From a19322d57558a0432430323ba795b14b7943a48e Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Tue, 4 Apr 2023 15:32:01 +0100 Subject: [PATCH] Moved 'WaitForNodesExcludingSelectedStandbys' to shared testhelpers file (#19976) --- .github/workflows/build-vault-oss.yml | 2 +- helper/testhelpers/testhelpers.go | 31 +++++++++++++++++++++++++++ helper/testhelpers/testhelpers_oss.go | 31 --------------------------- ui/.nvmrc | 2 +- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/.github/workflows/build-vault-oss.yml b/.github/workflows/build-vault-oss.yml index 0ba21db59999..0c3197e2aaeb 100644 --- a/.github/workflows/build-vault-oss.yml +++ b/.github/workflows/build-vault-oss.yml @@ -47,7 +47,7 @@ jobs: - name: Set up node and yarn uses: actions/setup-node@v3 with: - node-version: 14 + node-version: 16 cache: yarn cache-dependency-path: ui/yarn.lock - name: Build UI diff --git a/helper/testhelpers/testhelpers.go b/helper/testhelpers/testhelpers.go index c2d437abf279..2707845682b6 100644 --- a/helper/testhelpers/testhelpers.go +++ b/helper/testhelpers/testhelpers.go @@ -1003,3 +1003,34 @@ func SkipUnlessEnvVarsSet(t testing.T, envVars []string) { } } } + +// WaitForNodesExcludingSelectedStandbys is variation on WaitForActiveNodeAndStandbys. +// It waits for the active node before waiting for standby nodes, however +// it will not wait for cores with indexes that match those specified as arguments. +// Whilst you could specify index 0 which is likely to be the leader node, the function +// checks for the leader first regardless of the indexes to skip, so it would be redundant to do so. +// The intention/use case for this function is to allow a cluster to start and become active with one +// or more nodes not joined, so that we can test scenarios where a node joins later. +// e.g. 4 nodes in the cluster, only 3 nodes in cluster 'active', 1 node can be joined later in tests. +func WaitForNodesExcludingSelectedStandbys(t testing.T, cluster *vault.TestCluster, indexesToSkip ...int) { + WaitForActiveNode(t, cluster) + + contains := func(elems []int, e int) bool { + for _, v := range elems { + if v == e { + return true + } + } + + return false + } + for i, core := range cluster.Cores { + if contains(indexesToSkip, i) { + continue + } + + if standby, _ := core.Core.Standby(); standby { + WaitForStandbyNode(t, core) + } + } +} diff --git a/helper/testhelpers/testhelpers_oss.go b/helper/testhelpers/testhelpers_oss.go index cf1459a63da9..fc55e9b52c73 100644 --- a/helper/testhelpers/testhelpers_oss.go +++ b/helper/testhelpers/testhelpers_oss.go @@ -20,34 +20,3 @@ func WaitForActiveNodeAndStandbys(t testing.T, cluster *vault.TestCluster) { } } } - -// WaitForNodesExcludingSelectedStandbys is variation on WaitForActiveNodeAndStandbys. -// It waits for the active node before waiting for standby nodes, however -// it will not wait for cores with indexes that match those specified as arguments. -// Whilst you could specify index 0 which is likely to be the leader node, the function -// checks for the leader first regardless of the indexes to skip, so it would be redundant to do so. -// The intention/use case for this function is to allow a cluster to start and become active with one -// or more nodes not joined, so that we can test scenarios where a node joins later. -// e.g. 4 nodes in the cluster, only 3 nodes in cluster 'active', 1 node can be joined later in tests. -func WaitForNodesExcludingSelectedStandbys(t testing.T, cluster *vault.TestCluster, indexesToSkip ...int) { - WaitForActiveNode(t, cluster) - - contains := func(elems []int, e int) bool { - for _, v := range elems { - if v == e { - return true - } - } - - return false - } - for i, core := range cluster.Cores { - if contains(indexesToSkip, i) { - continue - } - - if standby, _ := core.Core.Standby(); standby { - WaitForStandbyNode(t, core) - } - } -} diff --git a/ui/.nvmrc b/ui/.nvmrc index 958b5a36e1fa..6f7f377bf514 100644 --- a/ui/.nvmrc +++ b/ui/.nvmrc @@ -1 +1 @@ -v14 +v16