Skip to content

Commit 4a928ee

Browse files
authored
CLOUDP-101199: Improve Flakiness of Cloud Manager tests in MongoCLI (#880)
1 parent 4b1f147 commit 4a928ee

File tree

3 files changed

+121
-12
lines changed

3 files changed

+121
-12
lines changed

build/ci/clean-up-cloud-manager.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
# Copyright 2021 MongoDB Inc
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -euo pipefail
18+
19+
# shellcheck disable=SC1091
20+
source project.sh
21+
22+
mongocli iam projects remove "$MCLI_PROJECT_ID"

build/ci/evergreen.yml

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,39 @@ functions:
175175
args: ['-h', 'hosts.json']
176176
env:
177177
XDG_CONFIG_HOME: ${workdir}
178+
"set-up cloud manager":
179+
- command: subprocess.exec
180+
type: setup
181+
params:
182+
add_to_path:
183+
- ${go_bin}
184+
- ../../bin
185+
working_dir: src/github.com/mongodb/mongocli/build/ci
186+
include_expansions_in_env:
187+
- cloud_manager_service
188+
- revision
189+
binary: ./set-up-cloud-manager.sh
190+
args: ['-h', 'hosts.json']
191+
env:
192+
XDG_CONFIG_HOME: ${workdir}
193+
MCLI_ORG_ID: ${cloud_manager_org_id}
194+
MCLI_PROJECT_ID: ${cloud_manager_project_id}
195+
MCLI_PRIVATE_API_KEY: ${cloud_manager_private_api_key}
196+
MCLI_PUBLIC_API_KEY: ${cloud_manager_public_api_key}
197+
MCLI_OPS_MANAGER_URL: ${mcli_ops_manager_url}
198+
MCLI_SERVICE: cloud-manager
199+
"clean-up cloud manager":
200+
- command: subprocess.exec
201+
type: setup
202+
params:
203+
add_to_path:
204+
- ${go_bin}
205+
- ../../bin
206+
working_dir: src/github.com/mongodb/mongocli/build/ci
207+
binary: ./clean-up-cloud-manager.sh
208+
args: ['-h', 'hosts.json']
209+
env:
210+
XDG_CONFIG_HOME: ${workdir}
178211
"lint":
179212
- command: shell.exec
180213
type: test
@@ -1073,18 +1106,15 @@ tasks:
10731106
commands:
10741107
- func: "clone"
10751108
- func: "install gotestsum"
1109+
- func: "build"
10761110
- func: "deploy spawn host"
10771111
- func: ssh-ready
1112+
- func: "set-up cloud manager"
10781113
- func: "install automation agent"
10791114
- func: "e2e test"
10801115
vars:
1081-
MCLI_ORG_ID: ${cloud_manager_org_id}
1082-
MCLI_PROJECT_ID: ${cloud_manager_project_id}
1083-
MCLI_PRIVATE_API_KEY: ${cloud_manager_private_api_key}
1084-
MCLI_PUBLIC_API_KEY: ${cloud_manager_public_api_key}
1085-
MCLI_OPS_MANAGER_URL: ${mcli_ops_manager_url}
1086-
MCLI_SERVICE: cloud-manager
10871116
E2E_TAGS: cloudmanager,remote,replica
1117+
- func: "clean-up cloud manager"
10881118
# Deploy a sharded cluster, we need to be careful on running parallel modifications to the automation config
10891119
- name: cloud_manager_deploy_sharded_cluster_e2e
10901120
tags: ["e2e","clusters","cloudmanager"]
@@ -1098,18 +1128,15 @@ tasks:
10981128
commands:
10991129
- func: "clone"
11001130
- func: "install gotestsum"
1131+
- func: "build"
11011132
- func: "deploy spawn host"
11021133
- func: ssh-ready
1134+
- func: "set-up cloud manager"
11031135
- func: "install automation agent"
11041136
- func: "e2e test"
11051137
vars:
1106-
MCLI_ORG_ID: ${cloud_manager_org_id}
1107-
MCLI_PROJECT_ID: ${cloud_manager_project_id}
1108-
MCLI_PRIVATE_API_KEY: ${cloud_manager_private_api_key}
1109-
MCLI_PUBLIC_API_KEY: ${cloud_manager_public_api_key}
1110-
MCLI_OPS_MANAGER_URL: ${mcli_ops_manager_url}
1111-
MCLI_SERVICE: cloud-manager
11121138
E2E_TAGS: cloudmanager,remote,sharded
1139+
- func: "clean-up cloud manager"
11131140
# Deploy ops manager and test against it
11141141
- name: ops_manager_4_4_generic_e2e
11151142
tags: [ "e2e","ops-manager-44" ]

build/ci/set-up-cloud-manager.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/bash
2+
3+
# Copyright 2021 MongoDB Inc
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -euo pipefail
18+
19+
export MCLI_SERVICE="${cloud_manager_service:?}"
20+
21+
cat <<EOF > "${XDG_CONFIG_HOME}/mongocli.toml"
22+
skip_update_check = true
23+
[default]
24+
service = "${MCLI_SERVICE}"
25+
public_api_key = "${MCLI_PUBLIC_API_KEY}"
26+
private_api_key = "${MCLI_PRIVATE_API_KEY}"
27+
org_id = "${MCLI_ORG_ID}"
28+
ops_manager_url = "${MCLI_OPS_MANAGER_URL}"
29+
30+
EOF
31+
32+
33+
echo "create project"
34+
35+
cat <<EOF > project.tmpl
36+
#!/bin/bash
37+
38+
set -euo pipefail
39+
40+
export AGENT_API_KEY="{{.AgentAPIKey}}"
41+
export MCLI_PROJECT_ID="{{.ID}}"
42+
EOF
43+
44+
# shellcheck disable=SC2154
45+
GROUP_NAME="cloudManager-e2e-$((1 + RANDOM % 1000))-$revision"
46+
mongocli iam projects create "$GROUP_NAME" -o="go-template-file=project.tmpl" > project.sh
47+
48+
chmod +x project.sh
49+
50+
# shellcheck disable=SC1091
51+
source project.sh
52+
53+
mongocli config set project_id "$MCLI_PROJECT_ID"
54+
55+
cat <<EOF > automation_agent_settings.sh
56+
export BASE_URL=${MCLI_OPS_MANAGER_URL}
57+
export LC_AGENT_KEY=${AGENT_API_KEY}
58+
export LC_GROUP_ID=${MCLI_PROJECT_ID}
59+
export MCLI_SERVICE=${MCLI_SERVICE}
60+
EOF

0 commit comments

Comments
 (0)