Skip to content

Commit

Permalink
feat: add test with preemptible nodegroup
Browse files Browse the repository at this point in the history
  • Loading branch information
n1Z3R committed Nov 27, 2024
1 parent 86bc1e2 commit 97f06c7
Showing 1 changed file with 87 additions and 0 deletions.
87 changes: 87 additions & 0 deletions selectel/resource_selectel_mks_nodegroup_v1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,40 @@ func TestAccMKSNodegroupV1Basic(t *testing.T) {
resource.TestCheckResourceAttr("selectel_mks_nodegroup_v1.nodegroup_tf_acc_test_1", "nodegroup_type", "STANDARD"),
),
},
{
Config: testAccMKSNodegroupV1Preemptible(projectName, clusterName, kubeVersion, maintenanceWindowStart),
Check: resource.ComposeTestCheckFunc(
testAccCheckVPCV2ProjectExists("selectel_vpc_project_v2.project_tf_acc_test_1", &project),
testAccCheckMKSNodegroupV1Exists("selectel_mks_nodegroup_v1.nodegroup_tf_acc_test_1", &mksNodegroup),
resource.TestCheckResourceAttr("selectel_mks_nodegroup_v1.nodegroup_tf_acc_test_1", "availability_zone", "ru-9a"),
resource.TestCheckResourceAttr("selectel_mks_nodegroup_v1.nodegroup_tf_acc_test_1", "nodes_count", "2"),
resource.TestCheckResourceAttr("selectel_mks_nodegroup_v1.nodegroup_tf_acc_test_1", "nodes.#", "2"),
resource.TestCheckResourceAttr("selectel_mks_nodegroup_v1.nodegroup_tf_acc_test_1", "cpus", "1"),
resource.TestCheckResourceAttr("selectel_mks_nodegroup_v1.nodegroup_tf_acc_test_1", "ram_mb", "1024"),
resource.TestCheckResourceAttr("selectel_mks_nodegroup_v1.nodegroup_tf_acc_test_1", "volume_gb", "10"),
resource.TestCheckResourceAttr("selectel_mks_nodegroup_v1.nodegroup_tf_acc_test_1", "volume_type", "fast.ru-9a"),
resource.TestCheckResourceAttr("selectel_mks_nodegroup_v1.nodegroup_tf_acc_test_1", "enable_autoscale", "true"),
resource.TestCheckResourceAttr("selectel_mks_nodegroup_v1.nodegroup_tf_acc_test_1", "autoscale_min_nodes", "2"),
resource.TestCheckResourceAttr("selectel_mks_nodegroup_v1.nodegroup_tf_acc_test_1", "autoscale_max_nodes", "3"),
resource.TestCheckResourceAttr("selectel_mks_nodegroup_v1.nodegroup_tf_acc_test_1", "user_data", "IyEvYmluL2Jhc2ggLXYKYXB0IC15IHVwZGF0ZQphcHQgLXkgaW5zdGFsbCBtdHI="),
resource.TestCheckResourceAttr("selectel_mks_nodegroup_v1.nodegroup_tf_acc_test_1", "install_nvidia_device_plugin", "false"),
resource.TestCheckResourceAttr("selectel_mks_nodegroup_v1.nodegroup_tf_acc_test_1", "preemptible", "true"),
resource.TestCheckResourceAttr("selectel_mks_nodegroup_v1.nodegroup_tf_acc_test_1", "labels.label-key0", "label-value0"),
resource.TestCheckResourceAttr("selectel_mks_nodegroup_v1.nodegroup_tf_acc_test_1", "labels.label-key1", "label-value1"),
resource.TestCheckResourceAttr("selectel_mks_nodegroup_v1.nodegroup_tf_acc_test_1", "labels.label-key2", "label-value2"),
resource.TestCheckResourceAttr("selectel_mks_nodegroup_v1.nodegroup_tf_acc_test_1", "taints.#", "3"),
resource.TestCheckResourceAttr("selectel_mks_nodegroup_v1.nodegroup_tf_acc_test_1", "taints.0.key", "test-key-0"),
resource.TestCheckResourceAttr("selectel_mks_nodegroup_v1.nodegroup_tf_acc_test_1", "taints.0.value", "test-value-0"),
resource.TestCheckResourceAttr("selectel_mks_nodegroup_v1.nodegroup_tf_acc_test_1", "taints.0.effect", "NoSchedule"),
resource.TestCheckResourceAttr("selectel_mks_nodegroup_v1.nodegroup_tf_acc_test_1", "taints.1.key", "test-key-1"),
resource.TestCheckResourceAttr("selectel_mks_nodegroup_v1.nodegroup_tf_acc_test_1", "taints.1.value", "test-value-1"),
resource.TestCheckResourceAttr("selectel_mks_nodegroup_v1.nodegroup_tf_acc_test_1", "taints.1.effect", "NoExecute"),
resource.TestCheckResourceAttr("selectel_mks_nodegroup_v1.nodegroup_tf_acc_test_1", "taints.2.key", "test-key-2"),
resource.TestCheckResourceAttr("selectel_mks_nodegroup_v1.nodegroup_tf_acc_test_1", "taints.2.value", "test-value-2"),
resource.TestCheckResourceAttr("selectel_mks_nodegroup_v1.nodegroup_tf_acc_test_1", "taints.2.effect", "PreferNoSchedule"),
resource.TestCheckResourceAttr("selectel_mks_nodegroup_v1.nodegroup_tf_acc_test_1", "nodegroup_type", "STANDARD"),
),
},
},
})
}
Expand Down Expand Up @@ -400,3 +434,56 @@ resource "selectel_mks_nodegroup_v1" "nodegroup_tf_acc_test_1" {
}
}`, projectName, clusterName, kubeVersion, maintenanceWindowStart)
}

func testAccMKSNodegroupV1Preemptible(projectName, clusterName, kubeVersion, maintenanceWindowStart string) string {
return fmt.Sprintf(`
resource "selectel_vpc_project_v2" "project_tf_acc_test_1" {
name = "%s"
}
resource "selectel_mks_cluster_v1" "cluster_tf_acc_test_1" {
name = "%s"
kube_version = "%s"
project_id = "${selectel_vpc_project_v2.project_tf_acc_test_1.id}"
region = "ru-9"
maintenance_window_start = "%s"
}
resource "selectel_mks_nodegroup_v1" "nodegroup_tf_acc_test_1" {
cluster_id = "${selectel_mks_cluster_v1.cluster_tf_acc_test_1.id}"
project_id = "${selectel_mks_cluster_v1.cluster_tf_acc_test_1.project_id}"
region = "${selectel_mks_cluster_v1.cluster_tf_acc_test_1.region}"
availability_zone = "ru-9a"
nodes_count = 2
cpus = 1
ram_mb = 1024
volume_gb = 10
volume_type = "fast.ru-9a"
enable_autoscale = true
autoscale_min_nodes = 2
autoscale_max_nodes = 3
user_data = "IyEvYmluL2Jhc2ggLXYKYXB0IC15IHVwZGF0ZQphcHQgLXkgaW5zdGFsbCBtdHI="
install_nvidia_device_plugin = false
preemptible = true
labels = {
label-key0 = "label-value0"
label-key1 = "label-value1"
label-key2 = "label-value2"
}
taints {
key = "test-key-0"
value = "test-value-0"
effect = "NoSchedule"
}
taints {
key = "test-key-1"
value = "test-value-1"
effect = "NoExecute"
}
taints {
key = "test-key-2"
value = "test-value-2"
effect = "PreferNoSchedule"
}
}`, projectName, clusterName, kubeVersion, maintenanceWindowStart)
}

0 comments on commit 97f06c7

Please sign in to comment.