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

Try to fix acceptance tests #361

Merged
merged 4 commits into from
Aug 16, 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
11 changes: 9 additions & 2 deletions castai/resource_node_configuration_gke_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

const (
// acceptanceTestClusterSubnetworkName points to the subnet that the acceptance test cluster uses.
// Actual value (should) be managed by our IaC repository and could be shared with other clusters as well.
acceptanceTestClusterSubnetworkName = "ext-prov-e2e-shared-ip-range-nodes"
)

func TestAccResourceNodeConfiguration_gke(t *testing.T) {
rName := fmt.Sprintf("%v-node-cfg-%v", ResourcePrefix, acctest.RandString(8))
resourceName := "castai_node_configuration.test"
Expand Down Expand Up @@ -127,14 +133,15 @@ resource "castai_gke_cluster" "test" {
}

func testAccGCPConfig(rName, clusterName, projectID string) string {

return fmt.Sprintf(`
locals {
service_account_id = %[3]q
cluster_name = %[1]q
service_account_email = "${local.service_account_id}@$%[2]s.iam.gserviceaccount.com"
custom_role_id = "castai.tfAcc.${substr(sha1(local.service_account_id),0,8)}.tf"
subnet_id = "projects/%[2]s/regions/us-central1/subnetworks/%[1]s-ip-range-nodes"
subnet_id = "projects/%[2]s/regions/us-central1/subnetworks/%[4]s"
}
resource "google_service_account" "castai_service_account" {
Expand Down Expand Up @@ -177,5 +184,5 @@ resource "google_service_account_key" "castai_key" {
public_key_type = "TYPE_X509_PEM_FILE"
}
`, clusterName, projectID, rName)
`, clusterName, projectID, rName, acceptanceTestClusterSubnetworkName)
}
4 changes: 2 additions & 2 deletions castai/resource_node_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -984,9 +984,9 @@ func updateDefaultNodeTemplate(ctx context.Context, d *schema.ResourceData, meta
for _, d := range diagnostics {
if d.Severity == diag.Error {
if strings.Contains(d.Summary, "node template not found") {
return retry.RetryableError(fmt.Errorf(d.Summary))
return retry.RetryableError(fmt.Errorf("%s", d.Summary))
}
return retry.NonRetryableError(fmt.Errorf(d.Summary))
return retry.NonRetryableError(fmt.Errorf("%s", d.Summary))
}
}
return nil
Expand Down
Loading