Skip to content

Commit

Permalink
add testing variables
Browse files Browse the repository at this point in the history
  • Loading branch information
phm07 committed Sep 18, 2024
1 parent dd0123c commit 5e0ba18
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 13 deletions.
4 changes: 2 additions & 2 deletions e2e_test/combined_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//go:build e2e

package e2e_test
package e2e

import (
"fmt"
Expand All @@ -13,7 +13,7 @@ import (

func TestCombined(t *testing.T) {
// combined tests combine multiple resources and can thus not be run in parallel
serverID := createServer(t, "test-server", "cpx11", "ubuntu-24.04")
serverID := createServer(t, "test-server", TestServerType, TestImage)

firewallID, err := createFirewall(t, "test-firewall")
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion e2e_test/datacenter_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//go:build e2e

package e2e_test
package e2e

import (
"encoding/json"
Expand Down
2 changes: 1 addition & 1 deletion e2e_test/e2e_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//go:build e2e

package e2e_test
package e2e

import (
"bytes"
Expand Down
2 changes: 1 addition & 1 deletion e2e_test/firewall_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//go:build e2e

package e2e_test
package e2e

import (
"fmt"
Expand Down
10 changes: 5 additions & 5 deletions e2e_test/floatingip_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//go:build e2e

package e2e_test
package e2e

import (
"fmt"
Expand All @@ -26,7 +26,7 @@ func TestFloatingIP(t *testing.T) {
_, err = createFloatingIP(t, "ipv4", "--server", "non-existing-server")
require.EqualError(t, err, "server not found: non-existing-server")

floatingIPId, err := createFloatingIP(t, "ipv4", "--home-location", "fsn1")
floatingIPId, err := createFloatingIP(t, "ipv4", "--home-location", TestLocationName)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -135,7 +135,7 @@ $`, out)
],
"home_location": {
"id": 1,
"name": "fsn1",
"name": "%s",
"description": "Falkenstein DC Park 1",
"country": "DE",
"city": "Falkenstein",
Expand All @@ -153,7 +153,7 @@ $`, out)
"name": "new-test-floating-ip"
}
]
`, floatingIPId, ipStr, ipStr)), []byte(out))
`, floatingIPId, ipStr, ipStr, TestLocationName)), []byte(out))

out, err = runCommand(t, "floating-ip", "delete", strconv.Itoa(floatingIPId))
assert.Regexp(t, `^Floating IP deletion is protected \(protected, [0-9a-f]+\)$`, err.Error())
Expand Down Expand Up @@ -183,7 +183,7 @@ $`, out)
require.NoError(t, err)
assert.Equal(t, fmt.Sprintf("Floating IP %d deleted\n", floatingIPId), out)

floatingIPId, err = createFloatingIP(t, "ipv6", "--home-location", "fsn1")
floatingIPId, err = createFloatingIP(t, "ipv6", "--home-location", TestLocationName)
if err != nil {
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion e2e_test/network_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//go:build e2e

package e2e_test
package e2e

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion e2e_test/placement_group_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//go:build e2e

package e2e_test
package e2e

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion e2e_test/server_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//go:build e2e

package e2e_test
package e2e

import (
"strconv"
Expand Down
42 changes: 42 additions & 0 deletions e2e_test/variables.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//go:build e2e

package e2e

import (
"os"

"github.com/hetznercloud/hcloud-go/v2/hcloud"
)

var (
// TestImage is the system image that is used in end-to-end tests.
TestImage = getEnv("TEST_IMAGE", "ubuntu-24.04")

// TestImageID is the system image ID that is used in end-to-end tests.
TestImageID = getEnv("TEST_IMAGE_ID", "161547269")

// TestServerType is the default server type used in end-to-end tests.
TestServerType = getEnv("TEST_SERVER_TYPE", "cpx11")

// TestServerTypeUpgrade is the upgrade server type used in end-to-end tests.
TestServerTypeUpgrade = getEnv("TEST_SERVER_TYPE_UPGRADE", "cpx21")

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

// TestLoadBalancerType is the default Load Balancer type used in end-to-end tests.
TestLoadBalancerType = "lb11"

// TestDataCenter is the default datacenter where we execute our end-to-end tests.
TestDataCenter = getEnv("TEST_DATACENTER", "nbg1-dc3")

// TestLocationName is the default location where we execute our end-to-end tests.
TestLocationName = getEnv("TEST_LOCATION", "nbg1")
)

func getEnv(key, fallback string) string {
if value, ok := os.LookupEnv(key); ok {
return value
}
return fallback
}

0 comments on commit 5e0ba18

Please sign in to comment.