@@ -28,25 +28,6 @@ type MountPathSuite struct {
28
28
tc * kube.TestClient
29
29
}
30
30
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
-
50
31
func (s * MountPathSuite ) waitForPods (labelPattern string ) {
51
32
require := s .Require ()
52
33
ctx , cancel := context .WithDeadline (
@@ -73,17 +54,19 @@ func (s *MountPathSuite) SetupSuite() {
73
54
createFromFiles (require , s .tc , append (s .commonSources , s .smbshareSetupSources ... ))
74
55
// ensure the smbserver test pod exists and is ready
75
56
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 )
78
61
share := smbclient.Share {
79
- Host : smbclient .Host (serverIP ),
62
+ Host : smbclient .Host (svcname ),
80
63
Name : s .smbShareSetupResource .Name ,
81
64
}
82
65
83
66
// Create folders over smbclient
84
67
smbclient := smbclient .MustPodExec (s .tc , testNamespace ,
85
68
"smbclient" , "client" )
86
- err = smbclient .CacheFlush (context .TODO ())
69
+ err : = smbclient .CacheFlush (context .TODO ())
87
70
require .NoError (err )
88
71
auth := s .auths [0 ]
89
72
cmds := []string {
@@ -116,17 +99,18 @@ func (s *MountPathSuite) TearDownSuite() {
116
99
func (s * MountPathSuite ) TestMountPath () {
117
100
require := s .Require ()
118
101
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 )
121
105
share := smbclient.Share {
122
- Host : smbclient .Host (serverIP ),
106
+ Host : smbclient .Host (svcname ),
123
107
Name : s .smbShareResource .Name ,
124
108
}
125
109
126
110
// Test if correct path mounted using smbclient
127
111
smbclient := smbclient .MustPodExec (s .tc , testNamespace ,
128
112
"smbclient" , "client" )
129
- err = smbclient .CacheFlush (context .TODO ())
113
+ err : = smbclient .CacheFlush (context .TODO ())
130
114
require .NoError (err )
131
115
auth := s .auths [0 ]
132
116
out , err := smbclient .CommandOutput (
0 commit comments