Skip to content

Commit

Permalink
Merge pull request #161 from philippgille/prefix-test-container-names…
Browse files Browse the repository at this point in the history
…-with-gokv

Prefix test container names with gokv
  • Loading branch information
philippgille committed Dec 21, 2023
2 parents 8b6e2a1 + 3e1aeee commit 3bd57d4
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions magefiles/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ func testImpl(impl string) (err error) {
// Implementations that require a separate service

var dockerImage string
dockerCmd := "docker run -d --rm"
dockerCmd := "docker run -d --rm --name gokv-"
var setup func() error
// TODO: Check quoting on Windows
switch impl {
case "cockroachdb":
dockerImage = "cockroachdb/cockroach"
dockerCmd += ` --name cockroachdb -p 26257:26257 --health-cmd='curl -f http://localhost:8080/health?ready=1' ` + dockerImage + ` start-single-node --insecure`
dockerCmd += `cockroachdb -p 26257:26257 --health-cmd='curl -f http://localhost:8080/health?ready=1' ` + dockerImage + ` start-single-node --insecure`
setup = func() error {
var out string
out, err = script.Exec(`docker exec cockroachdb bash -c './cockroach sql --insecure --execute="create database gokv;"'`).String()
out, err = script.Exec(`docker exec gokv-cockroachdb bash -c './cockroach sql --insecure --execute="create database gokv;"'`).String()
if err != nil {
// Print the output here, as it could be more info than what's in err.
fmt.Println(out)
Expand All @@ -53,43 +53,43 @@ func testImpl(impl string) (err error) {
}
case "consul":
dockerImage = "bitnami/consul"
dockerCmd += ` --name consul -e CONSUL_LOCAL_CONFIG='{"limits":{"http_max_conns_per_client":1000}}' -p 8500:8500 ` + dockerImage
dockerCmd += `consul -e CONSUL_LOCAL_CONFIG='{"limits":{"http_max_conns_per_client":1000}}' -p 8500:8500 ` + dockerImage
case "datastore": // Google Cloud Datastore via "Cloud Datastore Emulator"
// Using the ":slim" or ":alpine" tag would require the emulator to be installed manually.
// Both ways seem to be okay for setting the project: `-e CLOUDSDK_CORE_PROJECT=gokv` and CLI parameter `--project=gokv`
// `--host-port` is required because otherwise the server only listens on localhost IN the container.
dockerImage = "google/cloud-sdk"
dockerCmd += ` --name datastore -p 8081:8081 ` + dockerImage + ` gcloud beta emulators datastore start --no-store-on-disk --project=gokv --host-port=0.0.0.0:8081`
dockerCmd += `datastore -p 8081:8081 ` + dockerImage + ` gcloud beta emulators datastore start --no-store-on-disk --project=gokv --host-port=0.0.0.0:8081`
case "dynamodb": // DynamoDB via "DynamoDB local"
dockerImage = "amazon/dynamodb-local"
dockerCmd += ` --name dynamodb-local -p 8000:8000 ` + dockerImage
dockerCmd += `dynamodb-local -p 8000:8000 ` + dockerImage
case "etcd":
dockerImage = "bitnami/etcd"
dockerCmd += ` --name etcd -p 2379:2379 --env ALLOW_NONE_AUTHENTICATION=yes --health-cmd='etcdctl endpoint health' ` + dockerImage
dockerCmd += `etcd -p 2379:2379 --env ALLOW_NONE_AUTHENTICATION=yes --health-cmd='etcdctl endpoint health' ` + dockerImage
case "hazelcast":
dockerImage = "hazelcast/hazelcast"
dockerCmd += ` --name hazelcast -p 5701:5701 --health-cmd='curl -f http://localhost:5701/hazelcast/health/node-state' ` + dockerImage
dockerCmd += `hazelcast -p 5701:5701 --health-cmd='curl -f http://localhost:5701/hazelcast/health/node-state' ` + dockerImage
case "ignite":
dockerImage = "apacheignite/ignite"
dockerCmd += ` --name ignite -p 10800:10800 --health-cmd='${IGNITE_HOME}/bin/control.sh --baseline | grep "Cluster state: active"' ` + dockerImage
dockerCmd += `ignite -p 10800:10800 --health-cmd='${IGNITE_HOME}/bin/control.sh --baseline | grep "Cluster state: active"' ` + dockerImage
case "memcached":
dockerImage = "memcached"
dockerCmd += ` --name memcached -p 11211:11211 ` + dockerImage
dockerCmd += `memcached -p 11211:11211 ` + dockerImage
case "mongodb":
dockerImage = "mongo"
dockerCmd += ` --name mongodb -p 27017:27017 --health-cmd='echo "db.runCommand({ ping: 1 }).ok" | mongosh localhost:27017/test --quiet' ` + dockerImage
dockerCmd += `mongodb -p 27017:27017 --health-cmd='echo "db.runCommand({ ping: 1 }).ok" | mongosh localhost:27017/test --quiet' ` + dockerImage
case "mysql":
dockerImage = "mysql"
dockerCmd += ` --name mysql -e MYSQL_ALLOW_EMPTY_PASSWORD=true -p 3306:3306 --health-cmd='mysqladmin ping -h localhost' ` + dockerImage
dockerCmd += `mysql -e MYSQL_ALLOW_EMPTY_PASSWORD=true -p 3306:3306 --health-cmd='mysqladmin ping -h localhost' ` + dockerImage
case "postgresql":
dockerImage = "postgres:alpine"
dockerCmd += ` --name postgres -e POSTGRES_PASSWORD=secret -e POSTGRES_DB=gokv -p 5432:5432 --health-cmd='pg_isready -U postgres' ` + dockerImage
dockerCmd += `postgres -e POSTGRES_PASSWORD=secret -e POSTGRES_DB=gokv -p 5432:5432 --health-cmd='pg_isready -U postgres' ` + dockerImage
case "redis":
dockerImage = "redis"
dockerCmd += ` --name redis -p 6379:6379 --health-cmd='redis-cli ping' ` + dockerImage
dockerCmd += `redis -p 6379:6379 --health-cmd='redis-cli ping' ` + dockerImage
case "s3": // Amazon S3 via Minio
dockerImage = "minio/minio"
dockerCmd += ` --name s3 -e "MINIO_ACCESS_KEY=AKIAIOSFODNN7EXAMPLE" -e "MINIO_SECRET_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" -p 9000:9000 --health-cmd='mc ready local' ` + dockerImage + ` server /data`
dockerCmd += `s3 -e "MINIO_ACCESS_KEY=AKIAIOSFODNN7EXAMPLE" -e "MINIO_SECRET_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" -p 9000:9000 --health-cmd='mc ready local' ` + dockerImage + ` server /data`
case "tablestorage": // Tablestorage via Azurite
// In the past there was this problem: https://github.com/Azure/Azurite/issues/121
// With this Docker image:
Expand All @@ -100,7 +100,7 @@ func testImpl(impl string) (err error) {
// Currently no emulator exists for Alibaba Cloud Table Store.
case "zookeeper":
dockerImage = "zookeeper"
dockerCmd += ` --name zookeeper -p 2181:2181 -e ZOO_4LW_COMMANDS_WHITELIST=ruok --health-cmd='echo ruok | timeout 2 nc -w 2 localhost 2181 | grep imok' ` + dockerImage
dockerCmd += `zookeeper -p 2181:2181 -e ZOO_4LW_COMMANDS_WHITELIST=ruok --health-cmd='echo ruok | timeout 2 nc -w 2 localhost 2181 | grep imok' ` + dockerImage
default:
return errors.New("unknown `gokv.Store` implementation")
}
Expand Down

0 comments on commit 3bd57d4

Please sign in to comment.