From 97f06c72486129307d55e0959b464332b6268c64 Mon Sep 17 00:00:00 2001 From: n1Z3R Date: Wed, 27 Nov 2024 12:14:10 +0300 Subject: [PATCH] feat: add test with preemptible nodegroup --- ...resource_selectel_mks_nodegroup_v1_test.go | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/selectel/resource_selectel_mks_nodegroup_v1_test.go b/selectel/resource_selectel_mks_nodegroup_v1_test.go index 54a2f074..f348370a 100644 --- a/selectel/resource_selectel_mks_nodegroup_v1_test.go +++ b/selectel/resource_selectel_mks_nodegroup_v1_test.go @@ -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"), + ), + }, }, }) } @@ -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) +}