|
6 | 6 | "os" |
7 | 7 | "testing" |
8 | 8 |
|
| 9 | + "github.com/gruntwork-io/terratest/modules/terraform" |
9 | 10 | "github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/testschematic" |
10 | 11 |
|
11 | 12 | "github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper/common" |
@@ -74,14 +75,34 @@ func setupOptions(t *testing.T, prefix string, terraformDir string, ocpVersion s |
74 | 75 | func TestRunAdvancedExample(t *testing.T) { |
75 | 76 | t.Parallel() |
76 | 77 |
|
77 | | - options := setupOptions(t, "base-ocp-adv", advancedExampleDir, ocpVersion3) |
| 78 | + options := setupOptions(t, "base-ocp-adv", advancedExampleDir, ocpVersion2) |
| 79 | + options.PostApplyHook = getClusterIngress |
78 | 80 |
|
79 | 81 | output, err := options.RunTestConsistency() |
80 | 82 |
|
81 | 83 | assert.Nil(t, err, "This should not have errored") |
82 | 84 | assert.NotNil(t, output, "Expected some output") |
83 | 85 | } |
84 | 86 |
|
| 87 | +func getClusterIngress(options *testhelper.TestOptions) error { |
| 88 | + |
| 89 | + // Get output of the last apply |
| 90 | + outputs, outputErr := terraform.OutputAllE(options.Testing, options.TerraformOptions) |
| 91 | + if !assert.NoError(options.Testing, outputErr, "error getting last terraform apply outputs: %s", outputErr) { |
| 92 | + return nil |
| 93 | + } |
| 94 | + |
| 95 | + // Validate that the "cluster_name" key is present in the outputs |
| 96 | + expectedOutputs := []string{"cluster_name"} |
| 97 | + _, ValidationErr := testhelper.ValidateTerraformOutputs(outputs, expectedOutputs...) |
| 98 | + |
| 99 | + // Proceed with the cluster ingress health check if "cluster_name" is valid |
| 100 | + if assert.NoErrorf(options.Testing, ValidationErr, "Some outputs not found or nil: %s", ValidationErr) { |
| 101 | + options.CheckClusterIngressHealthyDefaultTimeout(outputs["cluster_name"].(string)) |
| 102 | + } |
| 103 | + return nil |
| 104 | +} |
| 105 | + |
85 | 106 | func TestRunUpgradeAdvancedExample(t *testing.T) { |
86 | 107 | t.Parallel() |
87 | 108 |
|
|
0 commit comments