Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Consecutive_up and Consecutive_down for load_balancer_monitor res… #1380

Merged
merged 2 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/1380.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
load_balancer_monitor: add support for `consecutive_up`, `consecutive_down`
```
36 changes: 19 additions & 17 deletions load_balancing.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,25 @@ type LoadBalancerOriginSteering struct {

// LoadBalancerMonitor represents a load balancer monitor's properties.
type LoadBalancerMonitor struct {
ID string `json:"id,omitempty"`
CreatedOn *time.Time `json:"created_on,omitempty"`
ModifiedOn *time.Time `json:"modified_on,omitempty"`
Type string `json:"type"`
Description string `json:"description"`
Method string `json:"method"`
Path string `json:"path"`
Header map[string][]string `json:"header"`
Timeout int `json:"timeout"`
Retries int `json:"retries"`
Interval int `json:"interval"`
Port uint16 `json:"port,omitempty"`
ExpectedBody string `json:"expected_body"`
ExpectedCodes string `json:"expected_codes"`
FollowRedirects bool `json:"follow_redirects"`
AllowInsecure bool `json:"allow_insecure"`
ProbeZone string `json:"probe_zone"`
ID string `json:"id,omitempty"`
CreatedOn *time.Time `json:"created_on,omitempty"`
ModifiedOn *time.Time `json:"modified_on,omitempty"`
Type string `json:"type"`
Description string `json:"description"`
Method string `json:"method"`
Path string `json:"path"`
Header map[string][]string `json:"header"`
Timeout int `json:"timeout"`
Retries int `json:"retries"`
Interval int `json:"interval"`
Consecutive_up int `json:"consecutive_up"`
Nmishin marked this conversation as resolved.
Show resolved Hide resolved
Consecutive_down int `json:"consecutive_down"`
Nmishin marked this conversation as resolved.
Show resolved Hide resolved
Port uint16 `json:"port,omitempty"`
ExpectedBody string `json:"expected_body"`
ExpectedCodes string `json:"expected_codes"`
FollowRedirects bool `json:"follow_redirects"`
AllowInsecure bool `json:"allow_insecure"`
ProbeZone string `json:"probe_zone"`
}

// LoadBalancer represents a load balancer's properties.
Expand Down
84 changes: 54 additions & 30 deletions load_balancing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,8 @@ func TestCreateLoadBalancerMonitor(t *testing.T) {
"timeout": 3,
"retries": 0,
"interval": 90,
"consecutive_up": 2,
"consecutive_down": 2,
"expected_body": "alive",
"expected_codes": "2xx",
"follow_redirects": true,
Expand Down Expand Up @@ -653,6 +655,8 @@ func TestCreateLoadBalancerMonitor(t *testing.T) {
"timeout": 3,
"retries": 0,
"interval": 90,
"consecutive_up": 2,
"consecutive_down": 2,
"expected_body": "alive",
"expected_codes": "2xx",
"follow_redirects": true,
Expand All @@ -677,11 +681,13 @@ func TestCreateLoadBalancerMonitor(t *testing.T) {
"Host": {"example.com"},
"X-App-ID": {"abc123"},
},
Timeout: 3,
Retries: 0,
Interval: 90,
ExpectedBody: "alive",
ExpectedCodes: "2xx",
Timeout: 3,
Retries: 0,
Interval: 90,
Consecutive_up: 2,
Consecutive_down: 2,
ExpectedBody: "alive",
ExpectedCodes: "2xx",

FollowRedirects: true,
AllowInsecure: true,
Expand All @@ -695,11 +701,13 @@ func TestCreateLoadBalancerMonitor(t *testing.T) {
"Host": {"example.com"},
"X-App-ID": {"abc123"},
},
Timeout: 3,
Retries: 0,
Interval: 90,
ExpectedBody: "alive",
ExpectedCodes: "2xx",
Timeout: 3,
Retries: 0,
Interval: 90,
Consecutive_up: 2,
Consecutive_down: 2,
ExpectedBody: "alive",
ExpectedCodes: "2xx",

FollowRedirects: true,
AllowInsecure: true,
Expand Down Expand Up @@ -752,6 +760,8 @@ func TestListLoadBalancerMonitors(t *testing.T) {
"timeout": 3,
"retries": 0,
"interval": 90,
"consecutive_up": 2,
"consecutive_down": 2,
"expected_body": "alive",
"expected_codes": "2xx"
}
Expand Down Expand Up @@ -781,11 +791,13 @@ func TestListLoadBalancerMonitors(t *testing.T) {
"Host": {"example.com"},
"X-App-ID": {"abc123"},
},
Timeout: 3,
Retries: 0,
Interval: 90,
ExpectedBody: "alive",
ExpectedCodes: "2xx",
Timeout: 3,
Retries: 0,
Interval: 90,
Consecutive_up: 2,
Consecutive_down: 2,
ExpectedBody: "alive",
ExpectedCodes: "2xx",
},
}

Expand Down Expand Up @@ -835,6 +847,8 @@ func TestGetLoadBalancerMonitor(t *testing.T) {
"timeout": 3,
"retries": 0,
"interval": 90,
"consecutive_up": 2,
"consecutive_down": 2,
"expected_body": "alive",
"expected_codes": "2xx",
"follow_redirects": true,
Expand All @@ -859,11 +873,13 @@ func TestGetLoadBalancerMonitor(t *testing.T) {
"Host": {"example.com"},
"X-App-ID": {"abc123"},
},
Timeout: 3,
Retries: 0,
Interval: 90,
ExpectedBody: "alive",
ExpectedCodes: "2xx",
Timeout: 3,
Retries: 0,
Interval: 90,
Consecutive_up: 2,
Consecutive_down: 2,
ExpectedBody: "alive",
ExpectedCodes: "2xx",

FollowRedirects: true,
AllowInsecure: true,
Expand Down Expand Up @@ -947,6 +963,8 @@ func TestUpdateLoadBalancerMonitor(t *testing.T) {
"timeout": 3,
"retries": 0,
"interval": 90,
"consecutive_up": 2,
"consecutive_down": 2,
"expected_body": "kicking",
"expected_codes": "200",
"follow_redirects": true,
Expand Down Expand Up @@ -977,6 +995,8 @@ func TestUpdateLoadBalancerMonitor(t *testing.T) {
"timeout": 3,
"retries": 0,
"interval": 90,
"consecutive_up": 2,
"consecutive_down": 2,
"expected_body": "kicking",
"expected_codes": "200",
"follow_redirects": true,
Expand All @@ -1001,11 +1021,13 @@ func TestUpdateLoadBalancerMonitor(t *testing.T) {
"Host": {"example.com"},
"X-App-ID": {"easy"},
},
Timeout: 3,
Retries: 0,
Interval: 90,
ExpectedBody: "kicking",
ExpectedCodes: "200",
Timeout: 3,
Retries: 0,
Interval: 90,
Consecutive_up: 2,
Consecutive_down: 2,
ExpectedBody: "kicking",
ExpectedCodes: "200",

FollowRedirects: true,
AllowInsecure: true,
Expand All @@ -1020,11 +1042,13 @@ func TestUpdateLoadBalancerMonitor(t *testing.T) {
"Host": {"example.com"},
"X-App-ID": {"easy"},
},
Timeout: 3,
Retries: 0,
Interval: 90,
ExpectedBody: "kicking",
ExpectedCodes: "200",
Timeout: 3,
Retries: 0,
Interval: 90,
Consecutive_up: 2,
Consecutive_down: 2,
ExpectedBody: "kicking",
ExpectedCodes: "200",

FollowRedirects: true,
AllowInsecure: true,
Expand Down