1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-07-15 01:34:38 +02:00

Rewrite nexus 3 Integration Tests (#1902)

This commit adapts nexus 3 integration tests to our new docker-based framework of writing IT. It makes individual tests easier to read and debug. One significant change is that each test now spawns a separate Nexus instance, which requires more memory, but also isolates the tests better.
This commit is contained in:
Florian Wilhelm
2020-08-11 10:28:03 +02:00
committed by GitHub
parent 806f7c8a09
commit 324f854814
2 changed files with 82 additions and 93 deletions

View File

@ -59,6 +59,7 @@ func givenThisContainer(t *testing.T, bundle IntegrationTestDockerExecRunnerBund
Image: bundle.Image,
User: bundle.User,
Mounts: bundle.Mounts,
Environment: bundle.Environment,
Setup: bundle.Setup,
ContainerName: containerName,
}
@ -90,7 +91,7 @@ func givenThisContainer(t *testing.T, bundle IntegrationTestDockerExecRunnerBund
}
if len(testRunner.Environment) > 0 {
for envVarName, envVarValue := range testRunner.Environment {
params = append(params, "--env", fmt.Sprintf("%s='%s'", envVarName, envVarValue))
params = append(params, "--env", fmt.Sprintf("%s=%s", envVarName, envVarValue))
}
}
params = append(params, testRunner.Image, "sleep", "2000")
@ -151,11 +152,16 @@ func setupPiperBinary(t *testing.T, testRunner IntegrationTestDockerExecRunner,
}
func (d *IntegrationTestDockerExecRunner) whenRunningPiperCommand(command string, parameters ...string) error {
args := []string{"exec", "--workdir", "/project", d.ContainerName, "/bin/bash", "/piper-wrapper", "/piper", command}
args := []string{"exec", "--workdir", "/project", d.ContainerName, "/bin/bash", "--login", "/piper-wrapper", "/piper", command}
args = append(args, parameters...)
return d.Runner.RunExecutable("docker", args...)
}
func (d *IntegrationTestDockerExecRunner) runScriptInsideContainer(script string) error {
args := []string{"exec", "--workdir", "/project", d.ContainerName, "/bin/bash", "--login", "-c", script}
return d.Runner.RunExecutable("docker", args...)
}
func (d *IntegrationTestDockerExecRunner) assertHasOutput(t *testing.T, want string) {
buffer := new(bytes.Buffer)
d.Runner.Stdout(buffer)