Skip to content

Commit

Permalink
Try to fix acceptance tests (#361)
Browse files Browse the repository at this point in the history
* Try to fix acceptance tests

* Linter magic 2

* Add const for the subnetwork in test and brief info on it.

* Remove forgotten single quote
  • Loading branch information
Tsonov authored Aug 16, 2024
1 parent 43426b4 commit 194ff0d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
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

0 comments on commit 194ff0d

Please sign in to comment.