Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.

Commit

Permalink
Add a test to test consul client restart
Browse files Browse the repository at this point in the history
  • Loading branch information
ishustava committed Apr 6, 2021
1 parent 7ecf10d commit 1853230
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
2 changes: 2 additions & 0 deletions templates/connect-inject-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ spec:
-consul-image="{{ default .Values.global.image .Values.connectInject.imageConsul }}" \
-envoy-image="{{ .Values.global.imageEnvoy }}" \
-consul-k8s-image="{{ default .Values.global.imageK8S .Values.connectInject.image }}" \
-release-name="{{ .Release.Name }} \
-release-namespace="{{ .Release.Namespace }} \
-listen=:8080 \
{{- if .Values.connectInject.logLevel }}
-log-level={{ .Values.connectInject.logLevel }} \
Expand Down
30 changes: 30 additions & 0 deletions test/acceptance/tests/connect/connect_inject_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,33 @@ func TestConnectInject_CleanupController(t *testing.T) {
})
}
}

// Test that when Consul clients are restarted and lose all their registrations,
// the services get re-registered and can continue to talk to each other.
func TestConnectInject_RestartConsulClients(t *testing.T) {
cfg := suite.Config()
ctx := suite.Environment().DefaultContext(t)

helmValues := map[string]string{
"connectInject.enabled": "true",
}

releaseName := helpers.RandomName()
consulCluster := consul.NewHelmCluster(t, helmValues, ctx, cfg, releaseName)

consulCluster.Create(t)

logger.Log(t, "creating static-server and static-client deployments")
k8s.DeployKustomize(t, ctx.KubectlOptions(t), cfg.NoCleanupOnFailure, cfg.DebugDirectory, "../fixtures/cases/static-server-inject")
k8s.DeployKustomize(t, ctx.KubectlOptions(t), cfg.NoCleanupOnFailure, cfg.DebugDirectory, "../fixtures/cases/static-client-inject")

logger.Log(t, "checking that connection is successful")
k8s.CheckStaticServerConnectionSuccessful(t, ctx.KubectlOptions(t), staticClientName, "http://localhost:1234")

logger.Log(t, "restarting Consul client daemonset")
k8s.RunKubectl(t, ctx.KubectlOptions(t), "rollout", "restart", fmt.Sprintf("ds/%s-consul", releaseName))
k8s.RunKubectl(t, ctx.KubectlOptions(t), "rollout", "status", fmt.Sprintf("ds/%s-consul", releaseName))

logger.Log(t, "checking that connection is still successful")
k8s.CheckStaticServerConnectionSuccessful(t, ctx.KubectlOptions(t), staticClientName, "http://localhost:1234")
}
2 changes: 1 addition & 1 deletion values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1514,7 +1514,7 @@ connectInject:
# ServiceIntentions require consul 1.9+.
controller:
# Enables the controller for managing custom resources.
enabled: true
enabled: false

# The number of deployment replicas.
replicas: 1
Expand Down

0 comments on commit 1853230

Please sign in to comment.