|
4 | 4 | "context" |
5 | 5 | "fmt" |
6 | 6 | "path/filepath" |
| 7 | + "regexp" |
| 8 | + "strings" |
7 | 9 | "sync" |
8 | 10 | "time" |
9 | 11 |
|
@@ -200,25 +202,30 @@ func (s *dockerDaemonSuite) Test_TLSAnnotations() { |
200 | 202 | rq.True(len(si.UserDaemon.Intercepts) == 1) |
201 | 203 | rq.Equal(si.UserDaemon.Intercepts[0].Name, ttSvc) |
202 | 204 |
|
203 | | - args := []string{"curl", "--max-time", "2", "-s", "-w", "\nStatus: %{http_code}\n", "-k"} |
204 | | - if tt.header != "" { |
205 | | - args = append(args, "-H", tt.header) |
206 | | - } |
207 | | - args = append(args, fmt.Sprintf("https://%s", ttSvc)) |
208 | | - so, se, err := itest.Telepresence(ctx, args...) |
209 | | - s.NoError(err) |
210 | | - if se != "" { |
211 | | - clog.Error(ctx, se) |
212 | | - } |
213 | | - if tt.errorPattern != "" { |
214 | | - s.Regexp(tt.errorPattern, so) |
215 | | - } else { |
216 | | - s.Contains(so, "HTTP/2.0 GET /") |
217 | | - } |
218 | | - clog.Info(ctx, so) |
| 205 | + rq.EventuallyContext(ctx, func() bool { |
| 206 | + args := []string{"curl", "--max-time", "2", "-s", "-w", "\nStatus: %{http_code}\n", "-k"} |
| 207 | + if tt.header != "" { |
| 208 | + args = append(args, "-H", tt.header) |
| 209 | + } |
| 210 | + args = append(args, fmt.Sprintf("https://%s", ttSvc)) |
| 211 | + so, se, err := itest.Telepresence(ctx, args...) |
| 212 | + if err != nil { |
| 213 | + if se != "" { |
| 214 | + clog.Error(ctx, se) |
| 215 | + } |
| 216 | + clog.Error(ctx, err) |
| 217 | + return false |
| 218 | + } |
| 219 | + clog.Info(ctx, so) |
| 220 | + if tt.errorPattern != "" { |
| 221 | + ok, err := regexp.MatchString(tt.errorPattern, so) |
| 222 | + return err == nil && ok |
| 223 | + } |
| 224 | + return strings.Contains(so, "HTTP/2.0 GET /") |
| 225 | + }, 10*time.Second, 3*time.Second, "expected curl response never arrived") |
219 | 226 |
|
220 | 227 | // Terminate the ongoing intercept |
221 | | - so, se, err = itest.Telepresence(ctx, "leave", ttSvc) |
| 228 | + so, se, err := itest.Telepresence(ctx, "leave", ttSvc) |
222 | 229 | if so != "" { |
223 | 230 | clog.Info(ctx, so) |
224 | 231 | } |
|
0 commit comments