Skip to content

Commit

Permalink
test(server): missing ssh keys prevents updating/resizing the server (#…
Browse files Browse the repository at this point in the history
…916)

Adding or removing ssh keys will force deleting the server and creating
a new one, instead of updating the same server.

Co-authored-by: Julian Tölle <[email protected]>
  • Loading branch information
jooola and apricote authored Apr 18, 2024
1 parent 842c9cc commit a8c5cee
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
18 changes: 11 additions & 7 deletions internal/server/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,13 @@ func TestServerResource_Resize(t *testing.T) {
SSHKeys: []string{sk.TFID() + ".id"},
}
res.SetRName("server-resize")
resResized := &server.RData{Name: res.Name, Type: "cx21", Image: res.Image, KeepDisk: true}
resResized := &server.RData{
Name: res.Name,
Type: teste2e.TestServerTypeUpgrade,
KeepDisk: true,
Image: res.Image,
SSHKeys: res.SSHKeys,
}
resResized.SetRName(res.Name)
tmplMan := testtemplate.Manager{}
resource.ParallelTest(t, resource.TestCase{
Expand All @@ -152,24 +158,22 @@ func TestServerResource_Resize(t *testing.T) {
),
Check: resource.ComposeTestCheckFunc(
testsupport.CheckResourceExists(res.TFID(), server.ByID(t, &s)),
resource.TestCheckResourceAttr(res.TFID(), "name",
fmt.Sprintf("server-resize--%d", tmplMan.RandInt)),
resource.TestCheckResourceAttr(res.TFID(), "name", fmt.Sprintf("server-resize--%d", tmplMan.RandInt)),
resource.TestCheckResourceAttr(res.TFID(), "server_type", res.Type),
resource.TestCheckResourceAttr(res.TFID(), "image", res.Image),
),
},
{
// Update the Server created in the previous step by
// setting all optional fields and renaming the Server.
// setting all optional fields.
Config: tmplMan.Render(t,
"testdata/r/hcloud_ssh_key", sk,
"testdata/r/hcloud_server", resResized,
),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr(resResized.TFID(), "name",
fmt.Sprintf("server-resize--%d", tmplMan.RandInt)),
resource.TestCheckResourceAttr(resResized.TFID(), "name", fmt.Sprintf("server-resize--%d", tmplMan.RandInt)),
resource.TestCheckResourceAttr(resResized.TFID(), "server_type", resResized.Type),
resource.TestCheckResourceAttr(resResized.TFID(), "image", res.Image),
resource.TestCheckResourceAttr(resResized.TFID(), "image", resResized.Image),
),
},
},
Expand Down
3 changes: 3 additions & 0 deletions internal/teste2e/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ var (
// TestServerType is the default server type used in all tests
TestServerType = getEnv("TEST_SERVER_TYPE", "cx11")

// TestServerTypeUpgrade is the upgrade server type used in all tests
TestServerTypeUpgrade = getEnv("TEST_SERVER_TYPE_UPGRADE", "cx21")

// TestArchitecture is the default architecture used in all tests, should match the architecture of the TestServerType.
TestArchitecture = getEnv("TEST_ARCHITECTURE", string(hcloud.ArchitectureX86))

Expand Down

0 comments on commit a8c5cee

Please sign in to comment.