Skip to content

Commit 61324ba

Browse files
committed
tests: always pull the image if it's not build locally
Signed-off-by: Dorin Geman <[email protected]>
1 parent 080bb68 commit 61324ba

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

cmd/cli/commands/integration_test.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,23 +147,29 @@ func ociRegistry(t *testing.T, ctx context.Context, net *testcontainers.DockerNe
147147
}
148148

149149
func dockerModelRunner(t *testing.T, ctx context.Context, net *testcontainers.DockerNetwork) string {
150+
containerCustomizerOpts := []testcontainers.ContainerCustomizer{
151+
testcontainers.WithExposedPorts("12434/tcp"),
152+
testcontainers.WithWaitStrategy(wait.ForHTTP("/engines/status").WithPort("12434/tcp").WithStartupTimeout(10 * time.Second)),
153+
testcontainers.WithEnv(map[string]string{
154+
"DEFAULT_REGISTRY": "registry.local:5000",
155+
"INSECURE_REGISTRY": "true",
156+
}),
157+
network.WithNetwork([]string{"dmr"}, net),
158+
}
150159
if os.Getenv("BUILD_DMR") == "1" {
151160
t.Log("Building DMR container...")
152161
out, err := exec.CommandContext(ctx, "make", "-C", "../../..", "docker-build").CombinedOutput()
153162
if err != nil {
154163
t.Fatalf("Failed to build DMR container: %v\n%s", err, out)
155164
}
165+
} else {
166+
// Always pull the image if it's not build locally.
167+
containerCustomizerOpts = append(containerCustomizerOpts, testcontainers.WithAlwaysPull())
156168
}
157169
t.Log("Starting DMR container...")
158170
ctr, err := testcontainers.Run(
159171
ctx, "docker/model-runner:latest",
160-
testcontainers.WithExposedPorts("12434/tcp"),
161-
testcontainers.WithWaitStrategy(wait.ForHTTP("/engines/status").WithPort("12434/tcp").WithStartupTimeout(10*time.Second)),
162-
testcontainers.WithEnv(map[string]string{
163-
"DEFAULT_REGISTRY": "registry.local:5000",
164-
"INSECURE_REGISTRY": "true",
165-
}),
166-
network.WithNetwork([]string{"dmr"}, net),
172+
containerCustomizerOpts...,
167173
)
168174
require.NoError(t, err)
169175
testcontainers.CleanupContainer(t, ctr)

0 commit comments

Comments
 (0)