Skip to content

Commit 758bd76

Browse files
spuiukphlogistonjohn
authored andcommitted
integration tests: Use hostname instead of ip for mount path test
Signed-off-by: Sachin Prabhu <[email protected]>
1 parent d1c86d0 commit 758bd76

File tree

1 file changed

+11
-27
lines changed

1 file changed

+11
-27
lines changed

tests/integration/mount_path_test.go

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,6 @@ type MountPathSuite struct {
2828
tc *kube.TestClient
2929
}
3030

31-
func (s *MountPathSuite) getPodIP(labelPattern string) (string, error) {
32-
pods, err := s.tc.FetchPods(
33-
context.TODO(),
34-
kube.PodFetchOptions{
35-
Namespace: testNamespace,
36-
LabelSelector: labelPattern,
37-
MaxFound: 1,
38-
})
39-
if err != nil {
40-
return "", err
41-
}
42-
for _, pod := range pods {
43-
if kube.PodIsReady(&pod) {
44-
return pod.Status.PodIP, nil
45-
}
46-
}
47-
return "", fmt.Errorf("no pods ready when fetching IP")
48-
}
49-
5031
func (s *MountPathSuite) waitForPods(labelPattern string) {
5132
require := s.Require()
5233
ctx, cancel := context.WithDeadline(
@@ -73,17 +54,19 @@ func (s *MountPathSuite) SetupSuite() {
7354
createFromFiles(require, s.tc, append(s.commonSources, s.smbshareSetupSources...))
7455
// ensure the smbserver test pod exists and is ready
7556
s.waitForPods(s.setupServerLabelPattern)
76-
serverIP, err := s.getPodIP(s.setupServerLabelPattern)
77-
require.NoError(err)
57+
58+
svcname := fmt.Sprintf("%s.%s.svc.cluster.local",
59+
s.smbShareSetupResource.Name,
60+
s.smbShareSetupResource.Namespace)
7861
share := smbclient.Share{
79-
Host: smbclient.Host(serverIP),
62+
Host: smbclient.Host(svcname),
8063
Name: s.smbShareSetupResource.Name,
8164
}
8265

8366
// Create folders over smbclient
8467
smbclient := smbclient.MustPodExec(s.tc, testNamespace,
8568
"smbclient", "client")
86-
err = smbclient.CacheFlush(context.TODO())
69+
err := smbclient.CacheFlush(context.TODO())
8770
require.NoError(err)
8871
auth := s.auths[0]
8972
cmds := []string{
@@ -116,17 +99,18 @@ func (s *MountPathSuite) TearDownSuite() {
11699
func (s *MountPathSuite) TestMountPath() {
117100
require := s.Require()
118101

119-
serverIP, err := s.getPodIP(s.serverLabelPattern)
120-
require.NoError(err)
102+
svcname := fmt.Sprintf("%s.%s.svc.cluster.local",
103+
s.smbShareResource.Name,
104+
s.smbShareResource.Namespace)
121105
share := smbclient.Share{
122-
Host: smbclient.Host(serverIP),
106+
Host: smbclient.Host(svcname),
123107
Name: s.smbShareResource.Name,
124108
}
125109

126110
// Test if correct path mounted using smbclient
127111
smbclient := smbclient.MustPodExec(s.tc, testNamespace,
128112
"smbclient", "client")
129-
err = smbclient.CacheFlush(context.TODO())
113+
err := smbclient.CacheFlush(context.TODO())
130114
require.NoError(err)
131115
auth := s.auths[0]
132116
out, err := smbclient.CommandOutput(

0 commit comments

Comments
 (0)