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

tests/integration: Run flux check after installation #4778

Merged
merged 1 commit into from
May 10, 2024
Merged
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions tests/integration/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ const (
// kubeconfigPath is the path of the file containing the kubeconfig
kubeconfigPath = "./build/kubeconfig"

// fluxBin is the path to the flux binary.
fluxBin = "./build/flux"

// default branch to be used when cloning git repositories
defaultBranch = "main"

Expand Down Expand Up @@ -291,6 +294,13 @@ func TestMain(m *testing.M) {
panic(fmt.Sprintf("error installing Flux: %v", err))
}

// On check failure, log and continue. Controllers may be ready by the time
// tests run.
log.Println("Running flux check")
if err := runFluxCheck(ctx); err != nil {
log.Printf("flux check failed: %v\n", err)
}

log.Println("Running e2e tests")
exitCode = m.Run()
}
Expand Down
13 changes: 10 additions & 3 deletions tests/integration/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,24 @@ func installFlux(ctx context.Context, tmpDir string, kubeconfigPath string) erro
bootstrapArgs = fmt.Sprintf("--token-auth --password=%s", cfg.gitPat)
}

bootstrapCmd := fmt.Sprintf("./build/flux bootstrap git --url=%s %s --kubeconfig=%s --path=clusters/e2e "+
bootstrapCmd := fmt.Sprintf("%s bootstrap git --url=%s %s --kubeconfig=%s --path=clusters/e2e "+
" --components-extra image-reflector-controller,image-automation-controller",
repoURL, bootstrapArgs, kubeconfigPath)
fluxBin, repoURL, bootstrapArgs, kubeconfigPath)

return tftestenv.RunCommand(ctx, "./", bootstrapCmd, tftestenv.RunCommandOptions{
Timeout: 15 * time.Minute,
})
}

func runFluxCheck(ctx context.Context) error {
checkCmd := fmt.Sprintf("%s check --kubeconfig %s", fluxBin, kubeconfigPath)
return tftestenv.RunCommand(ctx, "./", checkCmd, tftestenv.RunCommandOptions{
AttachConsole: true,
})
}

func uninstallFlux(ctx context.Context) error {
uninstallCmd := fmt.Sprintf("./build/flux uninstall --kubeconfig %s -s", kubeconfigPath)
uninstallCmd := fmt.Sprintf("%s uninstall --kubeconfig %s -s", fluxBin, kubeconfigPath)
if err := tftestenv.RunCommand(ctx, "./", uninstallCmd, tftestenv.RunCommandOptions{
Timeout: 15 * time.Minute,
}); err != nil {
Expand Down
Loading