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

Expose CheckClusterIngressHealthy to the pr_test.go #869

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
20 changes: 20 additions & 0 deletions tests/pr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ func TestRunRoksPattern(t *testing.T) {
}
Copy link
Author

@dishankkalra23 dishankkalra23 Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ocofaigh @toddgiguere The PostApplyHook never executes because TestRunRoksPattern are skipped when enableSchematicsTests is True. Where should we add the hook because other test methods like TestRunVSIPattern, TestRunVpcPattern are also getting skipped.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The landing zone tests executes in schematics and post apply hook is yet to be supported in schematics.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taking this to deep dive today to decide whether we add a support for post apply hook in schematics or is there any other way to approach it?


options := setupOptionsRoksPattern(t, "ocp")
options.PostApplyHook = getClusterIngress

output, err := options.RunTestConsistency()
assert.Nil(t, err, "This should not have errored")
Expand All @@ -239,6 +240,25 @@ func TestRunUpgradeRoksPattern(t *testing.T) {
}
}

func getClusterIngress(options *testhelper.TestOptions) error {

// Get output of the last apply
outputs, outputErr := terraform.OutputAllE(options.Testing, options.TerraformOptions)
if assert.Error(options.Testing, outputErr, "error getting last terraform apply outputs: %s", outputErr) {
return nil
}

// Validate that the "cluster_name" key is present in the outputs
expectedOutputs := []string{"cluster_name"}
_, ValidationErr := testhelper.ValidateTerraformOutputs(outputs, expectedOutputs...)

// Proceed with the cluster ingress health check if "cluster_name" is valid
if assert.NoErrorf(options.Testing, ValidationErr, "Some outputs not found or nil: %s", ValidationErr) {
options.CheckClusterIngressHealthyDefaultTimeout(outputs["cluster_name"].(string))
}
return nil
}

func setupOptionsVsiPattern(t *testing.T, prefix string) *testhelper.TestOptions {

sshPublicKey := sshPublicKey(t)
Expand Down