Skip to content

Commit

Permalink
Merge pull request #609 from anvial/fix-k8slcoud-acctest-by-dropping-…
Browse files Browse the repository at this point in the history
…model

fix(cloud): resolve acceptance test issues by removing model
  • Loading branch information
anvial authored Oct 17, 2024
2 parents 6e93012 + f1668fd commit ae8b121
Showing 1 changed file with 7 additions and 20 deletions.
27 changes: 7 additions & 20 deletions internal/provider/resource_kubernetes_cloud_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,53 +13,40 @@ import (
)

func TestAcc_ResourceKubernetesCloud(t *testing.T) {
// TODO: Skip this ACC test until we have a way to run correctly with kubernetes_config
// attribute set to a correct k8s config in github action environment
t.Skip(t.Name() + " is skipped until we have a way to run correctly with kubernetes_config attribute set to a correct k8s config in github action environment")

// TODO: This test is not adding model as a resource, which is required.
// The reason in the race that we (potentially) have in the Juju side.
// Once the problem is fixed (https://bugs.launchpad.net/juju/+bug/2084448),
// we should add the model as a resource.
if testingCloud != LXDCloudTesting {
t.Skip(t.Name() + " only runs with LXD")
}
cloudName := acctest.RandomWithPrefix("tf-test-k8scloud")
modelName := acctest.RandomWithPrefix("tf-test-model")
cloudConfig := os.Getenv("MICROK8S_CONFIG")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: frameworkProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccResourceKubernetesCloud(cloudName, modelName, cloudConfig),
Config: testAccResourceKubernetesCloudWithoutModel(cloudName, cloudConfig),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("juju_kubernetes_cloud."+cloudName, "name", cloudName),
resource.TestCheckResourceAttr("juju_kubernetes_cloud."+cloudName, "model", modelName),
),
},
},
})
}

func testAccResourceKubernetesCloud(cloudName string, modelName string, config string) string {
func testAccResourceKubernetesCloudWithoutModel(cloudName string, config string) string {
return internaltesting.GetStringFromTemplateWithData(
"testAccResourceSecret",
`
resource "juju_kubernetes_cloud" "tf-test-k8scloud" {
resource "juju_kubernetes_cloud" "{{.CloudName}}" {
name = "{{.CloudName}}"
kubernetes_config = file("~/microk8s-config.yaml")
}
resource "juju_model" {{.ModelName}} {
name = "{{.ModelName}}"
credential = juju_kubernetes_cloud.tf-test-k8scloud.credential
cloud {
name = juju_kubernetes_cloud.tf-test-k8scloud.name
}
}
`, internaltesting.TemplateData{
"CloudName": cloudName,
"ModelName": modelName,
"Config": config,
})
}

0 comments on commit ae8b121

Please sign in to comment.