File tree Expand file tree Collapse file tree 5 files changed +70
-8
lines changed Expand file tree Collapse file tree 5 files changed +70
-8
lines changed Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ # Ensure jq is available to parse json output. Installs jq on debian/ubuntu
4
+
5
+ if ! which -s jq ; then
6
+ echo " jq not found, attempting to install"
7
+ if ! sudo apt-get install -y jq ; then
8
+ echo " failed to install jq, ensure it is available before running tests"
9
+ exit 1
10
+ fi
11
+ fi
12
+
13
+ exit 0
Original file line number Diff line number Diff line change 15
15
fi
16
16
17
17
sleep 2s
18
- if ! addresses=$( $KUBECTL_BIN describe endpoints --namespace " $NAMESPACE " | grep " Addresses: " )
18
+ if ! addresses=$( $KUBECTL_BIN get endpointslices -o json --namespace " $NAMESPACE " | \
19
+ jq ' .items[] | select(.metadata.ownerReferences[].name=="e2e-service") | .endpoints[].addresses[0]' 2> /dev/null)
19
20
then
20
21
# no endpoints ready
21
22
continue
22
23
fi
23
24
24
- endpts=$( echo " $addresses " | tr -s " " | cut -f 3 -d " " )
25
-
26
- endpt_count=$( echo " $endpts " | tr ' ,' ' \n' | wc -l | xargs)
25
+ endpt_count=$( echo " $addresses " | wc -l | xargs)
27
26
done
28
27
29
- echo " $endpts "
28
+ echo " $addresses " | tr -d ' " ' | paste -sd " , " -
30
29
exit 0
Original file line number Diff line number Diff line change 2
2
3
3
# Runs the AWS Cloud Map MCS Controller for K8s as a background process and tests services have been exported
4
4
5
- set -eo pipefail
6
-
7
5
source ./integration/scripts/common.sh
8
6
9
7
$KUBECTL_BIN apply -f " $CONFIGS /e2e-deployment.yaml"
10
8
$KUBECTL_BIN apply -f " $CONFIGS /e2e-service.yaml"
11
9
$KUBECTL_BIN apply -f " $CONFIGS /e2e-export.yaml"
12
10
13
- endpts=$( ./integration/scripts/poll-endpoints.sh " $EXPECTED_ENDPOINT_COUNT " )
11
+ if ! endpts=$( ./integration/scripts/poll-endpoints.sh " $EXPECTED_ENDPOINT_COUNT " ) ; then
12
+ exit $?
13
+ fi
14
14
15
15
mkdir -p " $LOGS "
16
16
./bin/manager & > " $LOGS /ctl.log" &
17
17
CTL_PID=$!
18
+ echo " controller PID:$CTL_PID "
18
19
19
20
go run $SCENARIOS /runner/main.go $NAMESPACE $SERVICE $ENDPT_PORT " $endpts "
21
+ exit_code=$?
22
+
23
+ if [ " $exit_code " -eq 0 ] ; then
24
+ ./integration/scripts/test-import.sh " $endpts "
25
+ exit_code=$?
26
+ fi
20
27
28
+ echo " killing controller PID:$CTL_PID "
21
29
kill $CTL_PID
30
+ exit $exit_code
Original file line number Diff line number Diff line change 7
7
8
8
source ./integration/scripts/common.sh
9
9
10
+ ./integration/scripts/ensure-jq.sh
11
+
10
12
$KIND_BIN create cluster --name " $KIND_SHORT " --image " $IMAGE "
11
13
$KUBECTL_BIN config use-context " $CLUSTER "
12
14
$KUBECTL_BIN create namespace " $NAMESPACE "
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ # Test service imports were created during e2e test
4
+
5
+ set -e
6
+
7
+ source ./integration/scripts/common.sh
8
+
9
+ if [ " $# " -ne 1 ]; then
10
+ echo " test script expects endpoint IP list as single argument"
11
+ exit 1
12
+ fi
13
+
14
+ endpts=$1
15
+ echo " checking service imports..."
16
+
17
+ imports=$( $KUBECTL_BIN get endpointslices -o json --namespace $NAMESPACE | \
18
+ jq ' .items[] | select(.metadata.ownerReferences[].name | startswith("imported")) | .endpoints[].addresses[0]' )
19
+ import_count=$( echo " $imports " | wc -l | xargs)
20
+
21
+ if (( import_count != EXPECTED_ENDPOINT_COUNT)) ; then
22
+ echo " expected $EXPECTED_ENDPOINT_COUNT imports but found $import_count "
23
+ exit 1
24
+ fi
25
+
26
+ echo " $imports " | tr -d ' "' | while read -r import; do
27
+ echo " checking import: $import "
28
+ if ! echo " $endpts " | grep -q " $import " ; then
29
+ echo " exported endpoint not found: $import "
30
+ exit 1
31
+ fi
32
+ done
33
+
34
+ if [ $? -ne 0 ]; then
35
+ exit $?
36
+ fi
37
+
38
+ echo " matched all imports to exported endpoints"
39
+ exit 0
You can’t perform that action at this time.
0 commit comments