Skip to content

Commit 2b1dbff

Browse files
Vsan stretch tests to run on isolated setup
1 parent 954203f commit 2b1dbff

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

tests/e2e/vsan_stretched_cluster.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ var _ = ginkgo.Describe("[vsan-stretch-vanilla] vsan stretched cluster tests", f
128128
ginkgo.Skip(envStoragePolicyNameWithThickProvision + " env variable not set")
129129
}
130130
sc, err := client.StorageV1().StorageClasses().Get(ctx, defaultNginxStorageClassName, metav1.GetOptions{})
131-
framework.Logf("Storageclass is %v and err is %v", sc, err)
132-
if (!strings.Contains(err.Error(), "not found")) && sc != nil {
131+
if err != nil && (!strings.Contains(err.Error(), "not found")) && sc != nil {
133132
framework.ExpectNoError(client.StorageV1().StorageClasses().Delete(ctx, defaultNginxStorageClassName,
134133
*metav1.NewDeleteOptions(0)), "Unable to delete storage class "+defaultNginxStorageClassName)
135134
}

tests/e2e/vsan_stretched_cluster_utils.go

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,19 +220,44 @@ func createFaultDomainMap(ctx context.Context, vs *vSphere) map[string]string {
220220
return fdMap
221221
}
222222

223+
func isSSHReachable(ip string, timeout time.Duration) error {
224+
nimbusGeneratedK8sVmPwd := GetAndExpectStringEnvVar(nimbusK8sVmPwd)
225+
sshClientConfig := &ssh.ClientConfig{
226+
User: "root",
227+
Auth: []ssh.AuthMethod{
228+
ssh.Password(nimbusGeneratedK8sVmPwd),
229+
},
230+
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
231+
}
232+
// Read hosts sshd port number
233+
ip, portNum, err := getPortNumAndIP(ip)
234+
gomega.Expect(err).NotTo(gomega.HaveOccurred())
235+
addr := ip + ":" + portNum
236+
_, err = ssh.Dial("tcp", addr, sshClientConfig)
237+
if err != nil {
238+
if strings.Contains(err.Error(), "connection reset by peer") ||
239+
strings.Contains(err.Error(), "no route to host") ||
240+
strings.Contains(err.Error(), "handshake failed") {
241+
return err // unreachable
242+
}
243+
}
244+
return nil
245+
}
246+
223247
// waitForHostToBeDown wait for host to be down
224248
func waitForHostToBeDown(ctx context.Context, ip string) error {
225249
framework.Logf("checking host status of %s", ip)
226250
gomega.Expect(ip).NotTo(gomega.BeNil())
227251
gomega.Expect(ip).NotTo(gomega.BeEmpty())
228-
// Read hosts sshd port number
252+
/* Read hosts sshd port number
229253
ip, portNum, err := getPortNumAndIP(ip)
230254
gomega.Expect(err).NotTo(gomega.HaveOccurred())
231-
addr := ip + ":" + portNum
255+
addr := ip + ":" + portNum*/
232256

233257
waitErr := wait.PollUntilContextTimeout(ctx, poll*2, pollTimeoutShort*2, true,
234258
func(ctx context.Context) (bool, error) {
235-
_, err := net.DialTimeout("tcp", addr, poll)
259+
//_, err := net.DialTimeout("tcp", addr, poll)
260+
err := isSSHReachable(ip, poll)
236261
if err == nil {
237262
framework.Logf("host is reachable")
238263
return false, nil

0 commit comments

Comments
 (0)