Ft/rework acceptance tests (#675)

* Rework IaaS acceptance tests

Signed-off-by: Alexander Dahmen <alexander.dahmen@inovex.de>

* Rework mongodb acceptance tests

Signed-off-by: Alexander Dahmen <alexander.dahmen@inovex.de>

* Rework observability acceptance tests

Signed-off-by: Alexander Dahmen <alexander.dahmen@inovex.de>

* Rework secretsmanager acceptance tests

Signed-off-by: Alexander Dahmen <alexander.dahmen@inovex.de>

* Rework loadbalancer acceptance tests

Signed-off-by: Alexander Dahmen <alexander.dahmen@inovex.de>

* Rework ske acceptance tests

Signed-off-by: Alexander Dahmen <alexander.dahmen@inovex.de>

* Update documentation

Signed-off-by: Alexander Dahmen <alexander.dahmen@inovex.de>

---------

Signed-off-by: Alexander Dahmen <alexander.dahmen@inovex.de>
This commit is contained in:
Alexander Dahmen 2025-02-14 08:44:11 +01:00 committed by GitHub
parent ada9e096fe
commit f0168cfed9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 325 additions and 446 deletions

View file

@ -179,6 +179,7 @@ Terraform acceptance tests are run using the command `make test-acceptance-tf`.
- The env var `TF_ACC_PROJECT_ID` must be set with the ID of the STACKIT test project to test it.
- Authentication is set as usual.
- Optionally, the env var `TF_ACC_XXXXXX_CUSTOM_ENDPOINT` (where `XXXXXX` is the uppercase name of the service) can be set to use endpoints other than the default value.
- There are some acceptance test where it is needed to provide additional parameters, some of them have default values in order to run normally without manual interaction. Those default values can be overwritten (see testutils.go for a full list.)
Additionally:
@ -187,12 +188,6 @@ Additionally:
- The env var `TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_EMAIL` must be set as the email of the service account
- The env var `TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_TOKEN` must be set as a valid token of the service account. Can also be set in the credentials file used by authentication (see [Authentication](#authentication) for more details)
- The env var `TF_ACC_PROJECT_ID` is ignored
- For the Load Balancer service:
- OpenStack credentials are required, as the acceptance tests use the OpenStack provider to set up the supporting infrastructure
- These can be obtained after creating a user token through the [STACKIT Portal](https://portal.stackit.cloud/), in your project's Infrastructure API page
- The env var `TF_ACC_OS_USER_DOMAIN_NAME` must be set as the OpenStack user domain name
- The env var `TF_ACC_OS_USER_NAME` must be set as the OpenStack username
- The env var `TF_ACC_OS_PASSWORD` must be set as the OpenStack password
**WARNING:** Acceptance tests will create real resources, which may incur in costs.

View file

@ -20,8 +20,8 @@ import (
var instanceResource = map[string]string{
"project_id": testutil.ProjectId,
"name": testutil.ResourceNameWithDateTime("argus"),
"plan_name": "Monitoring-Basic-EU01",
"new_plan_name": "Monitoring-Medium-EU01",
"plan_name": "Observability-Monitoring-Basic-EU01",
"new_plan_name": "Observability-Monitoring-Medium-EU01",
"acl-0": "1.2.3.4/32",
"acl-1": "111.222.111.222/32",
"acl-1-updated": "111.222.111.125/32",

View file

@ -68,15 +68,16 @@ var volumeResource = map[string]string{
// Server resource data
var serverResource = map[string]string{
"project_id": testutil.ProjectId,
"availability_zone": "eu01-1",
"size": "64",
"source_type": "image",
"source_id": testutil.IaaSImageId,
"name": fmt.Sprintf("tf-acc-%s", acctest.RandStringFromCharSet(5, acctest.CharSetAlpha)),
"machine_type": serverMachineType,
"label1": "value",
"user_data": "#!/bin/bash",
"project_id": testutil.ProjectId,
"availability_zone": "eu01-1",
"size": "64",
"source_type": "image",
"source_id": testutil.IaaSImageId,
"name": fmt.Sprintf("tf-acc-%s", acctest.RandStringFromCharSet(5, acctest.CharSetAlpha)),
"machine_type": serverMachineType,
"label1": "value",
"user_data": "#!/bin/bash",
"delete_on_termination": "true",
}
// Security Group resource data
@ -98,7 +99,7 @@ var securityGroupRuleResource = map[string]string{
var publicIpResource = map[string]string{
"project_id": testutil.ProjectId,
"label1": "value",
"network_interface_id": testutil.IaaSNetworkInterfaceId,
"network_interface_id": "stackit_network_interface.network_interface.network_interface_id",
}
// Key pair resource data
@ -143,6 +144,26 @@ func networkResourceConfig(name, nameservers string) string {
)
}
// routed: true, gateway not present
func networkResourceConfigRouted(name, nameservers string) string {
return fmt.Sprintf(`
resource "stackit_network" "network" {
project_id = "%s"
name = "%s"
ipv4_prefix_length = "%s"
ipv4_nameservers = %s
ipv4_prefix = "%s"
routed = "true"
}
`,
networkResource["project_id"],
name,
networkResource["ipv4_prefix_length"],
nameservers,
networkResource["ipv4_prefix"],
)
}
func networkAreaResourceConfig(areaname, networkranges string) string {
return fmt.Sprintf(`
resource "stackit_network_area" "network_area" {
@ -226,7 +247,9 @@ func serverResourceConfig(name, machineType string) string {
size = %s
source_type = "%s"
source_id = "%s"
delete_on_termination = "%s"
}
network_interfaces = [stackit_network_interface.network_interface.network_interface_id]
labels = {
"label1" = "%s"
}
@ -240,6 +263,7 @@ func serverResourceConfig(name, machineType string) string {
serverResource["size"],
serverResource["source_type"],
serverResource["source_id"],
serverResource["delete_on_termination"],
serverResource["label1"],
serverResource["user_data"],
)
@ -290,18 +314,6 @@ func volumeAttachmentResourceConfig() string {
)
}
func nicAttachmentResourceConfig() string {
return fmt.Sprintf(`
resource "stackit_server_network_interface_attach" "attach_nic" {
project_id = "%s"
server_id = stackit_server.server.server_id
network_interface_id = stackit_network_interface.network_interface.network_interface_id
}
`,
testutil.ProjectId,
)
}
func serviceAccountAttachmentResourceConfig() string {
return fmt.Sprintf(`
resource "stackit_server_service_account_attach" "attach_sa" {
@ -359,14 +371,13 @@ func testAccVolumeConfig(name, size string) string {
}
func testAccServerConfig(name, nameservers, serverName, machineType, interfacename string) string {
return fmt.Sprintf("%s\n\n%s\n\n%s\n\n%s\n\n%s\n\n%s\n\n%s\n\n%s",
return fmt.Sprintf("%s\n\n%s\n\n%s\n\n%s\n\n%s\n\n%s\n\n%s",
testutil.IaaSProviderConfig(),
networkResourceConfig(name, nameservers),
serverResourceConfig(serverName, machineType),
volumeResourceConfig(volumeResource["name"], volumeResource["size"]),
networkInterfaceResourceConfig(interfacename),
volumeAttachmentResourceConfig(),
nicAttachmentResourceConfig(),
serviceAccountAttachmentResourceConfig(),
)
}
@ -379,9 +390,11 @@ func resourceConfigSecurityGroup(name, direction string) string {
)
}
func testAccPublicIpConfig(publicIpResourceConfig string) string {
return fmt.Sprintf("%s\n\n%s",
func testAccPublicIpConfig(nameNetwork, nameservers, nameNetworkInterface, publicIpResourceConfig string) string {
return fmt.Sprintf("%s\n\n%s\n\n%s\n\n%s",
testutil.IaaSProviderConfig(),
networkResourceConfigRouted(nameNetwork, nameservers),
networkInterfaceResourceConfig(nameNetworkInterface),
publicIpResourceConfig,
)
}
@ -683,6 +696,11 @@ func TestAccServer(t *testing.T) {
resource.TestCheckResourceAttr("stackit_server.server", "machine_type", serverResource["machine_type"]),
resource.TestCheckResourceAttr("stackit_server.server", "labels.label1", serverResource["label1"]),
resource.TestCheckResourceAttr("stackit_server.server", "user_data", serverResource["user_data"]),
resource.TestCheckResourceAttrSet("stackit_server.server", "network_interfaces.0"),
resource.TestCheckResourceAttr("stackit_server.server", "boot_volume.size", serverResource["size"]),
resource.TestCheckResourceAttr("stackit_server.server", "boot_volume.source_type", serverResource["source_type"]),
resource.TestCheckResourceAttr("stackit_server.server", "boot_volume.source_id", serverResource["source_id"]),
resource.TestCheckResourceAttr("stackit_server.server", "boot_volume.delete_on_termination", serverResource["delete_on_termination"]),
// Network Interface
resource.TestCheckResourceAttrPair(
@ -710,20 +728,6 @@ func TestAccServer(t *testing.T) {
"stackit_volume.volume", "volume_id",
),
// Nic attachment
resource.TestCheckResourceAttrPair(
"stackit_server_network_interface_attach.attach_nic", "project_id",
"stackit_server.server", "project_id",
),
resource.TestCheckResourceAttrPair(
"stackit_server_network_interface_attach.attach_nic", "server_id",
"stackit_server.server", "server_id",
),
resource.TestCheckResourceAttrPair(
"stackit_server_network_interface_attach.attach_nic", "network_interface_id",
"stackit_network_interface.network_interface", "network_interface_id",
),
// Service account attachment
resource.TestCheckResourceAttrPair(
"stackit_server_service_account_attach.attach_sa", "project_id",
@ -738,24 +742,24 @@ func TestAccServer(t *testing.T) {
// Data source
{
Config: fmt.Sprintf(`
%s
%s
data "stackit_network" "network" {
project_id = stackit_network.network.project_id
network_id = stackit_network.network.network_id
}
data "stackit_server" "server" {
project_id = stackit_server.server.project_id
server_id = stackit_server.server.server_id
}
data "stackit_network" "network" {
project_id = stackit_network.network.project_id
network_id = stackit_network.network.network_id
}
data "stackit_network_interface" "network_interface" {
project_id = stackit_network.network.project_id
network_id = stackit_network.network.network_id
network_interface_id = stackit_network_interface.network_interface.network_interface_id
}
`,
data "stackit_server" "server" {
project_id = stackit_server.server.project_id
server_id = stackit_server.server.server_id
}
data "stackit_network_interface" "network_interface" {
project_id = stackit_network.network.project_id
network_id = stackit_network.network.network_id
network_interface_id = stackit_network_interface.network_interface.network_interface_id
}
`,
testAccServerConfig(
networkResource["name"],
fmt.Sprintf(
@ -777,7 +781,6 @@ func TestAccServer(t *testing.T) {
resource.TestCheckResourceAttr("data.stackit_network.network", "name", networkResource["name"]),
resource.TestCheckResourceAttr("data.stackit_network.network", "nameservers.0", networkResource["nameserver0"]),
resource.TestCheckResourceAttr("data.stackit_network.network", "ipv4_gateway", networkResource["ipv4_gateway"]),
resource.TestCheckResourceAttr("data.stackit_network.network", "ipv4_prefix", networkResource["ipv4_prefix"]),
resource.TestCheckResourceAttr("data.stackit_network.network", "routed", networkResource["routed"]),
// Server
@ -820,7 +823,7 @@ func TestAccServer(t *testing.T) {
},
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"ipv4_prefix_length"}, // Field is not returned by the API
ImportStateVerifyIgnore: []string{"ipv4_prefix_length", "ipv4_prefix"}, // Field is not returned by the API
},
{
ResourceName: "stackit_server.server",
@ -899,26 +902,6 @@ func TestAccServer(t *testing.T) {
ImportState: true,
ImportStateVerify: false,
},
{
ResourceName: "stackit_server_network_interface_attach.attach_nic",
ImportStateIdFunc: func(s *terraform.State) (string, error) {
r, ok := s.RootModule().Resources["stackit_server_network_interface_attach.attach_nic"]
if !ok {
return "", fmt.Errorf("couldn't find resource stackit_server_network_interface_attach.attach_nic")
}
serverId, ok := r.Primary.Attributes["server_id"]
if !ok {
return "", fmt.Errorf("couldn't find attribute server_id")
}
networkInterfaceId, ok := r.Primary.Attributes["network_interface_id"]
if !ok {
return "", fmt.Errorf("couldn't find attribute network_interface_id")
}
return fmt.Sprintf("%s,%s,%s", testutil.ProjectId, serverId, networkInterfaceId), nil
},
ImportState: true,
ImportStateVerify: false,
},
// Update
{
Config: testAccServerConfig(
@ -941,7 +924,6 @@ func TestAccServer(t *testing.T) {
resource.TestCheckResourceAttr("stackit_network.network", "nameservers.0", networkResource["nameserver0"]),
resource.TestCheckResourceAttr("stackit_network.network", "nameservers.1", networkResource["nameserver1"]),
resource.TestCheckResourceAttr("stackit_network.network", "ipv4_gateway", networkResource["ipv4_gateway"]),
resource.TestCheckResourceAttr("stackit_network.network", "ipv4_prefix", networkResource["ipv4_prefix"]),
// Server
resource.TestCheckResourceAttr("stackit_server.server", "project_id", serverResource["project_id"]),
@ -951,6 +933,11 @@ func TestAccServer(t *testing.T) {
resource.TestCheckResourceAttr("stackit_server.server", "machine_type", updatedServerMachineType),
resource.TestCheckResourceAttr("stackit_server.server", "labels.label1", serverResource["label1"]),
resource.TestCheckResourceAttr("stackit_server.server", "user_data", serverResource["user_data"]),
resource.TestCheckResourceAttrSet("stackit_server.server", "network_interfaces.0"),
resource.TestCheckResourceAttr("stackit_server.server", "boot_volume.size", serverResource["size"]),
resource.TestCheckResourceAttr("stackit_server.server", "boot_volume.source_type", serverResource["source_type"]),
resource.TestCheckResourceAttr("stackit_server.server", "boot_volume.source_id", serverResource["source_id"]),
resource.TestCheckResourceAttr("stackit_server.server", "boot_volume.delete_on_termination", serverResource["delete_on_termination"]),
// Network interface
resource.TestCheckResourceAttrPair(
@ -1115,13 +1102,19 @@ func TestAccPublicIp(t *testing.T) {
// Creation
{
Config: testAccPublicIpConfig(
networkResource["name"],
fmt.Sprintf(
"[%q]",
networkResource["nameserver0"],
),
networkInterfaceResource["name"],
fmt.Sprintf(`
resource "stackit_public_ip" "public_ip" {
project_id = "%s"
labels = {
"label1" = "%s"
}
network_interface_id = "%s"
network_interface_id = %s
}
`,
publicIpResource["project_id"],
@ -1133,29 +1126,36 @@ func TestAccPublicIp(t *testing.T) {
resource.TestCheckResourceAttr("stackit_public_ip.public_ip", "project_id", publicIpResource["project_id"]),
resource.TestCheckResourceAttrSet("stackit_public_ip.public_ip", "public_ip_id"),
resource.TestCheckResourceAttr("stackit_public_ip.public_ip", "labels.label1", publicIpResource["label1"]),
resource.TestCheckResourceAttr("stackit_public_ip.public_ip", "network_interface_id", publicIpResource["network_interface_id"]),
resource.TestCheckResourceAttrSet("stackit_network_interface.network_interface", "network_interface_id"),
),
},
// Data source
{
Config: fmt.Sprintf(`
%s
data "stackit_public_ip" "public_ip" {
project_id = stackit_public_ip.public_ip.project_id
public_ip_id = stackit_public_ip.public_ip.public_ip_id
}
`,
testAccPublicIpConfig(
fmt.Sprintf(`
resource "stackit_public_ip" "public_ip" {
project_id = "%s"
labels = {
"label1" = "%s"
}
network_interface_id = "%s"
}
%s
data "stackit_public_ip" "public_ip" {
project_id = stackit_public_ip.public_ip.project_id
public_ip_id = stackit_public_ip.public_ip.public_ip_id
}
`,
testAccPublicIpConfig(
networkResource["name"],
fmt.Sprintf(
"[%q]",
networkResource["nameserver0"],
),
networkInterfaceResource["name"],
fmt.Sprintf(`
resource "stackit_public_ip" "public_ip" {
project_id = "%s"
labels = {
"label1" = "%s"
}
network_interface_id = %s
}
`,
publicIpResource["project_id"],
publicIpResource["label1"],
publicIpResource["network_interface_id"],
@ -1170,7 +1170,7 @@ func TestAccPublicIp(t *testing.T) {
"data.stackit_public_ip.public_ip", "public_ip_id",
),
resource.TestCheckResourceAttr("stackit_public_ip.public_ip", "labels.label1", publicIpResource["label1"]),
resource.TestCheckResourceAttr("data.stackit_public_ip.public_ip", "network_interface_id", publicIpResource["network_interface_id"]),
resource.TestCheckResourceAttrSet("data.stackit_public_ip.public_ip", "network_interface_id"),
),
},
// Import
@ -1193,14 +1193,20 @@ func TestAccPublicIp(t *testing.T) {
// Update
{
Config: testAccPublicIpConfig(
networkResource["name"],
fmt.Sprintf(
"[%q]",
networkResource["nameserver0"],
),
networkInterfaceResource["name"],
fmt.Sprintf(`
resource "stackit_public_ip" "public_ip" {
project_id = "%s"
labels = {
"label1" = "%s"
resource "stackit_public_ip" "public_ip" {
project_id = "%s"
labels = {
"label1" = "%s"
}
}
}
`,
`,
publicIpResource["project_id"],
publicIpResource["label1"],
),
@ -1344,6 +1350,8 @@ func TestAccImage(t *testing.T) {
resource.TestCheckResourceAttr("stackit_image.image", "disk_format", imageResource["disk_format"]),
resource.TestCheckResourceAttr("stackit_image.image", "min_disk_size", imageResource["min_disk_size"]),
resource.TestCheckResourceAttr("stackit_image.image", "min_ram", imageResource["min_ram"]),
resource.TestCheckResourceAttrSet("stackit_image.image", "local_file_path"),
resource.TestCheckResourceAttr("stackit_image.image", "local_file_path", imageResource["local_file_path"]),
resource.TestCheckResourceAttr("stackit_image.image", "labels.label1", imageResource["label1"]),
resource.TestCheckResourceAttr("stackit_image.image", "config.boot_menu", imageResource["boot_menu"]),
resource.TestCheckResourceAttrSet("stackit_image.image", "checksum.algorithm"),
@ -1360,19 +1368,7 @@ func TestAccImage(t *testing.T) {
image_id = stackit_image.image.image_id
}
`,
testAccImageConfig(
fmt.Sprintf(`
resource "stackit_image" "image" {
project_id = "%s"
labels = {
"label1" = "%s"
}
}
`,
imageResource["project_id"],
imageResource["label1"],
),
),
testAccImageConfig(imageResource["name"]),
),
Check: resource.ComposeAggregateTestCheckFunc(
// Instance
@ -1400,8 +1396,9 @@ func TestAccImage(t *testing.T) {
}
return fmt.Sprintf("%s,%s", testutil.ProjectId, imageId), nil
},
ImportState: true,
ImportStateVerify: true,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"local_file_path"},
},
// Update
{

View file

@ -20,31 +20,137 @@ import (
// Instance resource data
var loadBalancerResource = map[string]string{
"project_id": testutil.ProjectId,
"name": fmt.Sprintf("tf-acc-%s", acctest.RandStringFromCharSet(7, acctest.CharSetAlphaNum)),
"target_pool_name": "example-target-pool",
"target_port": "5432",
"target_port_updated": "5431",
"target_display_name": "example-target",
"healthy_threshold": "3",
"interval": "10s",
"interval_jitter": "5s",
"timeout": "10s",
"unhealthy_threshold": "3",
"use_source_ip_address": "true",
"listener_display_name": "example-listener",
"listener_port": "5432",
"listener_protocol": "PROTOCOL_TLS_PASSTHROUGH",
"serverNameIndicator": "domain.com",
"network_role": "ROLE_LISTENERS_AND_TARGETS",
"private_network_only": "true",
"credential_display_name": fmt.Sprintf("tf-acc-cred%s", acctest.RandStringFromCharSet(7, acctest.CharSetAlphaNum)),
"credential_username": "username",
"credential_password": "password",
"project_id": testutil.ProjectId,
"name": fmt.Sprintf("tf-acc-%s", acctest.RandStringFromCharSet(7, acctest.CharSetAlphaNum)),
"target_pool_name": "example-target-pool",
"target_port": "5432",
"target_port_updated": "5431",
"target_display_name": "example-target",
"healthy_threshold": "3",
"interval": "10s",
"interval_jitter": "5s",
"timeout": "10s",
"unhealthy_threshold": "3",
"use_source_ip_address": "true",
"listener_display_name": "example-listener",
"listener_port": "5432",
"listener_protocol": "PROTOCOL_TLS_PASSTHROUGH",
"network_role": "ROLE_LISTENERS_AND_TARGETS",
"private_network_only": "false",
}
func configResources(targetPort string) string {
// Network resource data
var networkResource = map[string]string{
"project_id": testutil.ProjectId,
"name": fmt.Sprintf("acc-test-%s", acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)),
"nameserver0": "8.8.8.8",
"ipv4_prefix": "192.168.0.0/25",
"routed": "true",
}
// Server resource data
var serverResource = map[string]string{
"project_id": testutil.ProjectId,
"availability_zone": "eu01-1",
"size": "32",
"source_type": "image",
"source_id": testutil.IaaSImageId,
"name": fmt.Sprintf("tf-acc-%s", acctest.RandStringFromCharSet(5, acctest.CharSetAlpha)),
"machine_type": "t1.1",
"user_data": "#!/bin/bash",
"delete_on_termination": "true",
}
// Public ip resource data
var publicIpResource = map[string]string{
"project_id": testutil.ProjectId,
"network_interface_id": "stackit_network_interface.network_interface.network_interface_id",
}
func publicIpResourceConfig() string {
return fmt.Sprintf(`
resource "stackit_public_ip" "public_ip" {
project_id = "%s"
network_interface_id = %s
lifecycle {
ignore_changes = [
network_interface_id
]
}
}
`,
publicIpResource["project_id"],
publicIpResource["network_interface_id"],
)
}
func networkResourceConfig() string {
return fmt.Sprintf(`
resource "stackit_network" "network" {
project_id = "%s"
name = "%s"
ipv4_nameservers = ["%s"]
ipv4_prefix = "%s"
routed = "%s"
}
`,
networkResource["project_id"],
networkResource["name"],
networkResource["nameserver0"],
networkResource["ipv4_prefix"],
networkResource["routed"],
)
}
func networkInterfaceResourceConfig() string {
return `
resource "stackit_network_interface" "network_interface" {
project_id = stackit_network.network.project_id
network_id = stackit_network.network.network_id
name = "name"
}
`
}
// server config
func serverResourceConfig() string {
return fmt.Sprintf(`
resource "stackit_server" "server" {
project_id = "%s"
availability_zone = "%s"
name = "%s"
machine_type = "%s"
boot_volume = {
size = %s
source_type = "%s"
source_id = "%s"
delete_on_termination = "%s"
}
network_interfaces = [stackit_network_interface.network_interface.network_interface_id]
user_data = "%s"
}
`,
serverResource["project_id"],
serverResource["availability_zone"],
serverResource["name"],
serverResource["machine_type"],
serverResource["size"],
serverResource["source_type"],
serverResource["source_id"],
serverResource["delete_on_termination"],
serverResource["user_data"],
)
}
// loadbalancer config
func loadbalancerResourceConfig(targetPort string) string {
return fmt.Sprintf(`
%s
%s
%s
%s
%s
@ -59,12 +165,9 @@ func configResources(targetPort string) string {
targets = [
{
display_name = "%s"
ip = openstack_compute_instance_v2.example.network.0.fixed_ip_v4
ip = stackit_network_interface.network_interface.ipv4
}
]
session_persistence = {
use_source_ip_address = %s
}
active_health_check = {
healthy_threshold = %s
interval = "%s"
@ -76,47 +179,34 @@ func configResources(targetPort string) string {
]
listeners = [
{
display_name = "%s"
port = %s
protocol = "%s"
server_name_indicators = [
{
name = "%s"
}
]
target_pool = "%s"
display_name = "%s"
port = %s
protocol = "%s"
target_pool = "%s"
}
]
networks = [
{
network_id = openstack_networking_network_v2.example.id
network_id = stackit_network.network.network_id
role = "%s"
}
]
external_address = stackit_public_ip.public_ip.ip
options = {
private_network_only = %s
}
}
resource "stackit_loadbalancer_observability_credential" "credential" {
project_id = "%s"
display_name = "%s"
username = "%s"
password = "%s"
}
`,
supportingInfraResources(loadBalancerResource["name"], OpenStack{
userDomainName: testutil.OSUserDomainName,
userName: testutil.OSUserName,
password: testutil.OSPassword,
}),
testutil.LoadBalancerProviderConfig(),
networkResourceConfig(),
networkInterfaceResourceConfig(),
publicIpResourceConfig(),
serverResourceConfig(),
loadBalancerResource["project_id"],
loadBalancerResource["name"],
loadBalancerResource["target_pool_name"],
targetPort,
loadBalancerResource["target_display_name"],
loadBalancerResource["use_source_ip_address"],
loadBalancerResource["healthy_threshold"],
loadBalancerResource["interval"],
loadBalancerResource["interval_jitter"],
@ -125,105 +215,20 @@ func configResources(targetPort string) string {
loadBalancerResource["listener_display_name"],
loadBalancerResource["listener_port"],
loadBalancerResource["listener_protocol"],
loadBalancerResource["serverNameIndicator"],
loadBalancerResource["target_pool_name"],
loadBalancerResource["network_role"],
loadBalancerResource["private_network_only"],
loadBalancerResource["project_id"],
loadBalancerResource["credential_display_name"],
loadBalancerResource["credential_username"],
loadBalancerResource["credential_password"],
)
}
func supportingInfraResources(name string, os OpenStack) string {
return fmt.Sprintf(`
provider "openstack" {
user_domain_name = "%s"
user_name = "%s"
password = "%s"
region = "RegionOne"
auth_url = "https://keystone.api.iaas.eu01.stackit.cloud/v3"
}
# Create a network
resource "openstack_networking_network_v2" "example" {
name = "%s_network"
}
resource "openstack_networking_subnet_v2" "example" {
name = "%s_subnet"
cidr = "192.168.0.0/25"
dns_nameservers = ["8.8.8.8"]
network_id = openstack_networking_network_v2.example.id
}
data "openstack_networking_network_v2" "public" {
name = "floating-net"
}
resource "openstack_networking_floatingip_v2" "example_ip" {
pool = data.openstack_networking_network_v2.public.name
}
# Create an instance
data "openstack_compute_flavor_v2" "example" {
name = "g1.1"
}
resource "openstack_compute_instance_v2" "example" {
depends_on = [openstack_networking_subnet_v2.example]
name = "%s_instance"
flavor_id = data.openstack_compute_flavor_v2.example.id
admin_pass = "example"
security_groups = ["default"]
block_device {
uuid = "4364cdb2-dacd-429b-803e-f0f7cfde1c24" // Ubuntu 22.04
volume_size = 32
source_type = "image"
destination_type = "volume"
delete_on_termination = true
}
network {
name = openstack_networking_network_v2.example.name
}
lifecycle {
ignore_changes = [security_groups]
}
}
resource "openstack_networking_router_v2" "example_router" {
name = "%s_router"
admin_state_up = "true"
external_network_id = data.openstack_networking_network_v2.public.id
}
resource "openstack_networking_router_interface_v2" "example_interface" {
router_id = openstack_networking_router_v2.example_router.id
subnet_id = openstack_networking_subnet_v2.example.id
}
`,
os.userDomainName, os.userName, os.password, name, name, name, name)
}
func TestAccLoadBalancerResource(t *testing.T) {
resource.Test(t, resource.TestCase{
ProtoV6ProviderFactories: testutil.TestAccProtoV6ProviderFactories,
ExternalProviders: map[string]resource.ExternalProvider{
"openstack": {
VersionConstraint: "= 1.52.1",
Source: "terraform-provider-openstack/openstack",
},
},
CheckDestroy: testAccCheckLoadBalancerDestroy,
CheckDestroy: testAccCheckLoadBalancerDestroy,
Steps: []resource.TestStep{
// Creation
{
Config: configResources(loadBalancerResource["target_port"]),
Config: loadbalancerResourceConfig(loadBalancerResource["target_port"]),
Check: resource.ComposeAggregateTestCheckFunc(
// Load balancer instance
resource.TestCheckResourceAttr("stackit_loadbalancer.loadbalancer", "project_id", loadBalancerResource["project_id"]),
@ -237,25 +242,13 @@ func TestAccLoadBalancerResource(t *testing.T) {
resource.TestCheckResourceAttr("stackit_loadbalancer.loadbalancer", "target_pools.0.active_health_check.interval_jitter", loadBalancerResource["interval_jitter"]),
resource.TestCheckResourceAttr("stackit_loadbalancer.loadbalancer", "target_pools.0.active_health_check.timeout", loadBalancerResource["timeout"]),
resource.TestCheckResourceAttr("stackit_loadbalancer.loadbalancer", "target_pools.0.active_health_check.unhealthy_threshold", loadBalancerResource["unhealthy_threshold"]),
resource.TestCheckResourceAttr("stackit_loadbalancer.loadbalancer", "target_pools.0.session_persistence.use_source_ip_address", loadBalancerResource["use_source_ip_address"]),
resource.TestCheckResourceAttr("stackit_loadbalancer.loadbalancer", "listeners.0.display_name", loadBalancerResource["listener_display_name"]),
resource.TestCheckResourceAttr("stackit_loadbalancer.loadbalancer", "listeners.0.port", loadBalancerResource["listener_port"]),
resource.TestCheckResourceAttr("stackit_loadbalancer.loadbalancer", "listeners.0.protocol", loadBalancerResource["listener_protocol"]),
resource.TestCheckResourceAttr("stackit_loadbalancer.loadbalancer", "listeners.0.server_name_indicators.0.name", loadBalancerResource["serverNameIndicator"]),
resource.TestCheckResourceAttr("stackit_loadbalancer.loadbalancer", "listeners.0.target_pool", loadBalancerResource["target_pool_name"]),
resource.TestCheckResourceAttrSet("stackit_loadbalancer.loadbalancer", "networks.0.network_id"),
resource.TestCheckResourceAttr("stackit_loadbalancer.loadbalancer", "networks.0.role", loadBalancerResource["network_role"]),
resource.TestCheckResourceAttr("stackit_loadbalancer.loadbalancer", "options.private_network_only", loadBalancerResource["private_network_only"]),
// Credential
resource.TestCheckResourceAttrPair(
"stackit_loadbalancer_observability_credential.credential", "project_id",
"stackit_loadbalancer.loadbalancer", "project_id",
),
resource.TestCheckResourceAttrSet("stackit_loadbalancer_observability_credential.credential", "credentials_ref"),
resource.TestCheckResourceAttr("stackit_loadbalancer_observability_credential.credential", "display_name", loadBalancerResource["credential_display_name"]),
resource.TestCheckResourceAttr("stackit_loadbalancer_observability_credential.credential", "username", loadBalancerResource["credential_username"]),
resource.TestCheckResourceAttr("stackit_loadbalancer_observability_credential.credential", "password", loadBalancerResource["credential_password"]),
),
},
// Data source
@ -268,7 +261,7 @@ func TestAccLoadBalancerResource(t *testing.T) {
name = stackit_loadbalancer.loadbalancer.name
}
`,
configResources(loadBalancerResource["target_port"]),
loadbalancerResourceConfig(loadBalancerResource["target_port"]),
),
Check: resource.ComposeAggregateTestCheckFunc(
// Load balancer instance
@ -292,15 +285,12 @@ func TestAccLoadBalancerResource(t *testing.T) {
resource.TestCheckResourceAttr("data.stackit_loadbalancer.loadbalancer", "target_pools.0.active_health_check.interval_jitter", loadBalancerResource["interval_jitter"]),
resource.TestCheckResourceAttr("data.stackit_loadbalancer.loadbalancer", "target_pools.0.active_health_check.timeout", loadBalancerResource["timeout"]),
resource.TestCheckResourceAttr("data.stackit_loadbalancer.loadbalancer", "target_pools.0.active_health_check.unhealthy_threshold", loadBalancerResource["unhealthy_threshold"]),
resource.TestCheckResourceAttr("data.stackit_loadbalancer.loadbalancer", "target_pools.0.session_persistence.use_source_ip_address", loadBalancerResource["use_source_ip_address"]),
resource.TestCheckResourceAttr("data.stackit_loadbalancer.loadbalancer", "listeners.0.display_name", loadBalancerResource["listener_display_name"]),
resource.TestCheckResourceAttr("data.stackit_loadbalancer.loadbalancer", "listeners.0.port", loadBalancerResource["listener_port"]),
resource.TestCheckResourceAttr("data.stackit_loadbalancer.loadbalancer", "listeners.0.protocol", loadBalancerResource["listener_protocol"]),
resource.TestCheckResourceAttr("data.stackit_loadbalancer.loadbalancer", "listeners.0.server_name_indicators.0.name", loadBalancerResource["serverNameIndicator"]),
resource.TestCheckResourceAttr("data.stackit_loadbalancer.loadbalancer", "listeners.0.target_pool", loadBalancerResource["target_pool_name"]),
resource.TestCheckResourceAttrSet("data.stackit_loadbalancer.loadbalancer", "networks.0.network_id"),
resource.TestCheckResourceAttr("data.stackit_loadbalancer.loadbalancer", "networks.0.role", loadBalancerResource["network_role"]),
resource.TestCheckResourceAttr("data.stackit_loadbalancer.loadbalancer", "options.private_network_only", loadBalancerResource["private_network_only"]),
),
},
// Import
@ -318,29 +308,13 @@ func TestAccLoadBalancerResource(t *testing.T) {
return fmt.Sprintf("%s,%s", testutil.ProjectId, name), nil
},
ImportState: true,
ImportStateVerify: true,
},
{
ResourceName: "stackit_loadbalancer_observability_credential.credential",
ImportStateIdFunc: func(s *terraform.State) (string, error) {
r, ok := s.RootModule().Resources["stackit_loadbalancer_observability_credential.credential"]
if !ok {
return "", fmt.Errorf("couldn't find resource stackit_loadbalancer_observability_credential.credential")
}
credentialsRef, ok := r.Primary.Attributes["credentials_ref"]
if !ok {
return "", fmt.Errorf("couldn't find attribute credentials_ref")
}
return fmt.Sprintf("%s,%s", testutil.ProjectId, credentialsRef), nil
},
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"password"},
ImportStateVerifyIgnore: []string{"options.private_network_only"},
},
// Update
{
Config: configResources(loadBalancerResource["target_port_updated"]),
Config: loadbalancerResourceConfig(loadBalancerResource["target_port_updated"]),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("stackit_loadbalancer.loadbalancer", "project_id", loadBalancerResource["project_id"]),
resource.TestCheckResourceAttr("stackit_loadbalancer.loadbalancer", "name", loadBalancerResource["name"]),
@ -352,12 +326,6 @@ func TestAccLoadBalancerResource(t *testing.T) {
})
}
type OpenStack struct {
userDomainName string
userName string
password string
}
func testAccCheckLoadBalancerDestroy(s *terraform.State) error {
ctx := context.Background()
var client *loadbalancer.APIClient

View file

@ -26,12 +26,12 @@ var instanceResource = map[string]string{
"flavor_cpu": "2",
"flavor_ram": "4",
"flavor_description": "Small, Compute optimized",
"replicas": "1",
"replicas": "3",
"storage_class": "premium-perf2-mongodb",
"storage_size": "10",
"version": "5.0",
"version_updated": "6.0",
"options_type": "Single",
"version": "6.0",
"version_updated": "7.0",
"options_type": "Replica",
"flavor_id": "2.4",
"backup_schedule": "00 6 * * *",
"backup_schedule_updated": "00 12 * * *",
@ -252,7 +252,7 @@ func TestAccMongoDBFlexFlexResource(t *testing.T) {
},
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"password"},
ImportStateVerifyIgnore: []string{"password", "uri"},
},
// Update
{

View file

@ -20,8 +20,8 @@ import (
var instanceResource = map[string]string{
"project_id": testutil.ProjectId,
"name": testutil.ResourceNameWithDateTime("observability"),
"plan_name": "Monitoring-Basic-EU01",
"new_plan_name": "Monitoring-Medium-EU01",
"plan_name": "Observability-Monitoring-Basic-EU01",
"new_plan_name": "Observability-Monitoring-Medium-EU01",
"acl-0": "1.2.3.4/32",
"acl-1": "111.222.111.222/32",
"acl-1-updated": "111.222.111.125/32",

View file

@ -291,7 +291,9 @@ func testAccCheckSecretsManagerDestroy(s *terraform.State) error {
var client *secretsmanager.APIClient
var err error
if testutil.SecretsManagerCustomEndpoint == "" {
client, err = secretsmanager.NewAPIClient()
client, err = secretsmanager.NewAPIClient(
config.WithRegion("eu01"),
)
} else {
client, err = secretsmanager.NewAPIClient(
config.WithEndpoint(testutil.SecretsManagerCustomEndpoint),

View file

@ -21,17 +21,17 @@ var clusterResource = map[string]string{
"project_id": testutil.ProjectId,
"name": fmt.Sprintf("cl-%s", acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum)),
"name_min": fmt.Sprintf("cl-min-%s", acctest.RandStringFromCharSet(3, acctest.CharSetAlphaNum)),
"kubernetes_version_min": "1.29",
"kubernetes_version_used": "1.29.10",
"kubernetes_version_min_new": "1.30",
"kubernetes_version_used_new": "1.30.6",
"kubernetes_version_min": "1.30",
"kubernetes_version_used": "1.30.7",
"kubernetes_version_min_new": "1.31",
"kubernetes_version_used_new": "1.31.4",
"nodepool_name": "np-acc-test",
"nodepool_name_min": "np-acc-min-test",
"nodepool_machine_type": "b1.2",
"nodepool_os_version_min": "3975.2",
"nodepool_os_version_used": "3975.2.0",
"nodepool_os_version_min_new": "3975.2.1",
"nodepool_os_version_used_new": "3975.2.1",
"nodepool_os_version_min": "4081.2.0",
"nodepool_os_version_used": "4081.2.0",
"nodepool_os_version_min_new": "4081.2.1",
"nodepool_os_version_used_new": "4081.2.1",
"nodepool_os_name": "flatcar",
"nodepool_minimum": "2",
"nodepool_maximum": "3",
@ -52,7 +52,7 @@ var clusterResource = map[string]string{
"extensions_argus_enabled": "false",
"extensions_argus_instance_id": "aaaaaaaa-1111-2222-3333-444444444444", // A not-existing Argus ID let the creation time-out.
"extensions_dns_enabled": "true",
"extensions_dns_zones": "foo.onstackit.cloud", // Dummy DNS zone, replace when running the tests!
"extensions_dns_zones": dnsResource["dns_name"],
"hibernations_start": "0 16 * * *",
"hibernations_end": "0 18 * * *",
"hibernations_timezone": "Europe/Berlin",
@ -64,6 +64,28 @@ var clusterResource = map[string]string{
"kubeconfig_expiration": "3600",
}
var dnsResource = map[string]string{
"project_id": testutil.ProjectId,
"dns_name": "acc-test.runs.onstackit.cloud",
}
func getDnsConfig() string {
return fmt.Sprintf(`
resource "stackit_dns_zone" "dns" {
project_id = "%s"
name = "acc-test-zone"
dns_name = "%s"
description = "DNS zone used by acceptance tests."
contact_email = "hostmaster@stackit.cloud"
type = "primary"
default_ttl = 3600
}
`,
dnsResource["project_id"],
dnsResource["dns_name"],
)
}
func getConfig(kubernetesVersion, nodePoolMachineOSVersion string, maintenanceEnd *string) string {
maintenanceEndTF := clusterResource["maintenance_end"]
if maintenanceEnd != nil {
@ -72,6 +94,8 @@ func getConfig(kubernetesVersion, nodePoolMachineOSVersion string, maintenanceEn
return fmt.Sprintf(`
%s
%s
resource "stackit_ske_cluster" "cluster" {
project_id = "%s"
name = "%s"
@ -132,25 +156,9 @@ func getConfig(kubernetesVersion, nodePoolMachineOSVersion string, maintenanceEn
expiration = "%s"
}
resource "stackit_ske_cluster" "cluster_min" {
project_id = "%s"
name = "%s"
node_pools = [{
name = "%s"
machine_type = "%s"
minimum = "%s"
maximum = "%s"
availability_zones = ["%s"]
}]
maintenance = {
enable_kubernetes_version_updates = %s
enable_machine_image_version_updates = %s
start = "%s"
end = "%s"
}
}
`,
testutil.SKEProviderConfig(),
getDnsConfig(),
clusterResource["project_id"],
clusterResource["name"],
kubernetesVersion,
@ -188,30 +196,18 @@ func getConfig(kubernetesVersion, nodePoolMachineOSVersion string, maintenanceEn
// Kubeconfig
clusterResource["kubeconfig_expiration"],
// Minimal
clusterResource["project_id"],
clusterResource["name_min"],
clusterResource["nodepool_name_min"],
clusterResource["nodepool_machine_type"],
clusterResource["nodepool_minimum"],
clusterResource["nodepool_maximum"],
clusterResource["nodepool_zone"],
clusterResource["maintenance_enable_kubernetes_version_updates"],
clusterResource["maintenance_enable_machine_image_version_updates"],
clusterResource["maintenance_start"],
maintenanceEndTF,
)
}
func TestAccSKE(t *testing.T) {
resource.ParallelTest(t, resource.TestCase{
resource.Test(t, resource.TestCase{
ProtoV6ProviderFactories: testutil.TestAccProtoV6ProviderFactories,
CheckDestroy: testAccCheckSKEDestroy,
Steps: []resource.TestStep{
// 1) Creation
{
Config: getConfig(clusterResource["kubernetes_version_min"], clusterResource["nodepool_os_version_min"], nil),
Check: resource.ComposeAggregateTestCheckFunc(
// cluster data
@ -267,59 +263,26 @@ func TestAccSKE(t *testing.T) {
),
resource.TestCheckResourceAttr("stackit_ske_kubeconfig.kubeconfig", "expiration", clusterResource["kubeconfig_expiration"]),
resource.TestCheckResourceAttrSet("stackit_ske_kubeconfig.kubeconfig", "expires_at"),
// Minimal cluster
resource.TestCheckResourceAttr("stackit_ske_cluster.cluster_min", "name", clusterResource["name_min"]),
resource.TestCheckResourceAttrSet("stackit_ske_cluster.cluster_min", "kubernetes_version_used"),
resource.TestCheckNoResourceAttr("stackit_ske_cluster.cluster_min", "allow_privileged_containers"),
resource.TestCheckResourceAttr("stackit_ske_cluster.cluster_min", "node_pools.0.name", clusterResource["nodepool_name_min"]),
resource.TestCheckResourceAttr("stackit_ske_cluster.cluster_min", "node_pools.0.availability_zones.#", "1"),
resource.TestCheckResourceAttr("stackit_ske_cluster.cluster_min", "node_pools.0.availability_zones.0", clusterResource["nodepool_zone"]),
resource.TestCheckResourceAttrSet("stackit_ske_cluster.cluster_min", "node_pools.0.os_name"),
resource.TestCheckResourceAttr("stackit_ske_cluster.cluster_min", "node_pools.0.os_version_used", clusterResource["nodepool_os_version_used"]),
resource.TestCheckResourceAttr("stackit_ske_cluster.cluster_min", "node_pools.0.machine_type", clusterResource["nodepool_machine_type"]),
resource.TestCheckResourceAttr("stackit_ske_cluster.cluster_min", "node_pools.0.minimum", clusterResource["nodepool_minimum"]),
resource.TestCheckResourceAttr("stackit_ske_cluster.cluster_min", "node_pools.0.maximum", clusterResource["nodepool_maximum"]),
resource.TestCheckResourceAttrSet("stackit_ske_cluster.cluster_min", "node_pools.0.max_surge"),
resource.TestCheckResourceAttrSet("stackit_ske_cluster.cluster_min", "node_pools.0.max_unavailable"),
resource.TestCheckResourceAttrSet("stackit_ske_cluster.cluster_min", "node_pools.0.volume_type"),
resource.TestCheckResourceAttr("stackit_ske_cluster.cluster", "node_pools.0.volume_size", clusterResource["nodepool_volume_size"]),
resource.TestCheckResourceAttr("stackit_ske_cluster.cluster_min", "node_pools.0.labels.%", "0"),
resource.TestCheckNoResourceAttr("stackit_ske_cluster.cluster_min", "node_pools.0.taints"),
resource.TestCheckResourceAttr("stackit_ske_cluster.cluster_min", "node_pools.0.cri", clusterResource["nodepool_cri"]),
resource.TestCheckNoResourceAttr("stackit_ske_cluster.cluster_min", "extensions"),
resource.TestCheckNoResourceAttr("stackit_ske_cluster.cluster_min", "hibernations"),
resource.TestCheckResourceAttrSet("stackit_ske_cluster.cluster_min", "maintenance.enable_kubernetes_version_updates"),
resource.TestCheckResourceAttrSet("stackit_ske_cluster.cluster_min", "maintenance.enable_machine_image_version_updates"),
resource.TestCheckResourceAttrSet("stackit_ske_cluster.cluster_min", "maintenance.start"),
resource.TestCheckResourceAttrSet("stackit_ske_cluster.cluster_min", "maintenance.end"),
),
},
// 2) Data source
{
Config: fmt.Sprintf(`
%s
data "stackit_ske_cluster" "cluster" {
project_id = "%s"
name = "%s"
depends_on = [stackit_ske_cluster.cluster]
}
%s
data "stackit_ske_cluster" "cluster_min" {
project_id = "%s"
name = "%s"
depends_on = [stackit_ske_cluster.cluster_min]
}
data "stackit_ske_cluster" "cluster" {
project_id = "%s"
name = "%s"
depends_on = [stackit_ske_cluster.cluster]
}
`,
`,
getConfig(clusterResource["kubernetes_version_min"], clusterResource["nodepool_os_version_min"], nil),
clusterResource["project_id"],
clusterResource["name"],
clusterResource["project_id"],
clusterResource["name_min"],
),
Check: resource.ComposeAggregateTestCheckFunc(
// cluster data
resource.TestCheckResourceAttr("data.stackit_ske_cluster.cluster", "id", fmt.Sprintf("%s,%s",
clusterResource["project_id"],
@ -358,31 +321,6 @@ func TestAccSKE(t *testing.T) {
resource.TestCheckResourceAttr("data.stackit_ske_cluster.cluster", "maintenance.enable_machine_image_version_updates", clusterResource["maintenance_enable_machine_image_version_updates"]),
resource.TestCheckResourceAttr("data.stackit_ske_cluster.cluster", "maintenance.start", clusterResource["maintenance_start"]),
resource.TestCheckResourceAttr("data.stackit_ske_cluster.cluster", "maintenance.end", clusterResource["maintenance_end"]),
// Minimal cluster
resource.TestCheckResourceAttr("data.stackit_ske_cluster.cluster_min", "name", clusterResource["name_min"]),
resource.TestCheckResourceAttrSet("data.stackit_ske_cluster.cluster_min", "kubernetes_version_used"),
resource.TestCheckNoResourceAttr("data.stackit_ske_cluster.cluster_min", "allow_privileged_containers"),
resource.TestCheckResourceAttr("data.stackit_ske_cluster.cluster_min", "node_pools.0.name", clusterResource["nodepool_name_min"]),
resource.TestCheckResourceAttr("data.stackit_ske_cluster.cluster_min", "node_pools.0.availability_zones.#", "1"),
resource.TestCheckResourceAttr("data.stackit_ske_cluster.cluster_min", "node_pools.0.availability_zones.0", clusterResource["nodepool_zone"]),
resource.TestCheckResourceAttrSet("data.stackit_ske_cluster.cluster_min", "node_pools.0.os_name"),
resource.TestCheckResourceAttr("data.stackit_ske_cluster.cluster_min", "node_pools.0.machine_type", clusterResource["nodepool_machine_type"]),
resource.TestCheckResourceAttr("data.stackit_ske_cluster.cluster_min", "node_pools.0.minimum", clusterResource["nodepool_minimum"]),
resource.TestCheckResourceAttr("data.stackit_ske_cluster.cluster_min", "node_pools.0.maximum", clusterResource["nodepool_maximum"]),
resource.TestCheckResourceAttrSet("data.stackit_ske_cluster.cluster_min", "node_pools.0.max_surge"),
resource.TestCheckResourceAttrSet("data.stackit_ske_cluster.cluster_min", "node_pools.0.max_unavailable"),
resource.TestCheckResourceAttrSet("data.stackit_ske_cluster.cluster_min", "node_pools.0.volume_type"),
resource.TestCheckResourceAttr("data.stackit_ske_cluster.cluster", "node_pools.0.volume_size", clusterResource["nodepool_volume_size"]),
resource.TestCheckResourceAttr("data.stackit_ske_cluster.cluster_min", "node_pools.0.labels.%", "0"),
resource.TestCheckNoResourceAttr("data.stackit_ske_cluster.cluster_min", "node_pools.0.taints"),
resource.TestCheckResourceAttr("data.stackit_ske_cluster.cluster_min", "node_pools.0.cri", clusterResource["nodepool_cri"]),
resource.TestCheckNoResourceAttr("data.stackit_ske_cluster.cluster_min", "extensions"),
resource.TestCheckNoResourceAttr("data.stackit_ske_cluster.cluster_min", "hibernations"),
resource.TestCheckResourceAttrSet("data.stackit_ske_cluster.cluster_min", "maintenance.enable_kubernetes_version_updates"),
resource.TestCheckResourceAttrSet("data.stackit_ske_cluster.cluster_min", "maintenance.enable_machine_image_version_updates"),
resource.TestCheckResourceAttrSet("data.stackit_ske_cluster.cluster_min", "maintenance.start"),
resource.TestCheckResourceAttrSet("data.stackit_ske_cluster.cluster_min", "maintenance.end"),
),
},
// 3) Import cluster
@ -408,29 +346,7 @@ func TestAccSKE(t *testing.T) {
// The fields are not provided in the SKE API when disabled, although set actively.
ImportStateVerifyIgnore: []string{"kubernetes_version_min", "node_pools.0.os_version_min", "extensions.argus.%", "extensions.argus.argus_instance_id", "extensions.argus.enabled", "extensions.acl.enabled", "extensions.acl.allowed_cidrs", "extensions.acl.allowed_cidrs.#", "extensions.acl.%", "extensions.dns.enabled", "extensions.dns.zones", "extensions.dns.zones.#", "extensions.dns.zones.%"},
},
// 4) Import minimal cluster
{
ResourceName: "stackit_ske_cluster.cluster_min",
ImportStateIdFunc: func(s *terraform.State) (string, error) {
r, ok := s.RootModule().Resources["stackit_ske_cluster.cluster_min"]
if !ok {
return "", fmt.Errorf("couldn't find resource stackit_ske_cluster.cluster_min")
}
_, ok = r.Primary.Attributes["project_id"]
if !ok {
return "", fmt.Errorf("couldn't find attribute project_id")
}
name, ok := r.Primary.Attributes["name"]
if !ok {
return "", fmt.Errorf("couldn't find attribute name")
}
return fmt.Sprintf("%s,%s", testutil.ProjectId, name), nil
},
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"kubernetes_version_min", "node_pools.0.os_version_min"},
},
// 5) Update kubernetes version, OS version and maintenance end
// 4) Update kubernetes version, OS version and maintenance end
{
Config: getConfig(clusterResource["kubernetes_version_min_new"], clusterResource["nodepool_os_version_min_new"], utils.Ptr(clusterResource["maintenance_end_new"])),
Check: resource.ComposeAggregateTestCheckFunc(
@ -476,7 +392,7 @@ func TestAccSKE(t *testing.T) {
resource.TestCheckResourceAttr("stackit_ske_cluster.cluster", "maintenance.end", clusterResource["maintenance_end_new"]),
),
},
// 6) Downgrade kubernetes and nodepool machine OS version
// 5) Downgrade kubernetes and nodepool machine OS version
{
Config: getConfig(clusterResource["kubernetes_version_min"], clusterResource["nodepool_os_version_min"], utils.Ptr(clusterResource["maintenance_end_new"])),
Check: resource.ComposeAggregateTestCheckFunc(

View file

@ -35,10 +35,9 @@ var (
Region = os.Getenv("TF_ACC_REGION")
// ServerId is the id of a server used for some tests
ServerId = getenv("TF_ACC_SERVER_ID", "")
// IaaSImageId is the id of an image used for IaaS acceptance tests. Once the stackit_image resource is implemented, we can remove this
IaaSImageId = getenv("TF_ACC_IMAGE_ID", "")
// IaaSNetworkInterfaceId is the id of a network interface used for IaaS acceptance tests. Once acceptance tests are merged, we can remove this
IaaSNetworkInterfaceId = getenv("TF_ACC_NETWORK_INTERFACE_ID", "")
// IaaSImageId is the id of an image used for IaaS acceptance tests.
// Default image is ubuntu 24.04
IaaSImageId = getenv("TF_ACC_IMAGE_ID", "59838a89-51b1-4892-b57f-b3caf598ee2f")
// TestProjectParentContainerID is the container id of the parent resource under which projects are created as part of the resource-manager acceptance tests
TestProjectParentContainerID = os.Getenv("TF_ACC_TEST_PROJECT_PARENT_CONTAINER_ID")
// TestProjectParentContainerID is the uuid of the parent resource under which projects are created as part of the resource-manager acceptance tests
@ -46,7 +45,8 @@ var (
// TestProjectServiceAccountEmail is the e-mail of a service account with admin permissions on the organization under which projects are created as part of the resource-manager acceptance tests
TestProjectServiceAccountEmail = os.Getenv("TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_EMAIL")
// TestProjectUserEmail is the e-mail of a user for the project created as part of the resource-manager acceptance tests
TestProjectUserEmail = os.Getenv("TF_ACC_TEST_PROJECT_USER_EMAIL")
// Default email: acc-test@sa.stackit.cloud
TestProjectUserEmail = getenv("TF_ACC_TEST_PROJECT_USER_EMAIL", "acc-test@sa.stackit.cloud")
// TestImageLocalFilePath is the local path to an image file used for image acceptance tests
TestImageLocalFilePath = os.Getenv("TF_ACC_TEST_IMAGE_LOCAL_FILE_PATH")
@ -144,6 +144,7 @@ func LoadBalancerProviderConfig() string {
return `
provider "stackit" {
region = "eu01"
enable_beta_resources = true
}`
}
return fmt.Sprintf(`