Skip to content

Commit 673de0d

Browse files
authored
Fix EKS acceptance tests (#1678)
1 parent 36ea64b commit 673de0d

File tree

5 files changed

+28
-4
lines changed

5 files changed

+28
-4
lines changed

GNUmakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ testacc: fmtcheck vet
6262
mkdir -p /tmp/.terraform.d/localhost/test/kubernetes/9.9.9/$(OS_ARCH) || true
6363
ls $(EXT_PROV_BIN) || go build -o $(EXT_PROV_BIN)
6464
cd $(EXT_PROV_DIR) && TF_CLI_CONFIG_FILE=$(EXT_PROV_DIR)/.terraformrc TF_PLUGIN_CACHE_DIR=$(EXT_PROV_DIR)/.terraform terraform init -upgrade
65-
TF_CLI_CONFIG_FILE=$(EXT_PROV_DIR)/.terraformrc TF_PLUGIN_CACHE_DIR=$(EXT_PROV_DIR)/.terraform TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m
65+
TF_CLI_CONFIG_FILE=$(EXT_PROV_DIR)/.terraformrc TF_PLUGIN_CACHE_DIR=$(EXT_PROV_DIR)/.terraform TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 3h
6666

6767
test-compile:
6868
@if [ "$(TEST)" = "./..." ]; then \

kubernetes/resource_kubernetes_pod_test.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ func TestAccKubernetesPod_with_cfg_map_volume_mount(t *testing.T) {
637637
})
638638
}
639639

640-
func TestAccKubernetesPod_with_csi_volume(t *testing.T) {
640+
func TestAccKubernetesPod_with_csi_volume_hostpath(t *testing.T) {
641641
var conf api.Pod
642642

643643
podName := acctest.RandomWithPrefix("tf-acc-test")
@@ -646,7 +646,12 @@ func TestAccKubernetesPod_with_csi_volume(t *testing.T) {
646646
imageName := "busybox:1.32"
647647

648648
resource.Test(t, resource.TestCase{
649-
PreCheck: func() { testAccPreCheck(t) },
649+
PreCheck: func() {
650+
testAccPreCheck(t)
651+
if err := testAccCheckCSIDriverExists("hostpath.csi.k8s.io"); err != nil {
652+
t.Skip(err.Error())
653+
}
654+
},
650655
ProviderFactories: testAccProviderFactories,
651656
CheckDestroy: testAccCheckKubernetesPodDestroy,
652657
Steps: []resource.TestStep{
@@ -1265,6 +1270,19 @@ func TestAccKubernetesPod_topologySpreadConstraint(t *testing.T) {
12651270
})
12661271
}
12671272

1273+
func testAccCheckCSIDriverExists(csiDriverName string) error {
1274+
conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset()
1275+
if err != nil {
1276+
return err
1277+
}
1278+
ctx := context.Background()
1279+
_, err = conn.StorageV1().CSIDrivers().Get(ctx, csiDriverName, metav1.GetOptions{})
1280+
if err != nil {
1281+
return fmt.Errorf("could not find CSIDriver %q", csiDriverName)
1282+
}
1283+
return nil
1284+
}
1285+
12681286
func testAccCheckKubernetesPodDestroy(s *terraform.State) error {
12691287
conn, err := testAccProvider.Meta().(KubeClientsets).MainClientset()
12701288

kubernetes/resource_kubernetes_service_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func TestAccKubernetesService_loadBalancer(t *testing.T) {
155155
resource.TestCheckResourceAttr(resourceName, "spec.0.selector.%", "1"),
156156
resource.TestCheckResourceAttr(resourceName, "spec.0.selector.App", "MyApp"),
157157
resource.TestCheckResourceAttr(resourceName, "spec.0.type", "LoadBalancer"),
158-
resource.TestCheckResourceAttrSet(resourceName, "status.0.load_balancer.0.ingress.0.ip"),
158+
resource.TestCheckResourceAttrSet(resourceName, "status.0.load_balancer.0.ingress.0.hostname"),
159159
testAccCheckServicePorts(&conf, []api.ServicePort{
160160
{
161161
Port: int32(8888),

kubernetes/structures.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,11 @@ func isInternalKey(annotationKey string) bool {
175175
return false
176176
}
177177

178+
// allow AWS load balancer configuration annotations
179+
if u.Hostname() == "service.beta.kubernetes.io" {
180+
return false
181+
}
182+
178183
// internal *.kubernetes.io keys
179184
if strings.HasSuffix(u.Hostname(), "kubernetes.io") {
180185
return true

kubernetes/structures_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ func TestIsInternalKey(t *testing.T) {
1414
{"anyKey", false},
1515
{"any.hostname.io", false},
1616
{"any.hostname.com/with/path", false},
17+
{"service.beta.kubernetes.io/aws-load-balancer-backend-protocol", false},
1718
{"app.kubernetes.io", false},
1819
{"kubernetes.io", true},
1920
{"kubectl.kubernetes.io", true},

0 commit comments

Comments
 (0)