Skip to content

Commit 81179a5

Browse files
authored
fix: remove comma delimited configs and cleanup test harness (#2477)
1 parent 0d558ec commit 81179a5

File tree

4 files changed

+47
-37
lines changed

4 files changed

+47
-37
lines changed

nodeadm/test/e2e/cases/config-cache/run.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ assert::json-files-equal <(jq .spec /run/eks/nodeadm/config.json) cached-config-
1616

1717
# assert that nodeadm does not crash and should load an existing cache. we dont
1818
# need any phase to go with this because the parsing happens first.
19-
nodeadm init --skip config,run --config-cache /run/eks/nodeadm/config.json
19+
nodeadm init --skip config --skip run --config-cache /run/eks/nodeadm/config.json
2020
assert::json-files-equal <(jq .spec /run/eks/nodeadm/config.json) cached-config-1.json
2121

2222
# trigger changes by writing out a new drop-in
@@ -39,17 +39,17 @@ EOF
3939

4040
# assert that if nodeadm tries to use the drop-in directory without the base
4141
# config from IMDS, then the verification should fail even if we have a cache.
42-
if nodeadm init --skip config,run --config-source file:///etc/eks/nodeadm.d --config-cache /run/eks/nodeadm/config.json; then
42+
if nodeadm init --skip config --skip run --config-source file:///etc/eks/nodeadm.d --config-cache /run/eks/nodeadm/config.json; then
4343
echo "running nodeadm with only a partial drop-in NodeConfig as the source should not work!"
4444
exit 1
4545
fi
4646

4747
# with a fixed config-source, assert that nodeadm generates a new cache config.
48-
nodeadm init --skip config,run --config-source imds://user-data,file:///etc/eks/nodeadm.d --config-cache /run/eks/nodeadm/config.json
48+
nodeadm init --skip config --skip run --config-source imds://user-data --config-source file:///etc/eks/nodeadm.d --config-cache /run/eks/nodeadm/config.json
4949
assert::json-files-equal <(jq .spec /run/eks/nodeadm/config.json) cached-config-2.json
5050

5151
# cleanup the drop-ins, and assert that if no config could be resolved through a
5252
# chain, then the cache should get used (this scenario is ideally for
5353
# nodeadm-run.service using a cached config from nodeadm-config.service).
5454
rm /etc/eks/nodeadm.d/*
55-
nodeadm init --skip config,run --config-source file:///etc/eks/nodeadm.d --config-cache /run/eks/nodeadm/config.json
55+
nodeadm init --skip config --skip run --config-source file:///etc/eks/nodeadm.d --config-cache /run/eks/nodeadm/config.json

nodeadm/test/e2e/cases/config-provider-chain/run.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,3 @@ cp config.yaml $CONFIG_DIR/config.yaml
2020
# assert all forms of inputting the chain are valid
2121
nodeadm init --skip run --config-source file://$CONFIG_DIR
2222
nodeadm init --skip run --config-source file://config.yaml --config-source file://$CONFIG_DIR
23-
nodeadm init --skip run --config-source file://config.yaml,file://$CONFIG_DIR

nodeadm/test/e2e/run.sh

Lines changed: 42 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,11 @@ set -o pipefail
66

77
cd "$(dirname $0)/../.."
88

9-
declare MOUNT_FLAGS=""
109
declare -A MOUNT_TARGETS=(
1110
['nodeadm']=$PWD/_bin/nodeadm
1211
['nodeadm-internal']=$PWD/_bin/nodeadm-internal
1312
)
1413

15-
for binary in "${!MOUNT_TARGETS[@]}"; do
16-
if [ ! -f "${MOUNT_TARGETS[$binary]}" ]; then
17-
echo >&2 "error: you must build nodeadm (run \`make\`) before you can run the e2e tests!"
18-
exit 1
19-
fi
20-
MOUNT_FLAGS+=" -v ${MOUNT_TARGETS[$binary]}:/usr/local/bin/$binary"
21-
done
22-
2314
# build image
2415
printf "🛠️ Building test infra image with containerd v1..."
2516
CONTAINERD_V1_IMAGE=$(docker build -q -f test/e2e/infra/Dockerfile --build-arg CONTAINERD_VERSION=1.7.* .)
@@ -32,47 +23,67 @@ echo "done! Test image with containerd v2: $CONTAINERD_V2_IMAGE"
3223
FAILED="false"
3324

3425
function runTest() {
35-
local case_name=$1
26+
local case_dir=$1
3627
local image=$2
37-
if [[ $image == "$CONTAINERD_V1_IMAGE" ]]; then
38-
printf "🧪 Testing %s with containerd v1 image..." "$case_name"
28+
29+
local case_name
30+
case_name=$(basename "$case_dir")
31+
32+
if [ $image = "$CONTAINERD_V1_IMAGE" ]; then
33+
echo -n "🧪 Testing $case_name with containerd v1 image..."
3934
else
40-
printf "🧪 Testing %s with containerd v2 image..." "$case_name"
35+
echo -n "🧪 Testing $case_name with containerd v2 image..."
4136
fi
4237

43-
# NOTE: we force the mac address of the container to be the one from the
44-
# ec2-metadata-mock to make expectations match.
45-
CONTAINER_ID=$(docker run \
46-
-d \
47-
--rm \
48-
--privileged \
49-
--mac-address 0e:49:61:0f:c3:11 \
50-
$MOUNT_FLAGS \
51-
-v "$PWD/$CASE_DIR":/test-case \
52-
"$image")
53-
54-
LOG_FILE=$(mktemp)
55-
if docker exec "$CONTAINER_ID" bash -c "cd /test-case && ./run.sh" > "$LOG_FILE" 2>&1; then
38+
local workdir=/test-case
39+
local docker_args=(
40+
--detach
41+
--rm
42+
--privileged
43+
# NOTE: we force the mac address of the container to be the one from the
44+
# ec2-metadata-mock to make expectations match.
45+
--mac-address "$(jq -r '.metadata.values.mac' $case_dir/../../infra/aemm-default-config.json)"
46+
--workdir "$workdir"
47+
--volume "$(pwd)/$case_dir:$workdir"
48+
)
49+
50+
for binary in "${!MOUNT_TARGETS[@]}"; do
51+
if [ ! -f "${MOUNT_TARGETS[$binary]}" ]; then
52+
echo >&2 "error: you must build nodeadm (run \`make\`) before you can run the e2e tests!"
53+
exit 1
54+
fi
55+
docker_args+=(--volume "${MOUNT_TARGETS[$binary]}:/usr/local/bin/$binary")
56+
done
57+
58+
local containerd_id
59+
containerd_id=$(docker run "${docker_args[@]}" "$image")
60+
61+
local logfile
62+
logfile=$(mktemp)
63+
64+
if docker exec "$containerd_id" ./run.sh > "$logfile" 2>&1; then
5665
echo "passed! ✅"
5766
else
5867
echo "failed! ❌"
59-
cat "$LOG_FILE"
68+
cat "$logfile"
6069
FAILED="true"
6170
fi
62-
docker kill "$CONTAINER_ID" > /dev/null 2>&1
71+
72+
# killing a container should not take more than 5 seconds.
73+
timeout 5 docker kill "$containerd_id" > /dev/null 2>&1
6374
}
6475

6576
# Run tests
6677
CASE_PREFIX=${1:-}
6778
for CASE_DIR in test/e2e/cases/${CASE_PREFIX}*; do
6879
CASE_NAME=$(basename "$CASE_DIR")
6980
if [[ "$CASE_NAME" == containerdv2-* ]]; then
70-
runTest "$CASE_NAME" "$CONTAINERD_V2_IMAGE"
81+
runTest "$CASE_DIR" "$CONTAINERD_V2_IMAGE"
7182
continue
7283
elif [[ "$CASE_NAME" == containerd-* ]]; then
73-
runTest "$CASE_NAME" "$CONTAINERD_V2_IMAGE"
84+
runTest "$CASE_DIR" "$CONTAINERD_V2_IMAGE"
7485
fi
75-
runTest "$CASE_NAME" "$CONTAINERD_V1_IMAGE"
86+
runTest "$CASE_DIR" "$CONTAINERD_V1_IMAGE"
7687
done
7788

7889
if [ "$FAILED" = "true" ]; then

templates/al2023/runtime/rootfs/etc/systemd/system/nodeadm-run.service

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Requires=nodeadm-config.service
88

99
[Service]
1010
Type=oneshot
11-
ExecStart=/usr/bin/nodeadm init --skip config --config-source imds://user-data,file:///etc/eks/nodeadm.d/ --config-cache /run/eks/nodeadm/config.json
11+
ExecStart=/usr/bin/nodeadm init --skip config --config-source imds://user-data --config-source file:///etc/eks/nodeadm.d/ --config-cache /run/eks/nodeadm/config.json
1212

1313
[Install]
1414
WantedBy=multi-user.target

0 commit comments

Comments
 (0)