88 "time"
99
1010 "github.com/nginxinc/nginx-plus-go-client/client"
11+ "github.com/nginxinc/nginx-plus-go-client/tests/helpers"
1112)
1213
1314const (
@@ -23,7 +24,7 @@ var defaultWeight = 1
2324
2425func TestStreamClient (t * testing.T ) {
2526 httpClient := & http.Client {}
26- c , err := client .NewNginxClient (httpClient , "http://127.0.0.1:8080/api" )
27+ c , err := client .NewNginxClient (httpClient , helpers . GetAPIEndpoint () )
2728
2829 if err != nil {
2930 t .Fatalf ("Error when creating a client: %v" , err )
@@ -168,7 +169,7 @@ func TestStreamClient(t *testing.T) {
168169
169170func TestStreamUpstreamServer (t * testing.T ) {
170171 httpClient := & http.Client {}
171- c , err := client .NewNginxClient (httpClient , "http://127.0.0.1:8080/api" )
172+ c , err := client .NewNginxClient (httpClient , helpers . GetAPIEndpoint () )
172173 if err != nil {
173174 t .Fatalf ("Error connecting to nginx: %v" , err )
174175 }
@@ -213,7 +214,7 @@ func TestStreamUpstreamServer(t *testing.T) {
213214
214215func TestClient (t * testing.T ) {
215216 httpClient := & http.Client {}
216- c , err := client .NewNginxClient (httpClient , "http://127.0.0.1:8080/api" )
217+ c , err := client .NewNginxClient (httpClient , helpers . GetAPIEndpoint () )
217218
218219 if err != nil {
219220 t .Fatalf ("Error when creating a client: %v" , err )
@@ -365,7 +366,7 @@ func TestClient(t *testing.T) {
365366
366367func TestUpstreamServer (t * testing.T ) {
367368 httpClient := & http.Client {}
368- c , err := client .NewNginxClient (httpClient , "http://127.0.0.1:8080/api" )
369+ c , err := client .NewNginxClient (httpClient , helpers . GetAPIEndpoint () )
369370 if err != nil {
370371 t .Fatalf ("Error connecting to nginx: %v" , err )
371372 }
@@ -410,7 +411,7 @@ func TestUpstreamServer(t *testing.T) {
410411
411412func TestStats (t * testing.T ) {
412413 httpClient := & http.Client {}
413- c , err := client .NewNginxClient (httpClient , "http://127.0.0.1:8080/api" )
414+ c , err := client .NewNginxClient (httpClient , helpers . GetAPIEndpoint () )
414415 if err != nil {
415416 t .Fatalf ("Error connecting to nginx: %v" , err )
416417 }
@@ -509,7 +510,7 @@ func TestStats(t *testing.T) {
509510
510511func TestUpstreamServerDefaultParameters (t * testing.T ) {
511512 httpClient := & http.Client {}
512- c , err := client .NewNginxClient (httpClient , "http://127.0.0.1:8080/api" )
513+ c , err := client .NewNginxClient (httpClient , helpers . GetAPIEndpoint () )
513514 if err != nil {
514515 t .Fatalf ("Error connecting to nginx: %v" , err )
515516 }
@@ -552,7 +553,7 @@ func TestUpstreamServerDefaultParameters(t *testing.T) {
552553
553554func TestStreamStats (t * testing.T ) {
554555 httpClient := & http.Client {}
555- c , err := client .NewNginxClient (httpClient , "http://127.0.0.1:8080/api" )
556+ c , err := client .NewNginxClient (httpClient , helpers . GetAPIEndpoint () )
556557 if err != nil {
557558 t .Fatalf ("Error connecting to nginx: %v" , err )
558559 }
@@ -566,7 +567,7 @@ func TestStreamStats(t *testing.T) {
566567 }
567568
568569 // 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 () )
570571 if err != nil {
571572 t .Errorf ("Error making tcp connection: %v" , err )
572573 }
@@ -622,7 +623,7 @@ func TestStreamStats(t *testing.T) {
622623
623624func TestStreamUpstreamServerDefaultParameters (t * testing.T ) {
624625 httpClient := & http.Client {}
625- c , err := client .NewNginxClient (httpClient , "http://127.0.0.1:8080/api" )
626+ c , err := client .NewNginxClient (httpClient , helpers . GetAPIEndpoint () )
626627 if err != nil {
627628 t .Fatalf ("Error connecting to nginx: %v" , err )
628629 }
@@ -666,7 +667,7 @@ func TestStreamUpstreamServerDefaultParameters(t *testing.T) {
666667func TestKeyValue (t * testing.T ) {
667668 zoneName := "zone_one"
668669 httpClient := & http.Client {}
669- c , err := client .NewNginxClient (httpClient , "http://127.0.0.1:8080/api" )
670+ c , err := client .NewNginxClient (httpClient , helpers . GetAPIEndpoint () )
670671 if err != nil {
671672 t .Fatalf ("Error connecting to nginx: %v" , err )
672673 }
@@ -764,7 +765,7 @@ func TestKeyValue(t *testing.T) {
764765func TestKeyValueStream (t * testing.T ) {
765766 zoneName := "zone_one_stream"
766767 httpClient := & http.Client {}
767- c , err := client .NewNginxClient (httpClient , "http://127.0.0.1:8080/api" )
768+ c , err := client .NewNginxClient (httpClient , helpers . GetAPIEndpoint () )
768769 if err != nil {
769770 t .Fatalf ("Error connecting to nginx: %v" , err )
770771 }
@@ -860,12 +861,12 @@ func TestKeyValueStream(t *testing.T) {
860861}
861862
862863func 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 () )
864865 if err != nil {
865866 t .Fatalf ("Error connecting to nginx: %v" , err )
866867 }
867868
868- c2 , err := client .NewNginxClient (& http.Client {}, "http://127.0.0.1:8090/api" )
869+ c2 , err := client .NewNginxClient (& http.Client {}, helpers . GetAPIEndpointOfHelper () )
869870 if err != nil {
870871 t .Fatalf ("Error connecting to nginx: %v" , err )
871872 }
@@ -987,7 +988,7 @@ func compareStreamUpstreamServers(x []client.StreamUpstreamServer, y []client.St
987988
988989func TestUpstreamServerWithDrain (t * testing.T ) {
989990 httpClient := & http.Client {}
990- c , err := client .NewNginxClient (httpClient , "http://127.0.0.1:8080/api" )
991+ c , err := client .NewNginxClient (httpClient , helpers . GetAPIEndpoint () )
991992 if err != nil {
992993 t .Fatalf ("Error connecting to nginx: %v" , err )
993994 }
0 commit comments