Skip to content

Commit

Permalink
Merge pull request #2187 from josephschorr/ds-restart
Browse files Browse the repository at this point in the history
Ensure datastore containers do not auto-restart
  • Loading branch information
josephschorr authored Jan 2, 2025
2 parents 5d0abb0 + d3fba84 commit d5f11f7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/testserver/datastore/crdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/google/uuid"
"github.com/jackc/pgx/v5"
"github.com/ory/dockertest/v3"
"github.com/ory/dockertest/v3/docker"
"github.com/stretchr/testify/require"

crdbmigrations "github.com/authzed/spicedb/internal/datastore/crdb/migrations"
Expand Down Expand Up @@ -44,6 +45,10 @@ func RunCRDBForTesting(t testing.TB, bridgeNetworkName string) RunningEngineForT
Tag: CRDBTestVersionTag,
Cmd: []string{"start-single-node", "--insecure", "--max-offset=50ms"},
NetworkID: bridgeNetworkName,
}, func(config *docker.HostConfig) {
// set AutoRemove to true so that stopped container goes away by itself
config.AutoRemove = true
config.RestartPolicy = docker.RestartPolicy{Name: "no"}
})
require.NoError(t, err)

Expand Down
5 changes: 5 additions & 0 deletions internal/testserver/datastore/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/google/uuid"
"github.com/ory/dockertest/v3"
"github.com/ory/dockertest/v3/docker"
"github.com/stretchr/testify/require"

"github.com/authzed/spicedb/internal/datastore/mysql/migrations"
Expand Down Expand Up @@ -64,6 +65,10 @@ func RunMySQLForTestingWithOptions(t testing.TB, options MySQLTesterOptions, bri
// increase max connections (default 151) to accommodate tests using the same docker container
Cmd: []string{"--max-connections=500"},
NetworkID: bridgeNetworkName,
}, func(config *docker.HostConfig) {
// set AutoRemove to true so that stopped container goes away by itself
config.AutoRemove = true
config.RestartPolicy = docker.RestartPolicy{Name: "no"}
})
require.NoError(t, err)

Expand Down
4 changes: 4 additions & 0 deletions internal/testserver/datastore/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ func RunPostgresForTestingWithCommitTimestamps(t testing.TB, bridgeNetworkName s
ExposedPorts: []string{POSTGRES_TEST_PORT + "/tcp"},
NetworkID: bridgeNetworkName,
Cmd: cmd,
}, func(config *docker.HostConfig) {
// set AutoRemove to true so that stopped container goes away by itself
config.AutoRemove = true
config.RestartPolicy = docker.RestartPolicy{Name: "no"}
})
require.NoError(t, err)

Expand Down
5 changes: 5 additions & 0 deletions internal/testserver/datastore/spanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"cloud.google.com/go/spanner/admin/instance/apiv1/instancepb"
"github.com/google/uuid"
"github.com/ory/dockertest/v3"
"github.com/ory/dockertest/v3/docker"
"github.com/stretchr/testify/require"

"github.com/authzed/spicedb/internal/datastore/spanner/migrations"
Expand All @@ -41,6 +42,10 @@ func RunSpannerForTesting(t testing.TB, bridgeNetworkName string, targetMigratio
Tag: "1.5.11",
ExposedPorts: []string{"9010/tcp"},
NetworkID: bridgeNetworkName,
}, func(config *docker.HostConfig) {
// set AutoRemove to true so that stopped container goes away by itself
config.AutoRemove = true
config.RestartPolicy = docker.RestartPolicy{Name: "no"}
})
require.NoError(t, err)

Expand Down

0 comments on commit d5f11f7

Please sign in to comment.