File tree Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import (
1212// APIVersion is a version of NGINX Plus API.
1313const APIVersion = 2
1414
15- // NginxClient lets you add/remove servers to/from NGINX Plus via its API.
15+ // NginxClient lets you access NGINX Plus API.
1616type NginxClient struct {
1717 apiEndpoint string
1818 httpClient * http.Client
@@ -108,6 +108,7 @@ type Responses struct {
108108 Responses3xx uint64 `json:"3xx"`
109109 Responses4xx uint64 `json:"4xx"`
110110 Responses5xx uint64 `json:"5xx"`
111+ Total uint64
111112}
112113
113114// Upstreams is a map of upstream stats by upstream name.
@@ -146,7 +147,7 @@ type Peer struct {
146147 Received uint64
147148 Fails uint64
148149 Unavail uint64
149- HealthChecks HealthChecks
150+ HealthChecks HealthChecks `json:"health_checks"`
150151 Downtime uint64
151152 Downstart string
152153 Selected string
Original file line number Diff line number Diff line change @@ -16,5 +16,10 @@ server {
1616 }
1717 api write=on;
1818 }
19+
20+ location /test {
21+ proxy_pass http://test;
22+ health_check interval=10 fails=3 passes=1;
23+ }
1924 status_zone test;
2025}
Original file line number Diff line number Diff line change @@ -399,7 +399,7 @@ func TestStats(t *testing.T) {
399399
400400 // need upstream for stats
401401 server := client.UpstreamServer {
402- Server : "127.0.0.1:2000 " ,
402+ Server : "127.0.0.1:8080 " ,
403403 }
404404 err = c .AddHTTPServer (upstream , server )
405405 if err != nil {
@@ -435,6 +435,12 @@ func TestStats(t *testing.T) {
435435 if ups .Peers [0 ].State != "up" {
436436 t .Errorf ("upstream server state should be 'up'" )
437437 }
438+ if ups .Peers [0 ].Responses .Total < 0 {
439+ t .Errorf ("upstream should have total responses value" )
440+ }
441+ if ups .Peers [0 ].HealthChecks .LastPassed {
442+ t .Errorf ("upstream server health check should report last failed" )
443+ }
438444 }
439445 } else {
440446 t .Errorf ("Upstream 'test' not found" )
You can’t perform that action at this time.
0 commit comments