Skip to content

Commit

Permalink
feat(lbaas): support for controlling health check TLS verify (#240)
Browse files Browse the repository at this point in the history
* support for health check tls verify

* fix lb svc tests and update fixtures
  • Loading branch information
thevilledev authored Jun 8, 2023
1 parent 101fabc commit e291e94
Show file tree
Hide file tree
Showing 13 changed files with 6,606 additions and 1,419 deletions.
1 change: 1 addition & 0 deletions upcloud/load_balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ type LoadBalancerBackendMember struct {
type LoadBalancerBackendProperties struct {
TimeoutServer int `json:"timeout_server,omitempty"`
TimeoutTunnel int `json:"timeout_tunnel,omitempty"`
HealthCheckTLSVerify *bool `json:"health_check_tls_verify,omitempty"`
HealthCheckType LoadBalancerHealthCheckType `json:"health_check_type,omitempty"`
HealthCheckInterval int `json:"health_check_interval,omitempty"`
HealthCheckFall int `json:"health_check_fall,omitempty"`
Expand Down
2 changes: 2 additions & 0 deletions upcloud/load_balancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ func TestLoadBalancerBackendProperties(t *testing.T) {
&LoadBalancerBackendProperties{
TimeoutServer: 30,
TimeoutTunnel: 3600,
HealthCheckTLSVerify: BoolPtr(false),
HealthCheckType: LoadBalancerHealthCheckTypeHTTP,
HealthCheckInterval: 20,
HealthCheckFall: 3,
Expand All @@ -521,6 +522,7 @@ func TestLoadBalancerBackendProperties(t *testing.T) {
"timeout_server": 30,
"timeout_tunnel": 3600,
"health_check_type": "http",
"health_check_tls_verify": false,
"health_check_interval": 20,
"health_check_fall": 3,
"health_check_rise": 3,
Expand Down
571 changes: 416 additions & 155 deletions upcloud/service/fixtures/loadbalancer.yaml

Large diffs are not rendered by default.

447 changes: 302 additions & 145 deletions upcloud/service/fixtures/loadbalancerbackend.yaml

Large diffs are not rendered by default.

497 changes: 327 additions & 170 deletions upcloud/service/fixtures/loadbalancerbackendmember.yaml

Large diffs are not rendered by default.

Large diffs are not rendered by default.

725 changes: 532 additions & 193 deletions upcloud/service/fixtures/loadbalancerfrontend.yaml

Large diffs are not rendered by default.

1,103 changes: 1,070 additions & 33 deletions upcloud/service/fixtures/loadbalancerfrontendrule.yaml

Large diffs are not rendered by default.

1,290 changes: 1,252 additions & 38 deletions upcloud/service/fixtures/loadbalancerlabels.yaml

Large diffs are not rendered by default.

394 changes: 367 additions & 27 deletions upcloud/service/fixtures/loadbalancernetworks.yaml

Large diffs are not rendered by default.

1,985 changes: 1,692 additions & 293 deletions upcloud/service/fixtures/loadbalancerpage.yaml

Large diffs are not rendered by default.

497 changes: 353 additions & 144 deletions upcloud/service/fixtures/loadbalancerresolver.yaml

Large diffs are not rendered by default.

50 changes: 21 additions & 29 deletions upcloud/service/load_balancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ func TestLoadBalancer(t *testing.T) {
// Create Load Balancer
lb, err := createLoadBalancerAndNetwork(ctx, svc, "fi-hel1", "172.16.1.0/24")
require.NoError(t, err)
t.Cleanup(func() {
defer func() {
err := cleanupLoadBalancer(ctx, rec, svc, lb)
assert.NoError(t, err)
})
}()
t.Logf("Created load balancer: %s", lb.Name)

// Modify Load Balancer
Expand Down Expand Up @@ -62,10 +62,10 @@ func TestLoadBalancerBackend(t *testing.T) {
record(t, "loadbalancerbackend", func(ctx context.Context, t *testing.T, rec *recorder.Recorder, svc *Service) {
lb, err := createLoadBalancerAndNetwork(ctx, svc, "fi-hel2", "172.16.2.0/24")
require.NoError(t, err)
t.Cleanup(func() {
defer func() {
err := cleanupLoadBalancer(ctx, rec, svc, lb)
assert.NoError(t, err)
})
}()

t.Logf("Created load balancer for testing LB backend CRUD: %s", lb.Name)

Expand Down Expand Up @@ -126,10 +126,10 @@ func TestLoadBalancerBackendMember(t *testing.T) {
record(t, "loadbalancerbackendmember", func(ctx context.Context, t *testing.T, rec *recorder.Recorder, svc *Service) {
lb, err := createLoadBalancerAndNetwork(ctx, svc, "nl-ams1", "172.16.3.0/24")
require.NoError(t, err)
t.Cleanup(func() {
defer func() {
err := cleanupLoadBalancer(ctx, rec, svc, lb)
assert.NoError(t, err)
})
}()
t.Logf("Created load balancer for testing LB backend members CRUD: %s", lb.Name)

backend, err := createLoadBalancerBackend(ctx, svc, lb.UUID)
Expand Down Expand Up @@ -248,10 +248,10 @@ func TestLoadBalancerResolver(t *testing.T) {
record(t, "loadbalancerresolver", func(ctx context.Context, t *testing.T, rec *recorder.Recorder, svc *Service) {
lb, err := createLoadBalancerAndNetwork(ctx, svc, "pl-waw1", "10.0.0.0/24")
require.NoError(t, err)
t.Cleanup(func() {
defer func() {
err := cleanupLoadBalancer(ctx, rec, svc, lb)
assert.NoError(t, err)
})
}()
t.Logf("Created load balancer for testing LB resolvers CRUD: %s", lb.Name)

name := "testname"
Expand Down Expand Up @@ -380,12 +380,12 @@ func TestLoadBalancerFrontend(t *testing.T) {
t.Parallel()

record(t, "loadbalancerfrontend", func(ctx context.Context, t *testing.T, rec *recorder.Recorder, svc *Service) {
lb, err := createLoadBalancerAndNetwork(ctx, svc, "de-fra1", "10.0.0.1/24")
lb, err := createLoadBalancerAndNetwork(ctx, svc, "de-fra1", "10.0.3.0/24")
require.NoError(t, err)
t.Cleanup(func() {
defer func() {
err := cleanupLoadBalancer(ctx, rec, svc, lb)
assert.NoError(t, err)
})
}()
t.Logf("Created LB for testing frontends: %s", lb.Name)
be, err := createLoadBalancerBackend(ctx, svc, lb.UUID)
require.NoError(t, err)
Expand Down Expand Up @@ -484,12 +484,10 @@ func TestLoadBalancerFrontendRule(t *testing.T) {
})

require.NoError(t, err)
t.Cleanup(func() {
cCtx, cancel := context.WithTimeout(context.Background(), time.Minute*10)
defer cancel()
err := cleanupLoadBalancer(cCtx, rec, svc, lb)
defer func() {
err := cleanupLoadBalancer(ctx, rec, svc, lb)
assert.NoError(t, err)
})
}()
rule, err := svc.CreateLoadBalancerFrontendRule(ctx, &request.CreateLoadBalancerFrontendRuleRequest{
ServiceUUID: lb.UUID,
FrontendName: lb.Frontends[0].Name,
Expand Down Expand Up @@ -607,7 +605,7 @@ func TestLoadBalancerCerticateBundlesAndFrontendTLSConfigs(t *testing.T) {
t.Parallel()

record(t, "loadbalancercerticatebundlesandfrontendtlsconfigs", func(ctx context.Context, t *testing.T, rec *recorder.Recorder, svc *Service) {
net, err := createLoadBalancerAndPrivateNetwork(ctx, svc, "fi-hel1", "10.0.1.1/24")
net, err := createLoadBalancerAndPrivateNetwork(ctx, svc, "fi-hel1", "10.0.4.0/24")
require.NoError(t, err)
feName := "fe-1"
lb, err := svc.CreateLoadBalancer(ctx, &request.CreateLoadBalancerRequest{
Expand Down Expand Up @@ -639,10 +637,10 @@ func TestLoadBalancerCerticateBundlesAndFrontendTLSConfigs(t *testing.T) {
})

require.NoError(t, err)
t.Cleanup(func() {
defer func() {
err := cleanupLoadBalancer(ctx, rec, svc, lb)
assert.NoError(t, err)
})
}()

mc, err := svc.CreateLoadBalancerCertificateBundle(ctx, &request.CreateLoadBalancerCertificateBundleRequest{
Type: upcloud.LoadBalancerCertificateBundleTypeManual,
Expand Down Expand Up @@ -871,10 +869,10 @@ func TestLoadBalancerNetwork(t *testing.T) {
Resolvers: make([]request.LoadBalancerResolver, 0),
})
require.NoError(t, err)
t.Cleanup(func() {
defer func() {
err := cleanupLoadBalancer(ctx, rec, svc, lb)
assert.NoError(t, err)
})
}()

t.Logf("Testing LB %s properties", lb.Name)
assert.Len(t, lb.Networks, 2)
Expand Down Expand Up @@ -955,16 +953,14 @@ func TestLoadBalancerLabels(t *testing.T) {
lb2, err := createLoadBalancerAndNetwork(ctx, svc, "fi-hel1", "172.16.14.0/24", upcloud.Label{Key: "zone", Value: "hel1"})
require.NoError(t, err)
t.Logf("Created load balancer: %s", lb2.Name)
t.Cleanup(func() {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
defer cancel()
defer func() {
if err := cleanupLoadBalancer(ctx, rec, svc, lb1); err != nil {
t.Log(err)
}
if err := cleanupLoadBalancer(ctx, rec, svc, lb2); err != nil {
t.Log(err)
}
})
}()

// Get Load Balancers
t.Log("Get load balancers labeled as 'zone'")
Expand Down Expand Up @@ -1062,11 +1058,7 @@ func cleanupLoadBalancer(ctx context.Context, rec *recorder.Recorder, svc *Servi
if rec.Mode() != recorder.ModeRecording {
return nil
}
rec.AddPassthrough(func(h *http.Request) bool {
return true
})
err := deleteLoadBalancer(ctx, svc, lb)
rec.Passthroughs = nil
return err
}

Expand Down

0 comments on commit e291e94

Please sign in to comment.