From 09c0dbd0bb3076f7a08cfcf9f024eacc1955183e Mon Sep 17 00:00:00 2001 From: Vitaly Antonenko Date: Fri, 11 Oct 2024 10:15:04 +0300 Subject: [PATCH] fix: WIP --- .github/workflows/test_integration.yml | 7 ++++++- .../provider/resource_kubernetes_cloud_test.go | 14 ++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test_integration.yml b/.github/workflows/test_integration.yml index 317397b2..2250f68c 100644 --- a/.github/workflows/test_integration.yml +++ b/.github/workflows/test_integration.yml @@ -101,7 +101,12 @@ jobs: if: ${{ matrix.action-operator.cloud == 'lxd' }} # language=bash run: | - sudo microk8s.config > /home/$USER/microk8s-config.yaml + sudo microk8s.config view > /home/$USER/microk8s-config.yaml + { + echo 'MICROK8S_CONFIG<> "$GITHUB_ENV" - run: go mod download - env: TF_ACC: "1" diff --git a/internal/provider/resource_kubernetes_cloud_test.go b/internal/provider/resource_kubernetes_cloud_test.go index c9e76f31..622b6aeb 100644 --- a/internal/provider/resource_kubernetes_cloud_test.go +++ b/internal/provider/resource_kubernetes_cloud_test.go @@ -13,23 +13,20 @@ 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") - 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") + userName := os.Getenv("USER") resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, ProtoV6ProviderFactories: frameworkProviderFactories, Steps: []resource.TestStep{ { - Config: testAccResourceKubernetesCloud(cloudName, modelName, cloudConfig), + Config: testAccResourceKubernetesCloud(cloudName, modelName, userName, cloudConfig), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("juju_kubernetes_cloud."+cloudName, "name", cloudName), resource.TestCheckResourceAttr("juju_kubernetes_cloud."+cloudName, "model", modelName), @@ -39,7 +36,7 @@ func TestAcc_ResourceKubernetesCloud(t *testing.T) { }) } -func testAccResourceKubernetesCloud(cloudName string, modelName string, config string) string { +func testAccResourceKubernetesCloud(cloudName string, modelName string, userName string, config string) string { return internaltesting.GetStringFromTemplateWithData( "testAccResourceSecret", ` @@ -47,10 +44,10 @@ func testAccResourceKubernetesCloud(cloudName string, modelName string, config s resource "juju_kubernetes_cloud" "tf-test-k8scloud" { name = "{{.CloudName}}" - kubernetes_config = file("~/microk8s-config.yaml") + kubernetes_config = file("/home/{{.UserName}}/microk8s-config.yaml") } -resource "juju_model" {{.ModelName}} { +resource "juju_model" "tf-test-k8scloud-model" { name = "{{.ModelName}}" credential = juju_kubernetes_cloud.tf-test-k8scloud.credential cloud { @@ -60,6 +57,7 @@ resource "juju_model" {{.ModelName}} { `, internaltesting.TemplateData{ "CloudName": cloudName, "ModelName": modelName, + "UserName": userName, "Config": config, }) }