From 3ef3a4d78cab8734b15e2bb7c595a41d9fc492af Mon Sep 17 00:00:00 2001 From: dishankkalra23 Date: Mon, 2 Sep 2024 17:04:56 +0530 Subject: [PATCH 1/2] tests: expose CheckClusterIngressHealthyDefaultTimeout --- tests/go.mod | 8 ++++---- tests/go.sum | 16 ++++++++-------- tests/pr_test.go | 11 +++++++++++ 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/tests/go.mod b/tests/go.mod index 851c678d1..5e3425ae7 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -5,9 +5,9 @@ go 1.22 toolchain go1.23.0 require ( - github.com/gruntwork-io/terratest v0.47.0 + github.com/gruntwork-io/terratest v0.47.1 github.com/stretchr/testify v1.9.0 - github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.37.2 + github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.38.1 ) require github.com/IBM/schematics-go-sdk v0.3.0 // indirect @@ -23,7 +23,7 @@ require ( github.com/IBM-Cloud/power-go-client v1.7.1 // indirect github.com/IBM/cloud-databases-go-sdk v0.7.0 // indirect github.com/IBM/go-sdk-core/v5 v5.17.4 // indirect - github.com/IBM/platform-services-go-sdk v0.67.0 // indirect + github.com/IBM/platform-services-go-sdk v0.68.1 // indirect github.com/IBM/project-go-sdk v0.3.0 // indirect github.com/IBM/vpc-go-sdk v1.0.2 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect @@ -67,7 +67,7 @@ require ( github.com/googleapis/gax-go/v2 v2.11.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect - github.com/hashicorp/go-getter v1.7.5 // indirect + github.com/hashicorp/go-getter v1.7.6 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/go-retryablehttp v0.7.7 // indirect github.com/hashicorp/go-safetemp v1.0.0 // indirect diff --git a/tests/go.sum b/tests/go.sum index 02b69bff6..165e7265c 100644 --- a/tests/go.sum +++ b/tests/go.sum @@ -199,8 +199,8 @@ github.com/IBM/go-sdk-core/v5 v5.9.2/go.mod h1:YlOwV9LeuclmT/qi/LAK2AsobbAP42veV github.com/IBM/go-sdk-core/v5 v5.10.2/go.mod h1:WZPFasUzsKab/2mzt29xPcfruSk5js2ywAPwW4VJjdI= github.com/IBM/go-sdk-core/v5 v5.17.4 h1:VGb9+mRrnS2HpHZFM5hy4J6ppIWnwNrw0G+tLSgcJLc= github.com/IBM/go-sdk-core/v5 v5.17.4/go.mod h1:KsAAI7eStAWwQa4F96MLy+whYSh39JzNjklZRbN/8ns= -github.com/IBM/platform-services-go-sdk v0.67.0 h1:AGu3NiCUyvyFUqbgtmsFRh74kyXrmNbSu1yG/qwGLIM= -github.com/IBM/platform-services-go-sdk v0.67.0/go.mod h1:6rYd3stLSnotYmZlxclw45EJPaQuLmh5f7c+Mg7rOg4= +github.com/IBM/platform-services-go-sdk v0.68.1 h1:RXGzEmdllzSj5OzCJO7AoTeQ+cgTTNa20CrrpLQe5KQ= +github.com/IBM/platform-services-go-sdk v0.68.1/go.mod h1:6rYd3stLSnotYmZlxclw45EJPaQuLmh5f7c+Mg7rOg4= github.com/IBM/project-go-sdk v0.3.0 h1:lZR4wT6UCsOZ8QkEBITrfM6OZkLlL70/HXiPxF/Olt4= github.com/IBM/project-go-sdk v0.3.0/go.mod h1:FOJM9ihQV3EEAY6YigcWiTNfVCThtdY8bLC/nhQHFvo= github.com/IBM/schematics-go-sdk v0.3.0 h1:Vwxw85SONflakiBsNHAfViKLyp9zJiH5/hh6SewOP5Q= @@ -450,16 +450,16 @@ github.com/googleapis/gax-go/v2 v2.11.0 h1:9V9PWXEsWnPpQhu/PeQIkS4eGzMlTLGgt80cU github.com/googleapis/gax-go/v2 v2.11.0/go.mod h1:DxmR61SGKkGLa2xigwuZIQpkCI2S5iydzRfb3peWZJI= github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/gruntwork-io/terratest v0.47.0 h1:xIy1pT7NbGVlMLDZEHl3+3iSnvffh8tN2pL6idn448c= -github.com/gruntwork-io/terratest v0.47.0/go.mod h1:oywHw1cFKXSYvKPm27U7quZVzDUlA22H2xUrKCe26xM= +github.com/gruntwork-io/terratest v0.47.1 h1:qOaxnL7Su5+KpDHYUN/ek1jn8ImvCKtOkaY4OSMS4tI= +github.com/gruntwork-io/terratest v0.47.1/go.mod h1:LnYX8BN5WxUMpDr8rtD39oToSL4CBERWSCusbJ0d/64= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= -github.com/hashicorp/go-getter v1.7.5 h1:dT58k9hQ/vbxNMwoI5+xFYAJuv6152UNvdHokfI5wE4= -github.com/hashicorp/go-getter v1.7.5/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744= +github.com/hashicorp/go-getter v1.7.6 h1:5jHuM+aH373XNtXl9TNTUH5Qd69Trve11tHIrB+6yj4= +github.com/hashicorp/go-getter v1.7.6/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744= github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k= github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= @@ -621,8 +621,8 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.37.2 h1:eCmT6aSQ3b3yNV4xkn8KXSaLufnZCNL6A744kljGvDI= -github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.37.2/go.mod h1:vkkmXzbPHcSiZ6A8bVeZpN9jkH9mbuNYuncS0rDvmQw= +github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.38.1 h1:K9NCtO7Mekoy/0hM5cJ6Dj5B6hnPIfx+R1d12bbSH+w= +github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.38.1/go.mod h1:+8DLAAN7KdLkv9S5O8he7uG/Xl+c8qo3xLIDZzBFiX8= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tmccombs/hcl2json v0.5.0 h1:cT2sXStOzKL06c8ZTf9vh+0N8GKGzV7+9RUaY5/iUP8= github.com/tmccombs/hcl2json v0.5.0/go.mod h1:B0ZpBthAKbQur6yZRKrtaqDmYLCvgnwHOBApE0faCpU= diff --git a/tests/pr_test.go b/tests/pr_test.go index 4fea34308..5d366948a 100644 --- a/tests/pr_test.go +++ b/tests/pr_test.go @@ -219,6 +219,7 @@ func TestRunRoksPattern(t *testing.T) { } options := setupOptionsRoksPattern(t, "ocp") + options.PostApplyHook = getClusterIngress output, err := options.RunTestConsistency() assert.Nil(t, err, "This should not have errored") @@ -237,6 +238,16 @@ func TestRunUpgradeRoksPattern(t *testing.T) { } } +func getClusterIngress(options *testhelper.TestOptions) error { + + // get output of last apply + outputs, outputErr := terraform.OutputAllE(options.Testing, options.TerraformOptions) + if assert.NoErrorf(options.Testing, outputErr, "error getting last terraform apply outputs: %s", outputErr) { + options.CheckClusterIngressHealthyDefaultTimeout(outputs["cluster_name"].(string)) + } + return nil +} + func setupOptionsVsiPattern(t *testing.T, prefix string) *testhelper.TestOptions { sshPublicKey := sshPublicKey(t) From cfdf355871294b196c99437f4a31454eee778d95 Mon Sep 17 00:00:00 2001 From: dishankkalra23 Date: Fri, 13 Sep 2024 14:37:46 +0530 Subject: [PATCH 2/2] fix: update validation --- tests/pr_test.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/pr_test.go b/tests/pr_test.go index 5d366948a..7d423774a 100644 --- a/tests/pr_test.go +++ b/tests/pr_test.go @@ -240,9 +240,18 @@ func TestRunUpgradeRoksPattern(t *testing.T) { func getClusterIngress(options *testhelper.TestOptions) error { - // get output of last apply + // Get output of the last apply outputs, outputErr := terraform.OutputAllE(options.Testing, options.TerraformOptions) - if assert.NoErrorf(options.Testing, outputErr, "error getting last terraform apply outputs: %s", outputErr) { + 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