Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a configurable environment variable for MSSQL containers #7

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading