|
| 1 | +// Copyright Jetstack Ltd. See LICENSE for details. |
| 2 | +package e2e_test |
| 3 | + |
| 4 | +import ( |
| 5 | + "fmt" |
| 6 | + "os" |
| 7 | + "testing" |
| 8 | +) |
| 9 | + |
| 10 | +func TestAWSSingleCluster(t *testing.T) { |
| 11 | + t.Parallel() |
| 12 | + skipE2ETests(t) |
| 13 | + |
| 14 | + ti := NewTarmakInstance(t) |
| 15 | + ti.singleCluster = true |
| 16 | + ti.singleZone = true |
| 17 | + |
| 18 | + t.Log("initialise config for single cluster") |
| 19 | + if err := ti.Init(); err != nil { |
| 20 | + t.Errorf("unexpected error: %+v", err) |
| 21 | + } |
| 22 | + |
| 23 | + t.Log("build tarmak image") |
| 24 | + c := ti.Command("cluster", "image", "build") |
| 25 | + c.Stderr = os.Stderr |
| 26 | + if err := c.Run(); err != nil { |
| 27 | + t.Errorf("unexpected error: %+v", err) |
| 28 | + } |
| 29 | + |
| 30 | + defer func() { |
| 31 | + t.Log("run cluster destroy command") |
| 32 | + c = ti.Command("cluster", "destroy") |
| 33 | + // write error out to my stdout |
| 34 | + c.Stderr = os.Stderr |
| 35 | + if err := c.Run(); err != nil { |
| 36 | + t.Errorf("unexpected error: %+v", err) |
| 37 | + } |
| 38 | + }() |
| 39 | + t.Log("run cluster apply command") |
| 40 | + c = ti.Command("cluster", "apply") |
| 41 | + // write error out to my stdout |
| 42 | + c.Stderr = os.Stderr |
| 43 | + if err := c.Run(); err != nil { |
| 44 | + t.Fatalf("unexpected error: %+v", err) |
| 45 | + } |
| 46 | + |
| 47 | + t.Log("get component status") |
| 48 | + c = ti.Command("cluster", "kubectl", "get", "cs", "-o", "yaml") |
| 49 | + // write error out to my stdout |
| 50 | + c.Stderr = os.Stderr |
| 51 | + c.Stdout = os.Stdout |
| 52 | + if err := c.Run(); err != nil { |
| 53 | + t.Fatalf("unexpected error: %+v", err) |
| 54 | + } |
| 55 | +} |
| 56 | + |
| 57 | +func TestAWSMultiCluster(t *testing.T) { |
| 58 | + t.Parallel() |
| 59 | + skipE2ETests(t) |
| 60 | + |
| 61 | + ti := NewTarmakInstance(t) |
| 62 | + ti.singleCluster = false |
| 63 | + ti.singleZone = false |
| 64 | + |
| 65 | + t.Log("initialise config for single cluster") |
| 66 | + if err := ti.Init(); err != nil { |
| 67 | + t.Fatalf("unexpected error: %+v", err) |
| 68 | + } |
| 69 | + |
| 70 | + t.Log("build tarmak image") |
| 71 | + c := ti.Command("cluster", "image", "build") |
| 72 | + c.Stderr = os.Stderr |
| 73 | + if err := c.Run(); err != nil { |
| 74 | + t.Fatalf("unexpected error: %+v", err) |
| 75 | + } |
| 76 | + |
| 77 | + defer func() { |
| 78 | + t.Log("run hub destroy command") |
| 79 | + c = ti.Command("--current-cluster", fmt.Sprintf("%s-hub", ti.environmentName), "cluster", "destroy") |
| 80 | + // write error out to my stdout |
| 81 | + c.Stderr = os.Stderr |
| 82 | + if err := c.Run(); err != nil { |
| 83 | + t.Errorf("unexpected error: %+v", err) |
| 84 | + } |
| 85 | + }() |
| 86 | + t.Log("run hub apply command") |
| 87 | + c = ti.Command("--current-cluster", fmt.Sprintf("%s-hub", ti.environmentName), "cluster", "apply") |
| 88 | + // write error out to my stdout |
| 89 | + c.Stderr = os.Stderr |
| 90 | + if err := c.Run(); err != nil { |
| 91 | + t.Fatalf("unexpected error: %+v", err) |
| 92 | + } |
| 93 | + |
| 94 | + defer func() { |
| 95 | + t.Log("run cluster destroy command") |
| 96 | + c = ti.Command("cluster", "destroy") |
| 97 | + // write error out to my stdout |
| 98 | + c.Stderr = os.Stderr |
| 99 | + if err := c.Run(); err != nil { |
| 100 | + t.Errorf("unexpected error: %+v", err) |
| 101 | + } |
| 102 | + }() |
| 103 | + t.Log("run cluster apply command") |
| 104 | + c = ti.Command("cluster", "apply") |
| 105 | + // write error out to my stdout |
| 106 | + c.Stderr = os.Stderr |
| 107 | + if err := c.Run(); err != nil { |
| 108 | + t.Fatalf("unexpected error: %+v", err) |
| 109 | + } |
| 110 | + |
| 111 | + t.Log("get component status") |
| 112 | + c = ti.Command("cluster", "kubectl", "get", "cs", "-o", "yaml") |
| 113 | + // write error out to my stdout |
| 114 | + c.Stderr = os.Stderr |
| 115 | + c.Stdout = os.Stdout |
| 116 | + if err := c.Run(); err != nil { |
| 117 | + t.Fatalf("unexpected error: %+v", err) |
| 118 | + } |
| 119 | + |
| 120 | +} |
0 commit comments