-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathposture_test.go
More file actions
104 lines (96 loc) · 2.76 KB
/
Copy pathposture_test.go
File metadata and controls
104 lines (96 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package capstan
import (
"testing"
)
func TestPostureDataLoads(t *testing.T) {
if len(posture.GeoRouting) == 0 {
t.Fatal("GeoRouting is empty")
}
if len(posture.TierMap) == 0 {
t.Fatal("TierMap is empty")
}
}
func TestRecommendPlacement_EUCentral(t *testing.T) {
r, err := RecommendPlacement(GeoEUCentral, WorkloadIOMultitenant, SLAStandard)
if err != nil {
t.Fatal(err)
}
if r.Primary.Provider != Hetzner {
t.Errorf("primary provider = %q, want hetzner", r.Primary.Provider)
}
if r.Primary.Region != "fsn1" {
t.Errorf("primary region = %q, want fsn1", r.Primary.Region)
}
if r.Primary.Size != "cx43" {
t.Errorf("primary size = %q, want cx43", r.Primary.Size)
}
if len(r.Fallbacks) < 1 {
t.Error("expected fallbacks")
}
}
func TestRecommendPlacement_USEast(t *testing.T) {
r, err := RecommendPlacement(GeoUSEast, WorkloadIOMultitenant, SLAPremium)
if err != nil {
t.Fatal(err)
}
if r.Primary.Provider != Hetzner {
t.Errorf("primary provider = %q, want hetzner", r.Primary.Provider)
}
if r.Primary.Region != "ash" {
t.Errorf("primary region = %q, want ash", r.Primary.Region)
}
if r.Primary.Size != "ccx33" {
t.Errorf("primary size = %q, want ccx33", r.Primary.Size)
}
if len(r.Caveats) == 0 {
t.Error("expected caveats for hetzner/ash")
}
}
func TestRecommendPlacement_Australia(t *testing.T) {
r, err := RecommendPlacement(GeoAustralia, WorkloadIOMultitenant, SLAStandard)
if err != nil {
t.Fatal(err)
}
if r.Primary.Provider != Linode {
t.Errorf("primary provider = %q, want linode", r.Primary.Provider)
}
if r.Primary.Region != "ap-southeast" {
t.Errorf("primary region = %q, want ap-southeast", r.Primary.Region)
}
if len(r.Caveats) == 0 {
t.Error("expected Sydney caveat")
}
}
func TestRecommendPlacement_Defaults(t *testing.T) {
r, err := RecommendPlacement(GeoJapan, "", "")
if err != nil {
t.Fatal(err)
}
if r.Primary.Size != "g6-standard-4" {
t.Errorf("default workload+sla should give g6-standard-4, got %q", r.Primary.Size)
}
}
func TestRecommendPlacement_InvalidGeo(t *testing.T) {
_, err := RecommendPlacement("antarctica", "", "")
if err == nil {
t.Error("expected error for unknown geography")
}
}
func TestRecommendPlacement_AllGeographies(t *testing.T) {
geos := []Geography{
GeoEUCentral, GeoEUNorth, GeoEUWest, GeoEUSouth,
GeoUSEast, GeoUSCentral, GeoUSWest, GeoCanada,
GeoSingapore, GeoJapan, GeoIndia, GeoIndonesia,
GeoAustralia, GeoLatam,
}
for _, geo := range geos {
r, err := RecommendPlacement(geo, WorkloadGeneral, SLAStandard)
if err != nil {
t.Errorf("RecommendPlacement(%q) failed: %v", geo, err)
continue
}
if r.Primary.Provider == "" || r.Primary.Region == "" || r.Primary.Size == "" {
t.Errorf("RecommendPlacement(%q) returned incomplete placement: %+v", geo, r.Primary)
}
}
}