Skip to content

Commit

Permalink
Acceptance: wait for previous installation to exit (hashicorp#818)
Browse files Browse the repository at this point in the history
* Acceptance: wait for previous installation to exit

In some cases the previous installation is listed as uninstalled by Helm
but its pods are still terminating. This can cause issues for the newly
running tests when they query Kubernetes to get information about the
new installation, e.g. getting the server pod IPs might return the IPs
from the old installation as well.

* Make static-client/server exit faster
  • Loading branch information
lkysow committed Feb 11, 2021
1 parent 18a6448 commit 21d92f5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/acceptance/framework/consul/consul_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,21 @@ func (h *HelmCluster) checkForPriorInstallations(t *testing.T) {
for _, r := range installedReleases {
require.NotContains(t, r["chart"], "consul", fmt.Sprintf("detected an existing installation of Consul %s, release name: %s", r["chart"], r["name"]))
}

// Wait for all pods in the "default" namespace to exit. A previous
// release may not be listed by Helm but its pods may still be terminating.
retry.RunWith(&retry.Counter{Wait: 1 * time.Second, Count: 30}, t, func(r *retry.R) {
consulPods, err := h.kubernetesClient.CoreV1().Pods(h.helmOptions.KubectlOptions.Namespace).List(context.Background(), metav1.ListOptions{})
require.NoError(r, err)
if len(consulPods.Items) > 0 {
var podNames []string
for _, p := range consulPods.Items {
podNames = append(podNames, p.Name)
}
r.Errorf("pods from previous installation still running: %s", strings.Join(podNames, ", "))
}
})

}

// configurePodSecurityPolicies creates a simple pod security policy, a cluster role to allow access to the PSP,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ spec:
command: [ "/bin/sh", "-c", "--" ]
args: [ "while true; do sleep 30; done;" ]
serviceAccountName: static-client
terminationGracePeriodSeconds: 0 # so deletion is quick
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ spec:
- containerPort: 8080
name: http
serviceAccountName: static-server
terminationGracePeriodSeconds: 0 # so deletion is quick

0 comments on commit 21d92f5

Please sign in to comment.