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 (
12
12
// APIVersion is a version of NGINX Plus API.
13
13
const APIVersion = 2
14
14
15
- // NginxClient lets you add/remove servers to/from NGINX Plus via its API.
15
+ // NginxClient lets you access NGINX Plus API.
16
16
type NginxClient struct {
17
17
apiEndpoint string
18
18
httpClient * http.Client
@@ -108,6 +108,7 @@ type Responses struct {
108
108
Responses3xx uint64 `json:"3xx"`
109
109
Responses4xx uint64 `json:"4xx"`
110
110
Responses5xx uint64 `json:"5xx"`
111
+ Total uint64
111
112
}
112
113
113
114
// Upstreams is a map of upstream stats by upstream name.
@@ -146,7 +147,7 @@ type Peer struct {
146
147
Received uint64
147
148
Fails uint64
148
149
Unavail uint64
149
- HealthChecks HealthChecks
150
+ HealthChecks HealthChecks `json:"health_checks"`
150
151
Downtime uint64
151
152
Downstart string
152
153
Selected string
Original file line number Diff line number Diff line change @@ -16,5 +16,10 @@ server {
16
16
}
17
17
api write=on;
18
18
}
19
+
20
+ location /test {
21
+ proxy_pass http://test;
22
+ health_check interval=10 fails=3 passes=1;
23
+ }
19
24
status_zone test;
20
25
}
Original file line number Diff line number Diff line change @@ -399,7 +399,7 @@ func TestStats(t *testing.T) {
399
399
400
400
// need upstream for stats
401
401
server := client.UpstreamServer {
402
- Server : "127.0.0.1:2000 " ,
402
+ Server : "127.0.0.1:8080 " ,
403
403
}
404
404
err = c .AddHTTPServer (upstream , server )
405
405
if err != nil {
@@ -435,6 +435,12 @@ func TestStats(t *testing.T) {
435
435
if ups .Peers [0 ].State != "up" {
436
436
t .Errorf ("upstream server state should be 'up'" )
437
437
}
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
+ }
438
444
}
439
445
} else {
440
446
t .Errorf ("Upstream 'test' not found" )
You can’t perform that action at this time.
0 commit comments