@@ -120,6 +120,7 @@ func setupProxyTest(t *testing.T, customAppHost ...string) (*codersdk.Client, co
120
120
},
121
121
},
122
122
})
123
+
123
124
user := coderdtest .CreateFirstUser (t , client )
124
125
125
126
workspace := createWorkspaceWithApps (t , client , user .OrganizationID , appHost , uint16 (tcpAddr .Port ))
@@ -243,7 +244,7 @@ func TestWorkspaceAppsProxyPath(t *testing.T) {
243
244
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
244
245
defer cancel ()
245
246
246
- resp , err := client . Request (ctx , http .MethodGet , fmt .Sprintf ("/@me/%s/apps/%s" , workspace .Name , proxyTestAppNameOwner ), nil )
247
+ resp , err := requestWithRetries (ctx , t , client , http .MethodGet , fmt .Sprintf ("/@me/%s/apps/%s" , workspace .Name , proxyTestAppNameOwner ), nil )
247
248
require .NoError (t , err )
248
249
defer resp .Body .Close ()
249
250
@@ -264,7 +265,7 @@ func TestWorkspaceAppsProxyPath(t *testing.T) {
264
265
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
265
266
defer cancel ()
266
267
267
- resp , err := userClient . Request (ctx , http .MethodGet , fmt .Sprintf ("/@me/%s/apps/%s" , workspace .Name , proxyTestAppNameOwner ), nil )
268
+ resp , err := requestWithRetries (ctx , t , userClient , http .MethodGet , fmt .Sprintf ("/@me/%s/apps/%s" , workspace .Name , proxyTestAppNameOwner ), nil )
268
269
require .NoError (t , err )
269
270
defer resp .Body .Close ()
270
271
require .Equal (t , http .StatusNotFound , resp .StatusCode )
@@ -276,7 +277,7 @@ func TestWorkspaceAppsProxyPath(t *testing.T) {
276
277
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
277
278
defer cancel ()
278
279
279
- resp , err := client . Request (ctx , http .MethodGet , fmt .Sprintf ("/@me/%s/apps/%s" , workspace .Name , proxyTestAppNameOwner ), nil )
280
+ resp , err := requestWithRetries (ctx , t , client , http .MethodGet , fmt .Sprintf ("/@me/%s/apps/%s" , workspace .Name , proxyTestAppNameOwner ), nil )
280
281
require .NoError (t , err )
281
282
defer resp .Body .Close ()
282
283
require .Equal (t , http .StatusTemporaryRedirect , resp .StatusCode )
@@ -288,7 +289,7 @@ func TestWorkspaceAppsProxyPath(t *testing.T) {
288
289
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
289
290
defer cancel ()
290
291
291
- resp , err := client . Request (ctx , http .MethodGet , fmt .Sprintf ("/@me/%s/apps/%s/" , workspace .Name , proxyTestAppNameOwner ), nil )
292
+ resp , err := requestWithRetries (ctx , t , client , http .MethodGet , fmt .Sprintf ("/@me/%s/apps/%s/" , workspace .Name , proxyTestAppNameOwner ), nil )
292
293
require .NoError (t , err )
293
294
defer resp .Body .Close ()
294
295
require .Equal (t , http .StatusTemporaryRedirect , resp .StatusCode )
@@ -303,7 +304,7 @@ func TestWorkspaceAppsProxyPath(t *testing.T) {
303
304
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
304
305
defer cancel ()
305
306
306
- resp , err := client . Request (ctx , http .MethodGet , fmt .Sprintf ("/@me/%s/apps/%s/?%s" , workspace .Name , proxyTestAppNameOwner , proxyTestAppQuery ), nil )
307
+ resp , err := requestWithRetries (ctx , t , client , http .MethodGet , fmt .Sprintf ("/@me/%s/apps/%s/?%s" , workspace .Name , proxyTestAppNameOwner , proxyTestAppQuery ), nil )
307
308
require .NoError (t , err )
308
309
defer resp .Body .Close ()
309
310
body , err := io .ReadAll (resp .Body )
@@ -318,7 +319,7 @@ func TestWorkspaceAppsProxyPath(t *testing.T) {
318
319
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
319
320
defer cancel ()
320
321
321
- resp , err := client . Request (ctx , http .MethodGet , fmt .Sprintf ("/@me/%s/apps/%s/?%s" , workspace .Name , proxyTestAppNameOwner , proxyTestAppQuery ), nil , func (r * http.Request ) {
322
+ resp , err := requestWithRetries (ctx , t , client , http .MethodGet , fmt .Sprintf ("/@me/%s/apps/%s/?%s" , workspace .Name , proxyTestAppNameOwner , proxyTestAppQuery ), nil , func (r * http.Request ) {
322
323
r .Header .Set ("Cf-Connecting-IP" , "1.1.1.1" )
323
324
})
324
325
require .NoError (t , err )
@@ -367,7 +368,9 @@ func TestWorkspaceApplicationAuth(t *testing.T) {
367
368
require .NoError (t , err )
368
369
req , err := http .NewRequestWithContext (ctx , http .MethodGet , u .String (), nil )
369
370
require .NoError (t , err )
370
- resp , err := client .HTTPClient .Do (req )
371
+
372
+ var resp * http.Response
373
+ resp , err = doWithRetries (t , client , req )
371
374
require .NoError (t , err )
372
375
resp .Body .Close ()
373
376
@@ -380,7 +383,7 @@ func TestWorkspaceApplicationAuth(t *testing.T) {
380
383
require .Equal (t , u .String (), gotLocation .Query ().Get ("redirect_uri" ))
381
384
382
385
// Load the application auth-redirect endpoint.
383
- resp , err = client . Request (ctx , http .MethodGet , "/api/v2/applications/auth-redirect" , nil , codersdk .WithQueryParam (
386
+ resp , err = requestWithRetries (ctx , t , client , http .MethodGet , "/api/v2/applications/auth-redirect" , nil , codersdk .WithQueryParam (
384
387
"redirect_uri" , u .String (),
385
388
))
386
389
require .NoError (t , err )
@@ -517,7 +520,7 @@ func TestWorkspaceApplicationAuth(t *testing.T) {
517
520
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
518
521
defer cancel ()
519
522
520
- resp , err := client . Request (ctx , http .MethodGet , "/api/v2/applications/auth-redirect" , nil ,
523
+ resp , err := requestWithRetries (ctx , t , client , http .MethodGet , "/api/v2/applications/auth-redirect" , nil ,
521
524
codersdk .WithQueryParam ("redirect_uri" , c .redirectURI ),
522
525
)
523
526
require .NoError (t , err )
@@ -556,7 +559,7 @@ func TestWorkspaceAppsProxySubdomainPassthrough(t *testing.T) {
556
559
defer cancel ()
557
560
558
561
uri := fmt .Sprintf ("http://app--agent--workspace--username.%s/api/v2/users/me" , proxyTestSubdomain )
559
- resp , err := client . Request (ctx , http .MethodGet , uri , nil )
562
+ resp , err := requestWithRetries (ctx , t , client , http .MethodGet , uri , nil )
560
563
require .NoError (t , err )
561
564
defer resp .Body .Close ()
562
565
@@ -605,7 +608,7 @@ func TestWorkspaceAppsProxySubdomainBlocked(t *testing.T) {
605
608
defer cancel ()
606
609
607
610
uri := fmt .Sprintf ("http://not-an-app-subdomain.%s/api/v2/users/me" , proxyTestSubdomain )
608
- resp , err := client . Request (ctx , http .MethodGet , uri , nil )
611
+ resp , err := requestWithRetries (ctx , t , client , http .MethodGet , uri , nil )
609
612
require .NoError (t , err )
610
613
defer resp .Body .Close ()
611
614
@@ -689,7 +692,7 @@ func TestWorkspaceAppsProxySubdomain(t *testing.T) {
689
692
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
690
693
defer cancel ()
691
694
692
- resp , err := userClient . Request (ctx , http .MethodGet , proxyURL (t , client , proxyTestAppNameOwner ), nil )
695
+ resp , err := requestWithRetries (ctx , t , userClient , http .MethodGet , proxyURL (t , client , proxyTestAppNameOwner ), nil )
693
696
require .NoError (t , err )
694
697
defer resp .Body .Close ()
695
698
require .Equal (t , http .StatusNotFound , resp .StatusCode )
@@ -702,7 +705,7 @@ func TestWorkspaceAppsProxySubdomain(t *testing.T) {
702
705
defer cancel ()
703
706
704
707
slashlessURL := proxyURL (t , client , proxyTestAppNameOwner , "" )
705
- resp , err := client . Request (ctx , http .MethodGet , slashlessURL , nil )
708
+ resp , err := requestWithRetries (ctx , t , client , http .MethodGet , slashlessURL , nil )
706
709
require .NoError (t , err )
707
710
defer resp .Body .Close ()
708
711
require .Equal (t , http .StatusTemporaryRedirect , resp .StatusCode )
@@ -719,7 +722,7 @@ func TestWorkspaceAppsProxySubdomain(t *testing.T) {
719
722
defer cancel ()
720
723
721
724
querylessURL := proxyURL (t , client , proxyTestAppNameOwner , "/" , "" )
722
- resp , err := client . Request (ctx , http .MethodGet , querylessURL , nil )
725
+ resp , err := requestWithRetries (ctx , t , client , http .MethodGet , querylessURL , nil )
723
726
require .NoError (t , err )
724
727
defer resp .Body .Close ()
725
728
require .Equal (t , http .StatusTemporaryRedirect , resp .StatusCode )
@@ -735,7 +738,7 @@ func TestWorkspaceAppsProxySubdomain(t *testing.T) {
735
738
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
736
739
defer cancel ()
737
740
738
- resp , err := client . Request (ctx , http .MethodGet , proxyURL (t , client , proxyTestAppNameOwner , "/" , proxyTestAppQuery ), nil )
741
+ resp , err := requestWithRetries (ctx , t , client , http .MethodGet , proxyURL (t , client , proxyTestAppNameOwner , "/" , proxyTestAppQuery ), nil )
739
742
require .NoError (t , err )
740
743
defer resp .Body .Close ()
741
744
body , err := io .ReadAll (resp .Body )
@@ -750,7 +753,7 @@ func TestWorkspaceAppsProxySubdomain(t *testing.T) {
750
753
ctx , cancel := context .WithTimeout (context .Background (), testutil .WaitLong )
751
754
defer cancel ()
752
755
753
- resp , err := client . Request (ctx , http .MethodGet , proxyURL (t , client , port , "/" , proxyTestAppQuery ), nil )
756
+ resp , err := requestWithRetries (ctx , t , client , http .MethodGet , proxyURL (t , client , port , "/" , proxyTestAppQuery ), nil )
754
757
require .NoError (t , err )
755
758
defer resp .Body .Close ()
756
759
body , err := io .ReadAll (resp .Body )
@@ -778,7 +781,7 @@ func TestWorkspaceAppsProxySubdomain(t *testing.T) {
778
781
defer cancel ()
779
782
780
783
port := uint16 (codersdk .MinimumListeningPort - 1 )
781
- resp , err := client . Request (ctx , http .MethodGet , proxyURL (t , client , port , "/" , proxyTestAppQuery ), nil )
784
+ resp , err := requestWithRetries (ctx , t , client , http .MethodGet , proxyURL (t , client , port , "/" , proxyTestAppQuery ), nil )
782
785
require .NoError (t , err )
783
786
defer resp .Body .Close ()
784
787
@@ -801,7 +804,7 @@ func TestWorkspaceAppsProxySubdomain(t *testing.T) {
801
804
u := proxyURL (t , client , proxyTestAppNameOwner , "/" , proxyTestAppQuery )
802
805
t .Logf ("url: %s" , u )
803
806
804
- resp , err := client . Request (ctx , http .MethodGet , u , nil )
807
+ resp , err := requestWithRetries (ctx , t , client , http .MethodGet , u , nil )
805
808
require .NoError (t , err )
806
809
defer resp .Body .Close ()
807
810
body , err := io .ReadAll (resp .Body )
@@ -823,7 +826,7 @@ func TestWorkspaceAppsProxySubdomain(t *testing.T) {
823
826
// Replace the -suffix with nothing.
824
827
u = strings .Replace (u , "-suffix" , "" , 1 )
825
828
826
- resp , err := client . Request (ctx , http .MethodGet , u , nil )
829
+ resp , err := requestWithRetries (ctx , t , client , http .MethodGet , u , nil )
827
830
require .NoError (t , err )
828
831
defer resp .Body .Close ()
829
832
body , err := io .ReadAll (resp .Body )
@@ -844,7 +847,7 @@ func TestWorkspaceAppsProxySubdomain(t *testing.T) {
844
847
// Replace the -suffix with something else.
845
848
u = strings .Replace (u , "-suffix" , "-not-suffix" , 1 )
846
849
847
- resp , err := client . Request (ctx , http .MethodGet , u , nil )
850
+ resp , err := requestWithRetries (ctx , t , client , http .MethodGet , u , nil )
848
851
require .NoError (t , err )
849
852
defer resp .Body .Close ()
850
853
body , err := io .ReadAll (resp .Body )
@@ -947,7 +950,7 @@ func TestAppSharing(t *testing.T) {
947
950
msg := fmt .Sprintf ("client %d" , i )
948
951
949
952
appPath := fmt .Sprintf ("/@%s/%s.%s/apps/%s/?%s" , username , workspaceName , agentName , appName , proxyTestAppQuery )
950
- res , err := client . Request (ctx , http .MethodGet , appPath , nil )
953
+ res , err := requestWithRetries (ctx , t , client , http .MethodGet , appPath , nil )
951
954
require .NoError (t , err , msg )
952
955
953
956
dump , err := httputil .DumpResponse (res , true )
0 commit comments