Skip to content

Commit

Permalink
fix(instance_image): removed state "stopped" in tests involving serve…
Browse files Browse the repository at this point in the history
…rs to try to fix nightly tests (#1374)
  • Loading branch information
Mia-Cross committed Jul 18, 2022
1 parent d998d65 commit 8dbe972
Show file tree
Hide file tree
Showing 5 changed files with 6,767 additions and 3,424 deletions.
70 changes: 66 additions & 4 deletions scaleway/resource_instance_image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ func TestAccScalewayInstanceImage_Server(t *testing.T) {
resource "scaleway_instance_server" "main" {
image = "ubuntu_focal"
type = "DEV1-S"
state = "stopped"
}
resource "scaleway_instance_snapshot" "main" {
Expand Down Expand Up @@ -152,7 +151,6 @@ func TestAccScalewayInstanceImage_Server(t *testing.T) {
resource "scaleway_instance_server" "main" {
image = "ubuntu_focal"
type = "DEV1-S"
state = "stopped"
}
resource "scaleway_instance_snapshot" "main" {
Expand Down Expand Up @@ -208,7 +206,6 @@ func TestAccScalewayInstanceImage_ServerWithBlockVolume(t *testing.T) {
resource "scaleway_instance_server" "server" {
image = "ubuntu_focal"
type = "DEV1-S"
state = "stopped"
}
resource "scaleway_instance_snapshot" "server" {
volume_id = scaleway_instance_server.server.root_volume.0.volume_id
Expand Down Expand Up @@ -264,7 +261,6 @@ func TestAccScalewayInstanceImage_ServerWithBlockVolume(t *testing.T) {
resource "scaleway_instance_server" "server" {
image = "ubuntu_focal"
type = "DEV1-S"
state = "stopped"
}
resource "scaleway_instance_snapshot" "server" {
volume_id = scaleway_instance_server.server.root_volume.0.volume_id
Expand Down Expand Up @@ -303,6 +299,72 @@ func TestAccScalewayInstanceImage_ServerWithBlockVolume(t *testing.T) {
})
}

func TestAccScalewayInstanceImage_ServerWithLocalVolume(t *testing.T) {
tt := NewTestTools(t)
defer tt.Cleanup()
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: tt.ProviderFactories,
CheckDestroy: resource.ComposeTestCheckFunc(
testAccCheckScalewayInstanceImageDestroy(tt),
testAccCheckScalewayInstanceSnapshotDestroy(tt),
testAccCheckScalewayInstanceVolumeDestroy(tt),
testAccCheckScalewayInstanceServerDestroy(tt),
),
Steps: []resource.TestStep{
{
Config: `
resource "scaleway_instance_server" "server01" {
image = "ubuntu_focal"
type = "DEV1-S"
root_volume {
size_in_gb = 15
volume_type = "l_ssd"
}
}
resource "scaleway_instance_server" "server02" {
image = "ubuntu_focal"
type = "DEV1-S"
root_volume {
size_in_gb = 10
volume_type = "l_ssd"
}
}
resource "scaleway_instance_snapshot" "local01" {
volume_id = scaleway_instance_server.server01.root_volume.0.volume_id
depends_on = [ scaleway_instance_server.server01 ]
}
resource "scaleway_instance_snapshot" "local02" {
volume_id = scaleway_instance_server.server02.root_volume.0.volume_id
depends_on = [ scaleway_instance_server.server02 ]
}
resource "scaleway_instance_image" "main" {
root_volume_id = scaleway_instance_snapshot.local01.id
additional_volume_ids = [ scaleway_instance_snapshot.local02.id ]
depends_on = [
scaleway_instance_snapshot.local01,
scaleway_instance_snapshot.local02,
]
}
`,
Check: resource.ComposeTestCheckFunc(
testAccCheckScalewayInstanceServerExists(tt, "scaleway_instance_server.server01"),
testAccCheckScalewayInstanceServerExists(tt, "scaleway_instance_server.server02"),
testAccCheckScalewayInstanceSnapShotExists(tt, "scaleway_instance_snapshot.local01"),
testAccCheckScalewayInstanceSnapShotExists(tt, "scaleway_instance_snapshot.local02"),
testAccCheckScalewayInstanceImageExists(tt, "scaleway_instance_image.main"),
resource.TestCheckResourceAttrPair("scaleway_instance_image.main", "root_volume_id", "scaleway_instance_snapshot.local01", "id"),
resource.TestCheckResourceAttrPair("scaleway_instance_image.main", "additional_volumes.0.id", "scaleway_instance_snapshot.local02", "id"),
resource.TestCheckResourceAttr("scaleway_instance_image.main", "additional_volumes.0.volume_type", "l_ssd"),
resource.TestCheckResourceAttr("scaleway_instance_image.main", "additional_volumes.0.size", "10000000000"),
),
},
},
})
}

func testAccCheckScalewayInstanceImageExists(tt *TestTools, n string) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
Expand Down

0 comments on commit 8dbe972

Please sign in to comment.