Skip to content

Commit 7fc6403

Browse files
Fix parity tests job
1 parent ff5990a commit 7fc6403

3 files changed

Lines changed: 68 additions & 32 deletions

File tree

.github/workflows/release-udmi.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ jobs:
8080
password: ${{ secrets.GITHUB_TOKEN }}
8181
- name: build and push image
8282
run: |
83-
IMAGE_REF="$PUSH_REGISTRY/${GITHUB_REPOSITORY_OWNER,,}/udmi/discoverynode"
83+
IMAGE_REF="$PUSH_REGISTRY/$GITHUB_REPOSITORY_OWNER/udmi/discoverynode"
8484
IMAGE_TAG=${REF_NAME//\//-}
8585
[[ $REF_NAME == master ]] && IMAGE_TAG=latest
8686
./misc/discoverynode/bin/build_container_and_push $IMAGE_REF:$IMAGE_TAG
@@ -111,7 +111,7 @@ jobs:
111111
password: ${{ secrets.GITHUB_TOKEN }}
112112
- name: build and push image
113113
run: |
114-
IMAGE_REF="$PUSH_REGISTRY/${GITHUB_REPOSITORY_OWNER,,}/udmi/spotter"
114+
IMAGE_REF="$PUSH_REGISTRY/$GITHUB_REPOSITORY_OWNER/udmi/spotter"
115115
IMAGE_TAG=${REF_NAME//\//-}
116116
[[ $REF_NAME == master ]] && IMAGE_TAG=latest
117117
docker build -t $IMAGE_REF:$IMAGE_TAG -f edge/spotter/container/Dockerfile .

edge/spotter/bin/run_spotter_tests

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,17 @@ fi
3636

3737
if [[ "$MODE" == "integration" || "$MODE" == "all" ]]; then
3838
SPOTTER_PYTHON="${WORKSPACE_DIR}/edge/spotter/venv/bin/python3"
39-
echo "--- Step 3: Building udmi-spotter:latest Container Image ---"
40-
CONTAINER_ENGINE="docker"
41-
if ! command -v docker >/dev/null 2>&1 && command -v podman >/dev/null 2>&1; then
42-
CONTAINER_ENGINE="podman"
39+
CONTAINER_ENGINE="${CONTAINER_ENGINE:-}"
40+
if [[ -z "${CONTAINER_ENGINE}" ]]; then
41+
if command -v docker >/dev/null 2>&1; then
42+
CONTAINER_ENGINE="docker"
43+
elif command -v podman >/dev/null 2>&1; then
44+
CONTAINER_ENGINE="podman"
45+
else
46+
CONTAINER_ENGINE="docker"
47+
fi
4348
fi
49+
export CONTAINER_ENGINE
4450
${CONTAINER_ENGINE} build -t udmi-spotter:latest -f "${WORKSPACE_DIR}/edge/spotter/container/Dockerfile" "${WORKSPACE_DIR}" >/dev/null
4551

4652
echo "--- Step 4: Running Container Lifecycle Integration Tests (test_container) ---"
@@ -62,7 +68,7 @@ if [[ "$MODE" == "integration" || "$MODE" == "all" ]]; then
6268
"${SCRIPT_DIR}/test_fault_injection"
6369
echo "-- Network Resilience Integration: PASSED!"
6470

65-
if ${CONTAINER_ENGINE} network inspect parity-spotter-net >/dev/null 2>&1 || ${CONTAINER_ENGINE} network create --subnet=192.168.12.0/24 parity-spotter-net >/dev/null 2>&1; then
71+
if ${CONTAINER_ENGINE} network inspect parity-spotter-net >/dev/null 2>&1 || ${CONTAINER_ENGINE} network create --subnet=192.168.12.0/24 --gateway=192.168.12.254 parity-spotter-net >/dev/null 2>&1; then
6672
echo "--- Step 8: Running Discovery Parity Tests (test_parity) ---"
6773
echo "Building legacy discovery node container and simulated BACnet device image..."
6874
"${WORKSPACE_DIR}/misc/discoverynode/bin/build_container" test-discovery_node >/dev/null

edge/spotter/bin/test_parity

Lines changed: 55 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,17 @@ import paho.mqtt.client as mqtt # pylint: disable=g-import-not-at-top
2525
sys.path.insert(0, os.path.join(_workspace_dir, "clientlib/python/src"))
2626
sys.path.insert(0, _workspace_dir)
2727

28-
CONTAINER_ENGINE = os.environ.get("CONTAINER_ENGINE") or (
29-
"podman" if shutil.which("podman") else "docker"
30-
)
28+
def get_container_engine():
29+
if os.environ.get("CONTAINER_ENGINE"):
30+
return os.environ["CONTAINER_ENGINE"]
31+
if shutil.which("docker"):
32+
return "docker"
33+
if shutil.which("podman"):
34+
return "podman"
35+
return "docker"
36+
37+
38+
CONTAINER_ENGINE = get_container_engine()
3139
PARITY_TEST_NUM_DEVICES = int(os.environ.get("PARITY_TEST_NUM_DEVICES", "2"))
3240

3341

@@ -116,17 +124,36 @@ class TestParity(unittest.TestCase):
116124
check=False,
117125
)
118126
if res.returncode != 0:
119-
subprocess.run(
120-
[
121-
CONTAINER_ENGINE,
122-
"network",
123-
"create",
124-
"--subnet=192.168.12.0/24",
125-
"--gateway=192.168.12.254",
126-
"parity-spotter-net",
127-
],
128-
check=True,
129-
)
127+
try:
128+
subprocess.run(
129+
[
130+
CONTAINER_ENGINE,
131+
"network",
132+
"create",
133+
"--subnet=192.168.12.0/24",
134+
"--gateway=192.168.12.254",
135+
"parity-spotter-net",
136+
],
137+
check=True,
138+
)
139+
except subprocess.CalledProcessError:
140+
subprocess.run(
141+
[CONTAINER_ENGINE, "network", "rm", "-f", "parity-spotter-net"],
142+
stdout=subprocess.DEVNULL,
143+
stderr=subprocess.DEVNULL,
144+
check=False,
145+
)
146+
subprocess.run(
147+
[
148+
CONTAINER_ENGINE,
149+
"network",
150+
"create",
151+
"--subnet=192.168.12.0/24",
152+
"--gateway=192.168.12.254",
153+
"parity-spotter-net",
154+
],
155+
check=True,
156+
)
130157

131158
def setUp(self):
132159
# pylint: disable=consider-using-with
@@ -215,17 +242,20 @@ allow_anonymous true
215242
check=False,
216243
)
217244
if res.returncode != 0:
218-
subprocess.run(
219-
[
220-
CONTAINER_ENGINE,
221-
"network",
222-
"create",
223-
"--subnet=192.168.12.0/24",
224-
"--gateway=192.168.12.254",
225-
"parity-spotter-net",
226-
],
227-
check=True,
228-
)
245+
try:
246+
subprocess.run(
247+
[
248+
CONTAINER_ENGINE,
249+
"network",
250+
"create",
251+
"--subnet=192.168.12.0/24",
252+
"--gateway=192.168.12.254",
253+
"parity-spotter-net",
254+
],
255+
check=True,
256+
)
257+
except subprocess.CalledProcessError:
258+
pass
229259

230260
# 4. Start N simulated BACnet devices
231261
self.simulated_devices = []

0 commit comments

Comments
 (0)