Skip to content

Commit 0da8924

Browse files
authored
Fix multi-arch smoke setup and some flaky test (#387)
# Summary This pull request introduces several improvements to CI/CD configuration, test reliability, and scripting. The main changes are the expansion of allowed requesters for certain build variants, enhancements to the authentication test fixtures for better isolation and reliability, and a simplification of the AWS CLI installation script. **Test Improvements:** * Changed test fixtures in `replica_set_scram_sha_256_connectivity.py` from module scope to function scope, ensuring a fresh environment for each test and reducing side effects between tests. * Refactored secret creation and resource loading in authentication tests to use `try_load` and explicit secret management, improving test reliability and clarity. * Removed unnecessary `attempts` parameter from the authentication check in sharded cluster test, simplifying the test logic. * Added "commit" as an allowed requester in several `buildvariants` sections of `.evergreen.yml`, enabling these builds to be triggered on direct commits in addition to patches and GitHub tags. -> i hope that fixes smoke tests to run on master merges * Updated `install_aws_cli_pip()` in `scripts/evergreen/setup_aws.sh` to check if AWS CLI is already installed and working before attempting installation, preventing unnecessary reinstalls. * Simplified the installation process to always use `pip3` and improved error handling and messaging for installation failures. # Proof - green ci - [openshift test passed as well](https://spruce.mongodb.com/version/68b1a0d262980b0007cba112) - ibm worked manually triggered the build: [PATCH](https://spruce.mongodb.com/version/68b195311add1b00074c5d51/tasks?sorts=STATUS%3AASC%3BBASE_STATUS%3ADESC) - in this patch no smoke and ibm stuff is running - after merge ibm stuff is triggered ## Checklist - [x] Have you linked a jira ticket and/or is the ticket in the title? - [x] Have you checked whether your jira ticket required DOCSP changes? - [x] Have you added changelog file? - use `skip-changelog` label if not needed - refer to [Changelog files and Release Notes](https://github.com/mongodb/mongodb-kubernetes/blob/master/CONTRIBUTING.md#changelog-files-and-release-notes) section in CONTRIBUTING.md for more details
1 parent 6b4107d commit 0da8924

File tree

4 files changed

+44
-32
lines changed

4 files changed

+44
-32
lines changed

.evergreen.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,7 +1475,7 @@ buildvariants:
14751475
run_on:
14761476
- rhel9-power-small
14771477
- rhel9-power-large
1478-
allowed_requesters: [ "patch", "github_tag" ]
1478+
allowed_requesters: [ "patch", "github_tag" , "commit"]
14791479
depends_on:
14801480
- name: build_operator_ubi
14811481
variant: init_test_run
@@ -1498,7 +1498,7 @@ buildvariants:
14981498
run_on:
14991499
- rhel9-zseries-small
15001500
- rhel9-zseries-large
1501-
allowed_requesters: [ "patch", "github_tag" ]
1501+
allowed_requesters: [ "patch", "github_tag", "commit"]
15021502
depends_on:
15031503
- name: build_operator_ubi
15041504
variant: init_test_run
@@ -1520,7 +1520,7 @@ buildvariants:
15201520
tags: [ "e2e_test_suite", "e2e_smoke_release_test_suite" ]
15211521
run_on:
15221522
- ubuntu2204-arm64-large
1523-
allowed_requesters: [ "patch", "github_tag" ]
1523+
allowed_requesters: [ "patch", "github_tag", "commit"]
15241524
<<: *base_no_om_image_dependency
15251525
tasks:
15261526
- name: e2e_smoke_arm_task_group
@@ -1530,7 +1530,7 @@ buildvariants:
15301530
tags: [ "e2e_test_suite", "e2e_smoke_release_test_suite", "static" ]
15311531
run_on:
15321532
- ubuntu2204-arm64-large
1533-
allowed_requesters: [ "patch", "github_tag" ]
1533+
allowed_requesters: [ "patch", "github_tag", "commit"]
15341534
<<: *base_no_om_image_dependency
15351535
tasks:
15361536
- name: e2e_smoke_arm_task_group
@@ -1541,7 +1541,7 @@ buildvariants:
15411541
run_on:
15421542
- rhel9-zseries-small
15431543
- rhel9-zseries-large
1544-
allowed_requesters: [ "patch", "github_tag" ]
1544+
allowed_requesters: [ "patch", "github_tag", "commit"]
15451545
depends_on:
15461546
- name: build_operator_ubi
15471547
variant: init_test_run
@@ -1564,7 +1564,7 @@ buildvariants:
15641564
run_on:
15651565
- rhel9-power-small
15661566
- rhel9-power-large
1567-
allowed_requesters: [ "patch", "github_tag" ]
1567+
allowed_requesters: [ "patch", "github_tag", "commit"]
15681568
depends_on:
15691569
- name: build_operator_ubi
15701570
variant: init_test_run

docker/mongodb-kubernetes-tests/tests/authentication/replica_set_scram_sha_256_connectivity.py

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
create_secret,
66
find_fixture,
77
read_secret,
8+
try_load,
89
update_secret,
910
wait_until,
1011
)
@@ -22,7 +23,16 @@
2223
USER_DATABASE = "admin"
2324

2425

25-
@fixture(scope="module")
26+
def create_password_secret(namespace: str) -> str:
27+
create_or_update_secret(
28+
namespace,
29+
PASSWORD_SECRET_NAME,
30+
{"password": USER_PASSWORD},
31+
)
32+
return PASSWORD_SECRET_NAME
33+
34+
35+
@fixture(scope="function")
2636
def replica_set(namespace: str, custom_mdb_version) -> MongoDB:
2737
resource = MongoDB.from_yaml(
2838
find_fixture("replica-set-scram-sha-256.yaml"),
@@ -36,37 +46,33 @@ def replica_set(namespace: str, custom_mdb_version) -> MongoDB:
3646
"enabled": True,
3747
"modes": ["SCRAM"],
3848
}
39-
40-
return resource.update()
49+
try_load(resource)
50+
return resource
4151

4252

43-
@fixture(scope="module")
53+
@fixture(scope="function")
4454
def scram_user(namespace: str) -> MongoDBUser:
4555
resource = MongoDBUser.from_yaml(find_fixture("scram-sha-user.yaml"), namespace=namespace)
4656

47-
create_or_update_secret(
48-
KubernetesTester.get_namespace(),
49-
resource.get_secret_name(),
50-
{"password": USER_PASSWORD},
51-
)
52-
53-
return resource.update()
57+
try_load(resource)
58+
return resource
5459

5560

56-
@fixture(scope="module")
61+
@fixture(scope="function")
5762
def standard_secret(replica_set: MongoDB):
5863
secret_name = "{}-{}-{}".format(replica_set.name, USER_NAME, USER_DATABASE)
5964
return read_secret(replica_set.namespace, secret_name)
6065

6166

62-
@fixture(scope="module")
67+
@fixture(scope="function")
6368
def connection_string_secret(replica_set: MongoDB):
6469
return read_secret(replica_set.namespace, CONNECTION_STRING_SECRET_NAME)
6570

6671

6772
@mark.e2e_replica_set_scram_sha_256_user_connectivity
6873
class TestReplicaSetCreation(KubernetesTester):
6974
def test_replica_set_created(self, replica_set: MongoDB):
75+
replica_set.update()
7076
replica_set.assert_reaches_phase(Phase.Running, timeout=400)
7177

7278
def test_replica_set_connectivity(self, replica_set: MongoDB):
@@ -82,7 +88,9 @@ def test_ops_manager_state_correctly_updated(self, replica_set: MongoDB):
8288

8389

8490
@mark.e2e_replica_set_scram_sha_256_user_connectivity
85-
def test_create_user(scram_user: MongoDBUser):
91+
def test_create_user(scram_user: MongoDBUser, namespace: str):
92+
create_password_secret(namespace)
93+
scram_user.update()
8694
scram_user.assert_reaches_phase(Phase.Updated)
8795

8896

@@ -125,9 +133,15 @@ def test_user_cannot_authenticate_with_incorrect_password(self, replica_set: Mon
125133
@mark.e2e_replica_set_scram_sha_256_user_connectivity
126134
class TestCanChangePassword(KubernetesTester):
127135
def test_user_can_authenticate_with_new_password(self, namespace: str, replica_set: MongoDB):
128-
update_secret(namespace, PASSWORD_SECRET_NAME, {"password": "my-new-password7"})
136+
ac_version = replica_set.get_automation_config_tester().automation_config["version"]
137+
138+
new_password = "my-new-password7"
139+
update_secret(namespace, PASSWORD_SECRET_NAME, {"password": new_password})
140+
141+
wait_until(lambda: replica_set.get_automation_config_tester().reached_version(ac_version + 1), timeout=800)
142+
129143
replica_set.tester().assert_scram_sha_authentication(
130-
password="my-new-password7",
144+
password=new_password,
131145
username="mms-user-1",
132146
auth_mechanism="SCRAM-SHA-256",
133147
)

docker/mongodb-kubernetes-tests/tests/authentication/sharded_cluster_scram_sha_256_connectivity.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ def test_user_can_authenticate_with_new_password(self):
117117
password="my-new-password",
118118
username="mms-user-1",
119119
auth_mechanism="SCRAM-SHA-256",
120-
attempts=20,
121120
)
122121

123122
def test_user_cannot_authenticate_with_old_password(self):

scripts/evergreen/setup_aws.sh

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ install_aws_cli_pip() {
4848
return 1
4949
fi
5050

51-
# Use pip3 if available, otherwise pip
52-
local pip_cmd="pip3"
53-
if ! command -v pip3 &> /dev/null; then
54-
pip_cmd="pip"
51+
# Check if AWS CLI exists and works before installing
52+
if command -v aws &> /dev/null && aws --version &> /dev/null 2>&1; then
53+
echo "AWS CLI is already installed and working"
54+
return 0
5555
fi
5656

57-
echo "Installing AWS CLI using ${pip_cmd}..."
58-
${pip_cmd} install --user awscli
57+
echo "Installing AWS CLI using pip3..."
58+
pip3 install --user awscli
5959

6060
# Add ~/.local/bin to PATH if not already there (where pip --user installs)
6161
if [[ ":${PATH}:" != *":${HOME}/.local/bin:"* ]]; then
@@ -65,10 +65,9 @@ install_aws_cli_pip() {
6565

6666
# Verify installation
6767
if command -v aws &> /dev/null; then
68-
echo "AWS CLI v1 installed successfully:"
69-
aws --version
68+
echo "AWS CLI v1 installed successfully"
7069
else
71-
echo "Error: AWS CLI v1 installation failed or not found in PATH" >&2
70+
echo "Error: AWS CLI v1 installation failed" >&2
7271
return 1
7372
fi
7473
}

0 commit comments

Comments
 (0)