8
8
"time"
9
9
10
10
"github.com/nginxinc/nginx-plus-go-client/client"
11
+ "github.com/nginxinc/nginx-plus-go-client/tests/helpers"
11
12
)
12
13
13
14
const (
@@ -23,7 +24,7 @@ var defaultWeight = 1
23
24
24
25
func TestStreamClient (t * testing.T ) {
25
26
httpClient := & http.Client {}
26
- c , err := client .NewNginxClient (httpClient , "http://127.0.0.1:8080/api" )
27
+ c , err := client .NewNginxClient (httpClient , helpers . GetAPIEndpoint () )
27
28
28
29
if err != nil {
29
30
t .Fatalf ("Error when creating a client: %v" , err )
@@ -168,7 +169,7 @@ func TestStreamClient(t *testing.T) {
168
169
169
170
func TestStreamUpstreamServer (t * testing.T ) {
170
171
httpClient := & http.Client {}
171
- c , err := client .NewNginxClient (httpClient , "http://127.0.0.1:8080/api" )
172
+ c , err := client .NewNginxClient (httpClient , helpers . GetAPIEndpoint () )
172
173
if err != nil {
173
174
t .Fatalf ("Error connecting to nginx: %v" , err )
174
175
}
@@ -213,7 +214,7 @@ func TestStreamUpstreamServer(t *testing.T) {
213
214
214
215
func TestClient (t * testing.T ) {
215
216
httpClient := & http.Client {}
216
- c , err := client .NewNginxClient (httpClient , "http://127.0.0.1:8080/api" )
217
+ c , err := client .NewNginxClient (httpClient , helpers . GetAPIEndpoint () )
217
218
218
219
if err != nil {
219
220
t .Fatalf ("Error when creating a client: %v" , err )
@@ -365,7 +366,7 @@ func TestClient(t *testing.T) {
365
366
366
367
func TestUpstreamServer (t * testing.T ) {
367
368
httpClient := & http.Client {}
368
- c , err := client .NewNginxClient (httpClient , "http://127.0.0.1:8080/api" )
369
+ c , err := client .NewNginxClient (httpClient , helpers . GetAPIEndpoint () )
369
370
if err != nil {
370
371
t .Fatalf ("Error connecting to nginx: %v" , err )
371
372
}
@@ -410,7 +411,7 @@ func TestUpstreamServer(t *testing.T) {
410
411
411
412
func TestStats (t * testing.T ) {
412
413
httpClient := & http.Client {}
413
- c , err := client .NewNginxClient (httpClient , "http://127.0.0.1:8080/api" )
414
+ c , err := client .NewNginxClient (httpClient , helpers . GetAPIEndpoint () )
414
415
if err != nil {
415
416
t .Fatalf ("Error connecting to nginx: %v" , err )
416
417
}
@@ -509,7 +510,7 @@ func TestStats(t *testing.T) {
509
510
510
511
func TestUpstreamServerDefaultParameters (t * testing.T ) {
511
512
httpClient := & http.Client {}
512
- c , err := client .NewNginxClient (httpClient , "http://127.0.0.1:8080/api" )
513
+ c , err := client .NewNginxClient (httpClient , helpers . GetAPIEndpoint () )
513
514
if err != nil {
514
515
t .Fatalf ("Error connecting to nginx: %v" , err )
515
516
}
@@ -552,7 +553,7 @@ func TestUpstreamServerDefaultParameters(t *testing.T) {
552
553
553
554
func TestStreamStats (t * testing.T ) {
554
555
httpClient := & http.Client {}
555
- c , err := client .NewNginxClient (httpClient , "http://127.0.0.1:8080/api" )
556
+ c , err := client .NewNginxClient (httpClient , helpers . GetAPIEndpoint () )
556
557
if err != nil {
557
558
t .Fatalf ("Error connecting to nginx: %v" , err )
558
559
}
@@ -566,7 +567,7 @@ func TestStreamStats(t *testing.T) {
566
567
}
567
568
568
569
// make connection so we have stream server zone stats - ignore response
569
- _ , err = net .Dial ("tcp" , "127.0.0.1:8081" )
570
+ _ , err = net .Dial ("tcp" , helpers . GetStreamAddress () )
570
571
if err != nil {
571
572
t .Errorf ("Error making tcp connection: %v" , err )
572
573
}
@@ -622,7 +623,7 @@ func TestStreamStats(t *testing.T) {
622
623
623
624
func TestStreamUpstreamServerDefaultParameters (t * testing.T ) {
624
625
httpClient := & http.Client {}
625
- c , err := client .NewNginxClient (httpClient , "http://127.0.0.1:8080/api" )
626
+ c , err := client .NewNginxClient (httpClient , helpers . GetAPIEndpoint () )
626
627
if err != nil {
627
628
t .Fatalf ("Error connecting to nginx: %v" , err )
628
629
}
@@ -666,7 +667,7 @@ func TestStreamUpstreamServerDefaultParameters(t *testing.T) {
666
667
func TestKeyValue (t * testing.T ) {
667
668
zoneName := "zone_one"
668
669
httpClient := & http.Client {}
669
- c , err := client .NewNginxClient (httpClient , "http://127.0.0.1:8080/api" )
670
+ c , err := client .NewNginxClient (httpClient , helpers . GetAPIEndpoint () )
670
671
if err != nil {
671
672
t .Fatalf ("Error connecting to nginx: %v" , err )
672
673
}
@@ -764,7 +765,7 @@ func TestKeyValue(t *testing.T) {
764
765
func TestKeyValueStream (t * testing.T ) {
765
766
zoneName := "zone_one_stream"
766
767
httpClient := & http.Client {}
767
- c , err := client .NewNginxClient (httpClient , "http://127.0.0.1:8080/api" )
768
+ c , err := client .NewNginxClient (httpClient , helpers . GetAPIEndpoint () )
768
769
if err != nil {
769
770
t .Fatalf ("Error connecting to nginx: %v" , err )
770
771
}
@@ -860,12 +861,12 @@ func TestKeyValueStream(t *testing.T) {
860
861
}
861
862
862
863
func TestStreamZoneSync (t * testing.T ) {
863
- c1 , err := client .NewNginxClient (& http.Client {}, "http://127.0.0.1:8080/api" )
864
+ c1 , err := client .NewNginxClient (& http.Client {}, helpers . GetAPIEndpoint () )
864
865
if err != nil {
865
866
t .Fatalf ("Error connecting to nginx: %v" , err )
866
867
}
867
868
868
- c2 , err := client .NewNginxClient (& http.Client {}, "http://127.0.0.1:8090/api" )
869
+ c2 , err := client .NewNginxClient (& http.Client {}, helpers . GetAPIEndpointOfHelper () )
869
870
if err != nil {
870
871
t .Fatalf ("Error connecting to nginx: %v" , err )
871
872
}
@@ -987,7 +988,7 @@ func compareStreamUpstreamServers(x []client.StreamUpstreamServer, y []client.St
987
988
988
989
func TestUpstreamServerWithDrain (t * testing.T ) {
989
990
httpClient := & http.Client {}
990
- c , err := client .NewNginxClient (httpClient , "http://127.0.0.1:8080/api" )
991
+ c , err := client .NewNginxClient (httpClient , helpers . GetAPIEndpoint () )
991
992
if err != nil {
992
993
t .Fatalf ("Error connecting to nginx: %v" , err )
993
994
}
0 commit comments