Skip to content

Commit

Permalink
Keep support for integration tests of modules without environment
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 committed Apr 30, 2020
1 parent 8365cba commit 85a87e6
Showing 1 changed file with 41 additions and 28 deletions.
69 changes: 41 additions & 28 deletions dev-tools/mage/integtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,37 +185,50 @@ 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...)
if !use {
continue
}
// 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"
}
// 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)
runner := &IntegrationRunner{
steps: runnerSteps,
tester: t,
dir: dir,
env: env,
}
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)
}
runner, err := NewDockerIntegrationRunner("MODULE")
if err != nil {
return nil, errors.Wrapf(err, "initializing docker runner")
}
runners = append(runners, runner)
}
return runners, nil
}
Expand Down

0 comments on commit 85a87e6

Please sign in to comment.