Skip to content

Commit

Permalink
Keep running integration tests of modules without environment (#18125)
Browse files Browse the repository at this point in the history
Modules that don't define a local environment with docker compose or
kubernetes (kind) are not being executed. Fall back to the old default
of docker in that case.
  • Loading branch information
jsoriano authored Apr 30, 2020
1 parent bff78c9 commit b6ca76b
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions dev-tools/mage/integtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,37 +185,30 @@ func NewIntegrationRunners(path string, passInEnv map[string]string) (Integratio
if err != nil {
return nil, errors.Wrapf(err, "%s tester failed on Use", t.Name())
}
if use {
// Create the steps for the specific runner.
var runnerSteps IntegrationTestSteps
requirements := t.StepRequirements()
if requirements != nil {
runnerSteps = append(runnerSteps, requirements...)
}
runnerSteps = append(runnerSteps, steps...)

// Create the custom env for the runner.
env := map[string]string{}
for k, v := range passInEnv {
env[k] = v
}
env[insideIntegrationTestEnvVar] = "true"
passThroughEnvs(env, defaultPassthroughEnvVars...)
if mg.Verbose() {
env["MAGEFILE_VERBOSE"] = "1"
}
if UseVendor {
env["GOFLAGS"] = "-mod=vendor"
}

runner := &IntegrationRunner{
steps: runnerSteps,
tester: t,
dir: dir,
env: env,
}
runners = append(runners, runner)
if !use {
continue
}
runner, err := initRunner(t, dir, passInEnv)
if err != nil {
return nil, errors.Wrapf(err, "initializing %s runner", t.Name())
}
runners = append(runners, runner)
}
// Keep support for modules that don't have a local environment defined at the module
// level (system, stack and cloud modules by now)
if len(runners) == 0 {
if mg.Verbose() {
fmt.Printf(">> No runner found in %s, using docker\n", path)
}
tester, ok := globalIntegrationTesters["docker"]
if !ok {
return nil, fmt.Errorf("docker integration test runner not registered")
}
runner, err := initRunner(tester, dir, passInEnv)
if err != nil {
return nil, errors.Wrapf(err, "initializing docker runner")
}
runners = append(runners, runner)
}
return runners, nil
}
Expand All @@ -230,6 +223,10 @@ func NewDockerIntegrationRunner(passThroughEnvVars ...string) (*IntegrationRunne
if !ok {
return nil, fmt.Errorf("docker integration test runner not registered")
}
return initRunner(tester, cwd, nil, passThroughEnvVars...)
}

func initRunner(tester IntegrationTester, dir string, passInEnv map[string]string, passThroughEnvVars ...string) (*IntegrationRunner, error) {
var runnerSteps IntegrationTestSteps
requirements := tester.StepRequirements()
if requirements != nil {
Expand All @@ -240,8 +237,11 @@ func NewDockerIntegrationRunner(passThroughEnvVars ...string) (*IntegrationRunne
env := map[string]string{
insideIntegrationTestEnvVar: "true",
}
passThroughEnvs(env, defaultPassthroughEnvVars...)
for name, value := range passInEnv {
env[name] = value
}
passThroughEnvs(env, passThroughEnvVars...)
passThroughEnvs(env, defaultPassthroughEnvVars...)
if mg.Verbose() {
env["MAGEFILE_VERBOSE"] = "1"
}
Expand All @@ -252,7 +252,7 @@ func NewDockerIntegrationRunner(passThroughEnvVars ...string) (*IntegrationRunne
runner := &IntegrationRunner{
steps: runnerSteps,
tester: tester,
dir: cwd,
dir: dir,
env: env,
}
return runner, nil
Expand Down

0 comments on commit b6ca76b

Please sign in to comment.