Skip to content

Commit

Permalink
Revert "Fix rebalancing schedules and phase 1 clusters"
Browse files Browse the repository at this point in the history
This reverts commit 29b1980.
  • Loading branch information
ivanstankovcast committed Nov 14, 2023
1 parent 29b1980 commit 290a4d9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,53 @@ package castai

import (
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"testing"
)

func TestAccResourceRebalancingJob_eks(t *testing.T) {
rName := fmt.Sprintf("%v-rebalancing-job-%v", ResourcePrefix, acctest.RandString(8))
clusterName := "core-tf-acc"
func TestAccResourceRebalancingJob_basic(t *testing.T) {
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },

ProviderFactories: providerFactories,
Steps: []resource.TestStep{
{
Config: makeInitialRebalancingJobConfig(rName, clusterName),
Config: makeInitialRebalancingJobConfig(),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("castai_rebalancing_job.test", "enabled", "true"),
),
},
{
ResourceName: "castai_rebalancing_job.test",
ImportStateIdFunc: func(s *terraform.State) (string, error) {
clusterID := s.RootModule().Resources["castai_eks_cluster.test"].Primary.ID
return fmt.Sprintf("%v/%v", clusterID, rName), nil
clusterID := s.RootModule().Resources["castai_eks_clusterid.test"].Primary.ID
rebalancingScheduleName := "test"
return fmt.Sprintf("%v/%v", clusterID, rebalancingScheduleName), nil
},
ImportState: true,
ImportStateVerify: true,
},
{
Config: makeUpdatedRebalancingJobConfig(rName, clusterName),
Config: makeUpdatedRebalancingJobConfig(),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("castai_rebalancing_job.test", "enabled", "false"),
),
},
},
ExternalProviders: map[string]resource.ExternalProvider{
"aws": {
Source: "hashicorp/aws",
VersionConstraint: "~> 4.0",
},
},
})
}

func makeRebalancingJobConfig(rName, config string) string {
func makeRebalancingJobConfig(config string) string {
template := `
resource "castai_eks_clusterid" "test" {
account_id = "fake"
region = "eu-central-1"
cluster_name = "fake"
}
resource "castai_rebalancing_schedule" "test" {
name = %[1]q
name = "test"
schedule {
cron = "5 4 * * *"
}
Expand All @@ -66,18 +64,17 @@ resource "castai_rebalancing_schedule" "test" {
}
resource "castai_rebalancing_job" "test" {
cluster_id = castai_eks_cluster.test.id
cluster_id = castai_eks_clusterid.test.id
rebalancing_schedule_id = castai_rebalancing_schedule.test.id
%[2]s
%s
}
`
return fmt.Sprintf(template, rName, config)
return fmt.Sprintf(template, config)
}

func makeInitialRebalancingJobConfig(rName, clusterName string) string {
return ConfigCompose(testAccEKSClusterConfig(rName, clusterName), makeRebalancingJobConfig(rName, ""))
func makeInitialRebalancingJobConfig() string {
return makeRebalancingJobConfig("")
}

func makeUpdatedRebalancingJobConfig(rName, clusterName string) string {
return ConfigCompose(testAccEKSClusterConfig(rName, clusterName), makeRebalancingJobConfig(rName, "enabled=false"))
func makeUpdatedRebalancingJobConfig() string {
return makeRebalancingJobConfig("enabled=false")
}
19 changes: 4 additions & 15 deletions castai/sdk/api.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 290a4d9

Please sign in to comment.