Skip to content

Commit 5ea4874

Browse files
authored
Merge pull request #140 from kubernetes-sigs/add-invalid-ip-test
e2e: Add test for invalid ip as control plane endpoint
2 parents c3f25a2 + e7ca579 commit 5ea4874

File tree

4 files changed

+34
-4
lines changed

4 files changed

+34
-4
lines changed

test/e2e/config/cloudstack.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ providers:
9494
- sourcePath: "../data/infrastructure-cloudstack/v1beta2/cluster-template-disk-offering.yaml"
9595
- sourcePath: "../data/infrastructure-cloudstack/v1beta2/cluster-template-custom-disk-offering.yaml"
9696
- sourcePath: "../data/infrastructure-cloudstack/v1beta2/cluster-template-subdomain.yaml"
97+
- sourcePath: "../data/infrastructure-cloudstack/v1beta2/cluster-template-invalid-ip.yaml"
9798
- sourcePath: "../data/shared/v1beta1/metadata.yaml"
9899
versions:
99100
- name: v1.0.0
@@ -127,6 +128,7 @@ variables:
127128
CLOUDSTACK_SHARED_NETWORK_NAME: Shared1
128129
CLUSTER_ENDPOINT_IP: 172.16.2.199
129130
CLUSTER_ENDPOINT_IP_2: 172.16.2.198
131+
CLOUDSTACK_INVALID_IP: 1.2.3.4
130132
CLOUDSTACK_CONTROL_PLANE_MACHINE_OFFERING: "Large Instance"
131133
CLOUDSTACK_INVALID_CONTROL_PLANE_MACHINE_OFFERING: "OfferingXXXX"
132134
CLOUDSTACK_IMPOSSIBLE_CONTROL_PLANE_MACHINE_OFFERING: "Impossible Instance"
@@ -169,4 +171,4 @@ intervals:
169171
node-drain/wait-control-plane: ["15m", "10s"]
170172
node-drain/wait-machine-deleted: ["5m", "10s"]
171173

172-
174+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
2+
kind: CloudStackCluster
3+
metadata:
4+
name: ${CLUSTER_NAME}
5+
spec:
6+
failureDomains:
7+
- name: ${CLOUDSTACK_FD1_NAME}
8+
acsEndpoint:
9+
name: ${CLOUDSTACK_FD1_SECRET_NAME}
10+
namespace: default
11+
zone:
12+
name: ${CLOUDSTACK_ZONE_NAME}
13+
network:
14+
name: ${CLOUDSTACK_NETWORK_NAME}
15+
controlPlaneEndpoint:
16+
host: ${CLOUDSTACK_INVALID_IP}
17+
port: 6443
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
bases:
2+
- ../bases/cluster-with-kcp.yaml
3+
- ../bases/md.yaml
4+
5+
patchesStrategicMerge:
6+
- ./cloudstack-cluster.yaml

test/e2e/invalid_resource.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,19 @@ import (
2020
"context"
2121
"errors"
2222
"fmt"
23+
"os"
24+
"path/filepath"
25+
"strings"
26+
2327
. "github.com/onsi/ginkgo"
2428
. "github.com/onsi/gomega"
2529
corev1 "k8s.io/api/core/v1"
2630
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2731
"k8s.io/utils/pointer"
28-
"os"
29-
"path/filepath"
3032
"sigs.k8s.io/cluster-api/api/v1beta1"
3133
controlplanev1 "sigs.k8s.io/cluster-api/controlplane/kubeadm/api/v1beta1"
3234
"sigs.k8s.io/cluster-api/util/patch"
3335
"sigs.k8s.io/controller-runtime/pkg/client"
34-
"strings"
3536

3637
"sigs.k8s.io/cluster-api/test/framework"
3738
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
@@ -99,6 +100,10 @@ func InvalidResourceSpec(ctx context.Context, inputGetter func() CommonSpecInput
99100
testInvalidResource(ctx, input, "invalid-disk-offering-size-for-customized", "is customized, disk size can not be 0 GB")
100101
})
101102

103+
It("Should fail due to the public IP can not be found", func() {
104+
testInvalidResource(ctx, input, "invalid-ip", "no public addresses found in available networks")
105+
})
106+
102107
Context("When starting with a healthy cluster", func() {
103108
var logFolder string
104109

0 commit comments

Comments
 (0)