Skip to content

Commit f6d8e46

Browse files
Add a configurable environment variable for MSSQL containers
1 parent 0876988 commit f6d8e46

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

test/octopus_container_test_framework.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func (o *OctopusContainerTest) setupNetwork(ctx context.Context) (testcontainers
104104
func (o *OctopusContainerTest) setupDatabase(ctx context.Context, network string) (*MysqlContainer, error) {
105105
req := testcontainers.ContainerRequest{
106106
Name: "mssql-" + uuid.New().String(),
107-
Image: "mcr.microsoft.com/mssql/server",
107+
Image: "mcr.microsoft.com/mssql/server" + o.getMSSQLTaggedVersion(),
108108
ExposedPorts: []string{"1433/tcp"},
109109
Env: map[string]string{
110110
"ACCEPT_EULA": "Y",
@@ -144,6 +144,15 @@ func (o *OctopusContainerTest) setupDatabase(ctx context.Context, network string
144144
}, nil
145145
}
146146

147+
func (o *OctopusContainerTest) getMSSQLTaggedVersion() string {
148+
overrideMSSQLOctoTag := os.Getenv("OCTO_MSSQLTAG")
149+
if overrideMSSQLOctoTag != "" {
150+
return ":" + overrideMSSQLOctoTag
151+
}
152+
153+
return ""
154+
}
155+
147156
func (o *OctopusContainerTest) getOctopusImageUrl() string {
148157
overrideImageUrl := os.Getenv("OCTOTESTIMAGEURL")
149158
if overrideImageUrl != "" {
@@ -323,23 +332,28 @@ func (o *OctopusContainerTest) ArrangeContainer(m *testing.M) (*OctopusContainer
323332
ctx := context.Background()
324333

325334
var err error
335+
log.Print("Setting up network")
326336
network, networkName, err = o.setupNetwork(ctx)
327337
if err != nil {
338+
log.Print("Failed to setup network container")
328339
return err
329340
}
330341

331342
sqlServer, err = o.setupDatabase(ctx, networkName)
332343
if err != nil {
344+
log.Print("Failed to setup mssql database container")
333345
return err
334346
}
335347

336348
sqlIp, err := sqlServer.Container.ContainerIP(ctx)
337349
if err != nil {
350+
log.Print("Failed to setup container IP container")
338351
return err
339352
}
340353

341354
sqlName, err := sqlServer.Container.Name(ctx)
342355
if err != nil {
356+
log.Print("Failed to get sql container name")
343357
return err
344358
}
345359

@@ -348,16 +362,19 @@ func (o *OctopusContainerTest) ArrangeContainer(m *testing.M) (*OctopusContainer
348362

349363
octopusContainer, err = o.setupOctopus(ctx, "Server="+sqlIp+",1433;Database=OctopusDeploy;User=sa;Password=Password01!", networkName)
350364
if err != nil {
365+
log.Print("Failed to setup octopus container")
351366
return err
352367
}
353368

354369
octoIp, err := octopusContainer.Container.ContainerIP(ctx)
355370
if err != nil {
371+
log.Print("Failed to get octopus container IP")
356372
return err
357373
}
358374

359375
octoName, err := octopusContainer.Container.Name(ctx)
360376
if err != nil {
377+
log.Print("Failed to get octopus container Name")
361378
return err
362379
}
363380

0 commit comments

Comments
 (0)