Skip to content

Commit

Permalink
Merge pull request #7 from OctopusSolutionsEngineering/isaac/add-mssq…
Browse files Browse the repository at this point in the history
…l-tag-env-var

Add a configurable environment variable for MSSQL containers
  • Loading branch information
IsaacCalligeros95 authored Jul 25, 2024
2 parents 0876988 + f6d8e46 commit 42853d1
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion test/octopus_container_test_framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (o *OctopusContainerTest) setupNetwork(ctx context.Context) (testcontainers
func (o *OctopusContainerTest) setupDatabase(ctx context.Context, network string) (*MysqlContainer, error) {
req := testcontainers.ContainerRequest{
Name: "mssql-" + uuid.New().String(),
Image: "mcr.microsoft.com/mssql/server",
Image: "mcr.microsoft.com/mssql/server" + o.getMSSQLTaggedVersion(),
ExposedPorts: []string{"1433/tcp"},
Env: map[string]string{
"ACCEPT_EULA": "Y",
Expand Down Expand Up @@ -144,6 +144,15 @@ func (o *OctopusContainerTest) setupDatabase(ctx context.Context, network string
}, nil
}

func (o *OctopusContainerTest) getMSSQLTaggedVersion() string {
overrideMSSQLOctoTag := os.Getenv("OCTO_MSSQLTAG")
if overrideMSSQLOctoTag != "" {
return ":" + overrideMSSQLOctoTag
}

return ""
}

func (o *OctopusContainerTest) getOctopusImageUrl() string {
overrideImageUrl := os.Getenv("OCTOTESTIMAGEURL")
if overrideImageUrl != "" {
Expand Down Expand Up @@ -323,23 +332,28 @@ func (o *OctopusContainerTest) ArrangeContainer(m *testing.M) (*OctopusContainer
ctx := context.Background()

var err error
log.Print("Setting up network")
network, networkName, err = o.setupNetwork(ctx)
if err != nil {
log.Print("Failed to setup network container")
return err
}

sqlServer, err = o.setupDatabase(ctx, networkName)
if err != nil {
log.Print("Failed to setup mssql database container")
return err
}

sqlIp, err := sqlServer.Container.ContainerIP(ctx)
if err != nil {
log.Print("Failed to setup container IP container")
return err
}

sqlName, err := sqlServer.Container.Name(ctx)
if err != nil {
log.Print("Failed to get sql container name")
return err
}

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

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

octoIp, err := octopusContainer.Container.ContainerIP(ctx)
if err != nil {
log.Print("Failed to get octopus container IP")
return err
}

octoName, err := octopusContainer.Container.Name(ctx)
if err != nil {
log.Print("Failed to get octopus container Name")
return err
}

Expand Down

0 comments on commit 42853d1

Please sign in to comment.