Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions dockertest/dockertest.go

This file was deleted.

8 changes: 4 additions & 4 deletions dockertest/README.md → dockertestx/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# dockertest
# dockertestx

This package is an abstraction of several dockerized data storages using `ory/dockertest` to bootstrap a specific dockerized instance.

Expand Down Expand Up @@ -44,7 +44,7 @@ if err != nil {
// create postgres instance
pgDocker, err := dockertest.CreatePostgres(
dockertest.PostgresWithDockerPool(pool),
dockertest.PostgresWithDockerNetwork(network),
dockertest.PostgresWithDockertestNetwork(network),
dockertest.PostgresWithDetail(
pgUser, pgPass, pgDBName,
),
Expand All @@ -56,12 +56,12 @@ connString := pgDocker.GetInternalConnString()
// create spice db instance
spiceDocker, err := dockertest.CreateSpiceDB(connString,
dockertest.SpiceDBWithDockerPool(pool),
dockertest.SpiceDBWithDockerNetwork(network),
dockertest.SpiceDBWithDockertestNetwork(network),
)

if err := dockertest.MigrateSpiceDB(connString,
dockertest.MigrateSpiceDBWithDockerPool(pool),
dockertest.MigrateSpiceDBWithDockerNetwork(network),
dockertest.MigrateSpiceDBWithDockertestNetwork(network),
); err != nil {
return err
}
Expand Down
93 changes: 93 additions & 0 deletions dockertestx/configs/nginx/cortex_nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
worker_processes 1;
error_log /dev/stderr;
pid /tmp/nginx.pid;
worker_rlimit_nofile 8192;

events {
worker_connections 1024;
}


http {
client_max_body_size 5M;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $status '
'"$request" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" $http_x_scope_orgid';
access_log /dev/stderr main;
sendfile on;
tcp_nopush on;
resolver 127.0.0.11 ipv6=off;

server {
listen {{.ExposedPort}};
proxy_connect_timeout 300s;
proxy_send_timeout 300s;
proxy_read_timeout 300s;
proxy_http_version 1.1;

location = /healthz {
return 200 'alive';
}

# Distributor Config
location = /ring {
proxy_pass http://{{.RulerHost}}$request_uri;
}

location = /all_user_stats {
proxy_pass http://{{.RulerHost}}$request_uri;
}

location = /api/prom/push {
proxy_pass http://{{.RulerHost}}$request_uri;
}

## New Remote write API. Ref: https://cortexmetrics.io/docs/api/#remote-write
location = /api/v1/push {
proxy_pass http://{{.RulerHost}}$request_uri;
}


# Alertmanager Config
location ~ /api/prom/alertmanager/.* {
proxy_pass http://{{.AlertManagerHost}}$request_uri;
}

location ~ /api/v1/alerts {
proxy_pass http://{{.AlertManagerHost}}$request_uri;
}

location ~ /multitenant_alertmanager/status {
proxy_pass http://{{.AlertManagerHost}}$request_uri;
}

# Ruler Config
location ~ /api/v1/rules {
proxy_pass http://{{.RulerHost}}$request_uri;
}

location ~ /ruler/ring {
proxy_pass http://{{.RulerHost}}$request_uri;
}

# Config Config
location ~ /api/prom/configs/.* {
proxy_pass http://{{.RulerHost}}$request_uri;
}

# Query Config
location ~ /api/prom/.* {
proxy_pass http://{{.RulerHost}}$request_uri;
}

## New Query frontend APIs as per https://cortexmetrics.io/docs/api/#querier--query-frontend
location ~ ^/prometheus/api/v1/(read|metadata|labels|series|query_range|query) {
proxy_pass http://{{.RulerHost}}$request_uri;
}

location ~ /prometheus/api/v1/label/.* {
proxy_pass http://{{.RulerHost}}$request_uri;
}
}
}
16 changes: 9 additions & 7 deletions dockertest/cortex.go → dockertestx/cortex.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dockertest
package dockertestx

import (
"fmt"
Expand All @@ -15,14 +15,14 @@ import (

type dockerCortexOption func(dc *dockerCortex)

// CortexWithDockerNetwork is an option to assign docker network
func CortexWithDockerNetwork(network *docker.Network) dockerCortexOption {
// CortexWithDockertestNetwork is an option to assign docker network
func CortexWithDockertestNetwork(network *dockertest.Network) dockerCortexOption {
return func(dc *dockerCortex) {
dc.network = network
}
}

// CortexWithDockerNetwork is an option to assign version tag
// CortexWithDockertestNetwork is an option to assign version tag
// of a `quay.io/cortexproject/cortex` image
func CortexWithVersionTag(versionTag string) dockerCortexOption {
return func(dc *dockerCortex) {
Expand Down Expand Up @@ -60,7 +60,7 @@ func CortexWithS3Endpoint(s3URL string) dockerCortexOption {
}

type dockerCortex struct {
network *docker.Network
network *dockertest.Network
pool *dockertest.Pool
moduleName string
alertManagerURL string
Expand Down Expand Up @@ -115,11 +115,13 @@ func CreateCortex(opts ...dockerCortexOption) (*dockerCortex, error) {
fmt.Sprintf("-alertmanager.storage.s3.endpoint=%s", dc.s3URL),
},
ExposedPorts: []string{"9009/tcp"},
ExtraHosts: []string{"cortex.siren_nginx_1:127.0.0.1"},
ExtraHosts: []string{
"cortex.siren_nginx_1:127.0.0.1",
},
}

if dc.network != nil {
runOpts.NetworkID = dc.network.ID
runOpts.NetworkID = dc.network.Network.ID
}

pwd, err := os.Getwd()
Expand Down
11 changes: 11 additions & 0 deletions dockertestx/dockertestx.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package dockertestx

import "runtime"

func DockerHostAddress() string {
var dockerHostInternal = "host-gateway" // linux by default
if runtime.GOOS == "darwin" {
dockerHostInternal = "host.docker.internal"
}
return dockerHostInternal
}
10 changes: 5 additions & 5 deletions dockertest/minio.go → dockertestx/minio.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dockertest
package dockertestx

import (
"fmt"
Expand All @@ -18,8 +18,8 @@ const (

type dockerMinioOption func(dm *dockerMinio)

// MinioWithDockerNetwork is an option to assign docker network
func MinioWithDockerNetwork(network *docker.Network) dockerMinioOption {
// MinioWithDockertestNetwork is an option to assign docker network
func MinioWithDockertestNetwork(network *dockertest.Network) dockerMinioOption {
return func(dm *dockerMinio) {
dm.network = network
}
Expand All @@ -41,7 +41,7 @@ func MinioWithDockerPool(pool *dockertest.Pool) dockerMinioOption {
}

type dockerMinio struct {
network *docker.Network
network *dockertest.Network
pool *dockertest.Pool
rootUser string
rootPassword string
Expand Down Expand Up @@ -103,7 +103,7 @@ func CreateMinio(opts ...dockerMinioOption) (*dockerMinio, error) {
}

if dm.network != nil {
runOpts.NetworkID = dm.network.ID
runOpts.NetworkID = dm.network.Network.ID
}

dm.dockertestResource, err = dm.pool.RunWithOptions(
Expand Down
10 changes: 5 additions & 5 deletions dockertest/minio_migrate.go → dockertestx/minio_migrate.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dockertest
package dockertestx

import (
"bytes"
Expand All @@ -14,8 +14,8 @@ const waitContainerTimeout = 60 * time.Second

type dockerMigrateMinioOption func(dmm *dockerMigrateMinio)

// MigrateMinioWithDockerNetwork is an option to assign docker network
func MigrateMinioWithDockerNetwork(network *docker.Network) dockerMigrateMinioOption {
// MigrateMinioWithDockertestNetwork is an option to assign docker network
func MigrateMinioWithDockertestNetwork(network *dockertest.Network) dockerMigrateMinioOption {
return func(dm *dockerMigrateMinio) {
dm.network = network
}
Expand All @@ -37,7 +37,7 @@ func MigrateMinioWithDockerPool(pool *dockertest.Pool) dockerMigrateMinioOption
}

type dockerMigrateMinio struct {
network *docker.Network
network *dockertest.Network
pool *dockertest.Pool
versionTag string
}
Expand Down Expand Up @@ -79,7 +79,7 @@ func MigrateMinio(minioHost string, bucketName string, opts ...dockerMigrateMini
}

if dm.network != nil {
runOpts.NetworkID = dm.network.ID
runOpts.NetworkID = dm.network.Network.ID
}

resource, err := dm.pool.RunWithOptions(runOpts, func(config *docker.HostConfig) {
Expand Down
Loading