diff --git a/.github/workflows/cirque.yaml b/.github/workflows/cirque.yaml new file mode 100644 index 00000000000000..6d016dd0b0e794 --- /dev/null +++ b/.github/workflows/cirque.yaml @@ -0,0 +1,130 @@ +# Copyright (c) 2020-2023 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: Cirque + +on: + push: + pull_request: + merge_group: + workflow_dispatch: + +concurrency: + group: ${{ github.ref }}-${{ github.workflow }}-${{ (github.event_name == 'pull_request' && github.event.number) || (github.event_name == 'workflow_dispatch' && github.run_number) || github.sha }} + cancel-in-progress: true + +env: + CHIP_NO_LOG_TIMESTAMPS: true + +jobs: + cirque: + name: Cirque + + env: + GITHUB_CACHE_PATH: /tmp/cirque-cache + + runs-on: ubuntu-latest + if: github.actor != 'restyled-io[bot]' + + # need to run with privilege, which isn't supported by job.XXX.contaner + # https://github.com/actions/container-action/issues/2 + # container: + # image: ghcr.io/project-chip/chip-build-cirque:0.8 + # volumes: + # - "/tmp:/tmp" + # - "/dev/pts:/dev/pts" + # env: + # LOG_DIR: /tmp/cirque_test_output/ + # CLEANUP_DOCKER_FOR_CI: 1 + # options: "--privileged" + + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Checkout submodules + uses: ./.github/actions/checkout-submodules + with: + platform: linux + + - name: Bootstrap Cache + uses: ./.github/actions/bootstrap-cache + - name: Bootstrap Cirque + run: | + integrations/docker/images/stage-2/chip-build-cirque/run.sh \ + -- sh -c " \ + git config --global --add safe.directory '*' \ + && bash scripts/bootstrap.sh \ + && chown -R $(id -u):$(id -g) .environment \ + " + + - name: Get Cirque Bootstrap cache key + id: cirque-bootstrap-cache-key + run: echo "val=$(scripts/tests/cirque_tests.sh cachekeyhash)" >> $GITHUB_OUTPUT + - uses: Wandalen/wretry.action@v1.3.0 + name: Cirque Bootstrap cache + if: ${{ !env.ACT }} + continue-on-error: true + timeout-minutes: 10 + with: + action: buildjet/cache@v3 + attempt_limit: 3 + attempt_delay: 2000 + with: | + key: ${{ runner.os }}-cirque-${{ steps.cirque-bootstrap-cache-key.outputs.val }} + restore-keys: ${{ runner.os }}-cirque- + path: ${{ env.GITHUB_CACHE_PATH }} + - name: Cirque Bootstrap + run: | + integrations/docker/images/stage-2/chip-build-cirque/run.sh \ + --env GITHUB_ACTION_RUN=1 \ + --env GITHUB_CACHE_PATH=${{ env.GITHUB_CACHE_PATH }} \ + --volume /tmp:/tmp \ + -- scripts/tests/cirque_tests.sh bootstrap + + - name: Artifact suffix + id: outsuffix + uses: haya14busa/action-cond@v1 + if: ${{ !env.ACT }} + with: + cond: ${{ github.event.pull_request.number == '' }} + if_true: "${{ github.sha }}" + if_false: "pull-${{ github.event.pull_request.number }}" + - name: Build Binaries + run: | + integrations/docker/images/stage-2/chip-build-cirque/run.sh \ + -- sh -c " \ + git config --global --add safe.directory '*' \ + && scripts/build/gn_gen_cirque.sh \ + " + - name: Run Tests + run: | + integrations/docker/images/stage-2/chip-build-cirque/run.sh \ + --env LOG_DIR=/tmp/cirque_test_output \ + --env CLEANUP_DOCKER_FOR_CI=1 \ + --env GITHUB_ACTION_RUN=1 \ + --privileged \ + --volume /tmp:/tmp \ + --volume /dev/pts:/dev/pts \ + -- sh -c " \ + git config --global --add safe.directory '*' \ + && scripts/tests/cirque_tests.sh run_all_tests \ + " + + + - name: Uploading Binaries + uses: actions/upload-artifact@v3 + if: ${{ always() && !env.ACT }} + with: + name: cirque_log-${{steps.outsuffix.outputs.value}}-logs + path: /tmp/cirque_test_output/ diff --git a/integrations/docker/images/stage-2/chip-build-cirque/Dockerfile b/integrations/docker/images/stage-2/chip-build-cirque/Dockerfile new file mode 100644 index 00000000000000..1f10e8eae866d2 --- /dev/null +++ b/integrations/docker/images/stage-2/chip-build-cirque/Dockerfile @@ -0,0 +1,46 @@ +ARG VERSION=latest +FROM ghcr.io/project-chip/chip-build:${VERSION} +LABEL org.opencontainers.image.source https://github.com/project-chip/connectedhomeip + +# Bazel +RUN set -x \ + && apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -fy \ + curl gnupg \ + && curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel.gpg \ + && mv bazel.gpg /etc/apt/trusted.gpg.d/ \ + && echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list \ + && apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -fy \ + bazel \ + && : # aids diffs + +# Docker +RUN set -x \ + && apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -fy \ + curl gnupg-agent apt-transport-https ca-certificates \ + software-properties-common \ + && curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - \ + && python3.8 `which add-apt-repository` \ + "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \ + && apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -fy \ + docker-ce docker-ce-cli containerd.io \ + && : # aids diffs + +# Other Cirque prereqs +RUN set -x \ + && apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -fy \ + sudo socat psmisc tigervnc-standalone-server xorg xauth \ + python3-pip python3-venv libdbus-glib-1-dev \ + uuid-runtime libgirepository1.0-dev \ + && : # aids diffs + +COPY requirements_nogrpc.txt /requirements.txt + +RUN set -x \ + && pip3 install -r requirements.txt \ + && xinit -- /usr/bin/Xvnc \ + && : # aids diffs diff --git a/integrations/docker/images/stage-2/chip-build-cirque/README.md b/integrations/docker/images/stage-2/chip-build-cirque/README.md new file mode 100644 index 00000000000000..304deab5350a2f --- /dev/null +++ b/integrations/docker/images/stage-2/chip-build-cirque/README.md @@ -0,0 +1,36 @@ +# Docker connectedhomeip:chip-build-cirque + +project-chip/chip-build-cirque is the name of the Docker image used by CHIP for +continuous integration and other builds when using Cirque. It builds upon the +chip-build image and adds system dependencies needed by Cirque. + +Contents of this directory: + +- build.sh - utility for building (and optionally) tagging and pushing the + chip-build Docker image +- version - the semver-style version of the image in use for this branch of + CHIP +- Dockerfile - description of the image + +Please update version when any required tooling is updated. Some rough +guidelines: + +- Updating a tool? Increment dot version unless the tool has a major version + delta or a backward incompatibility +- Adding a tool? Increment minor version: e.g. 0.2.1 -> 0.3.0 +- Removing a tool? Increment major version: e.g. 1.2 -> 2.0 + +Note, you must have privileged access to the connectedhomeip area on Docker Hub +to push the image. + +Typical use: + +1. new build tool dependency identified +2. add tool to Dockerfile +3. update version +4. `$ ./build.sh`, which installs the image locally as the new version +5. update the image version in the devcontainer.json and CI manifests +6. verify that the build works locally in the new image +7. `$ docker login` +8. `$ ./build.sh --push --latest`, _*Note:*_ omit `--latest` unless on the + master branch diff --git a/integrations/docker/images/stage-2/chip-build-cirque/build.sh b/integrations/docker/images/stage-2/chip-build-cirque/build.sh new file mode 120000 index 00000000000000..46b20313461454 --- /dev/null +++ b/integrations/docker/images/stage-2/chip-build-cirque/build.sh @@ -0,0 +1 @@ +../../../build.sh \ No newline at end of file diff --git a/integrations/docker/images/stage-2/chip-build-cirque/requirements_nogrpc.txt b/integrations/docker/images/stage-2/chip-build-cirque/requirements_nogrpc.txt new file mode 100644 index 00000000000000..508ad6d8ddef61 --- /dev/null +++ b/integrations/docker/images/stage-2/chip-build-cirque/requirements_nogrpc.txt @@ -0,0 +1,8 @@ +cmd2 +docker >= 4.1.0 +flask == 2.2.2 +pycodestyle >= 2.5.0 +pylint == 2.4 +pyroute2 >= 0.5.7 +six >= 1.12 +toml diff --git a/integrations/docker/images/stage-2/chip-build-cirque/run.sh b/integrations/docker/images/stage-2/chip-build-cirque/run.sh new file mode 120000 index 00000000000000..9bbfad86d46e50 --- /dev/null +++ b/integrations/docker/images/stage-2/chip-build-cirque/run.sh @@ -0,0 +1 @@ +../../../run.sh \ No newline at end of file diff --git a/integrations/docker/images/stage-2/chip-build-cirque/version b/integrations/docker/images/stage-2/chip-build-cirque/version new file mode 120000 index 00000000000000..a40ba48b0188a8 --- /dev/null +++ b/integrations/docker/images/stage-2/chip-build-cirque/version @@ -0,0 +1 @@ +../../base/chip-build/version \ No newline at end of file diff --git a/integrations/docker/images/stage-2/chip-cirque-device-base/CHIPCirqueDaemon.py b/integrations/docker/images/stage-2/chip-cirque-device-base/CHIPCirqueDaemon.py new file mode 100755 index 00000000000000..a96868a4593c67 --- /dev/null +++ b/integrations/docker/images/stage-2/chip-cirque-device-base/CHIPCirqueDaemon.py @@ -0,0 +1,138 @@ +#!/usr/bin/env python3 + +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import logging +import subprocess +import sys +import time +from dataclasses import dataclass +from enum import Enum +from multiprocessing.connection import Client, Listener +from pathlib import Path + +import click + +log = logging.getLogger() +log.setLevel(logging.DEBUG) + +sh = logging.StreamHandler() +sh.setFormatter( + logging.Formatter( + '%(asctime)s [%(name)s] %(levelname)s %(message)s')) +log.addHandler(sh) + + +class CommandStatus(Enum): + """Enum class for passing status code of execute CirqueDaemon command, not CHIP error codes.""" + SUCCESS = 0 + FAILURE = 1 + UNKNOWN_COMMAND = 2 + INVALID_ARGUMENT = 3 + + +@dataclass +class CommandResponse: + """Class for holding status of running CirqueDaemon commands.""" + status_code: CommandStatus + error_message: str = "" + + +class ShellCommand: + def __init__(self, args=None): + self._args = args + + def __call__(self): + if not self._args: + return CommandResponse(CommandStatus.INVALID_ARGUMENT, "Cannot spwan background process") + log.info("Will run command: {}".format(self._args)) + try: + # As the command will be execued in background, we won't return the exit code of the program. + subprocess.Popen( + self._args, stdout=sys.stdout, stderr=sys.stderr) + return CommandResponse(CommandStatus.SUCCESS) + except Exception as ex: + return CommandResponse(CommandStatus.FAILURE, "Failed to run command: {}".format(ex)) + + +class InvalidCommand: + def __init__(self, args=None): + self._args = args + + def __call__(self): + return CommandResponse(CommandStatus.FAILURE, "invalid command") + + +SERVER_ADDRESS = "/tmp/cirque-helper.socket" +CLIENT_WAIT_TIMEOUT_SECONDS = 5 + + +def CommandFactory(args): + commands = { + "run": ShellCommand + } + if len(args) == 0: + return InvalidCommand() + return commands.get(args[0], InvalidCommand)(args[1:]) + + +def ServerMain(args): + extraOptions = { + "otbr-agent": ShellCommand(["otbr-agent", "-I", "wpan0", "-B", "eth0", "spinel+hdlc+uart:///dev/ttyUSB0"]) + } + + with Listener(SERVER_ADDRESS) as listener: + log.info("Server running on {}".format(SERVER_ADDRESS)) + for extraOption in args: + cmd = extraOptions.get(extraOption, InvalidCommand()) + cmd() + + while True: + with listener.accept() as conn: + log.info("Received connection") + cmd = CommandFactory(conn.recv()) + conn.send(cmd()) + + +def ClientMain(args): + if len(args) == 0: + sys.exit(1) + # The server may start very slowly, wait for a few seconds to see if the server will start. + for _ in range(CLIENT_WAIT_TIMEOUT_SECONDS): + socks = Path(SERVER_ADDRESS) + if socks.exists(): + break + time.sleep(1) + # If the address does not exist, Client constructor will throw an exception, so no need to add a flag. + with Client(SERVER_ADDRESS) as conn: + conn.send(args) + res = conn.recv() + print(res) + if res.status_code != CommandStatus.SUCCESS: + sys.exit(1) + + +@click.command() +@click.option('--server', is_flag=True) +@click.argument('command', nargs=-1) +def main(server, command): + if server: + ServerMain(command) + else: + ClientMain(command) + + +if __name__ == '__main__': + main() diff --git a/integrations/docker/images/stage-2/chip-cirque-device-base/Dockerfile b/integrations/docker/images/stage-2/chip-cirque-device-base/Dockerfile new file mode 100644 index 00000000000000..d7f7538e484e40 --- /dev/null +++ b/integrations/docker/images/stage-2/chip-cirque-device-base/Dockerfile @@ -0,0 +1,67 @@ +FROM ubuntu:focal + +ARG OT_BR_POSIX_CHECKOUT=main + +ENV DEBIAN_FRONTEND noninteractive +ENV PLATFORM ubuntu +ENV DOCKER 1 +ENV OT_BR_POSIX_CHECKOUT=${OT_BR_POSIX_CHECKOUT} + +RUN mkdir /app + +WORKDIR /app + +RUN apt-cache policy + +# TODO: Use multi stage build for smaller image size. +RUN apt-get update \ + && apt-get install --no-install-recommends -y \ + avahi-daemon \ + avahi-utils \ + ca-certificates \ + dhcpcd5 \ + gdb \ + git \ + iproute2 \ + libavahi-client3 \ + libcairo2-dev \ + libdbus-1-dev \ + libgif-dev \ + libgirepository1.0-dev \ + libglib2.0-dev \ + libjpeg-dev \ + psmisc \ + python3-dev \ + python3-pip \ + python3 \ + sudo \ + wireless-tools \ + wpasupplicant \ + && ln -fs /usr/share/zoneinfo/UTC /etc/localtime \ + && (mkdir ot-br-posix \ + && cd ot-br-posix \ + && git init \ + && git remote add origin https://github.com/openthread/ot-br-posix \ + && git fetch origin $OT_BR_POSIX_CHECKOUT --depth=1 \ + && git reset --hard FETCH_HEAD \ + && git submodule update --init --depth=1 \ + && ./script/bootstrap \ + && ./script/setup)\ + && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \ + git psmisc ninja-build cmake wget libreadline-dev libncurses-dev libcpputest-dev \ + libavahi-common-dev libavahi-client-dev libboost-dev libboost-filesystem-dev \ + libboost-system-dev libjsoncpp-dev libnetfilter-queue-dev cmake cpputest doxygen \ + && mkdir -p /etc/wpa_supplicant \ + && echo "ctrl_interface=/run/wpa_supplicant" >> /etc/wpa_supplicant/wpa_supplicant.conf \ + && echo "update_config=1" >> /etc/wpa_supplicant/wpa_supplicant.conf \ + && rm -rf /var/lib/apt/lists/* \ + && pip3 install --no-cache-dir click==8.0.3 + +COPY CHIPCirqueDaemon.py /bin/CHIPCirqueDaemon.py +COPY entrypoint.sh /opt/entrypoint.sh + +WORKDIR / + +ENTRYPOINT ["/opt/entrypoint.sh"] + +EXPOSE 80 diff --git a/integrations/docker/images/stage-2/chip-cirque-device-base/build.sh b/integrations/docker/images/stage-2/chip-cirque-device-base/build.sh new file mode 120000 index 00000000000000..46b20313461454 --- /dev/null +++ b/integrations/docker/images/stage-2/chip-cirque-device-base/build.sh @@ -0,0 +1 @@ +../../../build.sh \ No newline at end of file diff --git a/integrations/docker/images/stage-2/chip-cirque-device-base/cachekey.sh b/integrations/docker/images/stage-2/chip-cirque-device-base/cachekey.sh new file mode 100755 index 00000000000000..4e5c754538a5f0 --- /dev/null +++ b/integrations/docker/images/stage-2/chip-cirque-device-base/cachekey.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +# +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# build.sh - utility for building (and optionally) tagging and pushing +# the a Docker image +# +# This script expects to output a string that can be used to identify one image. + +me=$(basename "$0") +cd "$(dirname "$0")" + +SOURCE=${BASH_SOURCE[0]} +SOURCE_DIR=$(cd "$(dirname "$SOURCE")" >/dev/null 2>&1 && pwd) +REPO_DIR="$SOURCE_DIR/../../../../" + +# The image build will clone its own ot-br-posix checkout due to limitations of git submodule. +# Using the same ot-br-posix version as chip +OT_BR_POSIX=$REPO_DIR/third_party/ot-br-posix/repo +OT_BR_POSIX_CHECKOUT=$(cd "$REPO_DIR" && git rev-parse :third_party/ot-br-posix/repo) + +filehash() { + shasum "$1" | awk '{ print $1 }' +} + +echo "ot-br-posix.$OT_BR_POSIX_CHECKOUT.dockerfile.$(filehash ./Dockerfile)" diff --git a/integrations/docker/images/stage-2/chip-cirque-device-base/entrypoint.sh b/integrations/docker/images/stage-2/chip-cirque-device-base/entrypoint.sh new file mode 100755 index 00000000000000..a0235ee1e7dd81 --- /dev/null +++ b/integrations/docker/images/stage-2/chip-cirque-device-base/entrypoint.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +# +# Copyright (c) 2021 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +service dbus start +service avahi-daemon start +/bin/CHIPCirqueDaemon.py --server otbr-agent diff --git a/integrations/docker/images/stage-2/chip-cirque-device-base/run.sh b/integrations/docker/images/stage-2/chip-cirque-device-base/run.sh new file mode 120000 index 00000000000000..9bbfad86d46e50 --- /dev/null +++ b/integrations/docker/images/stage-2/chip-cirque-device-base/run.sh @@ -0,0 +1 @@ +../../../run.sh \ No newline at end of file diff --git a/integrations/docker/images/stage-2/chip-cirque-device-base/version b/integrations/docker/images/stage-2/chip-cirque-device-base/version new file mode 100644 index 00000000000000..3dc85ada5e1cf0 --- /dev/null +++ b/integrations/docker/images/stage-2/chip-cirque-device-base/version @@ -0,0 +1 @@ +latest : This image tracks the version of ot-br-posix in the CHIP repo. diff --git a/scripts/tests/cirque_tests.sh b/scripts/tests/cirque_tests.sh index 4796ecd2bffbd5..d3d988fd1e515d 100755 --- a/scripts/tests/cirque_tests.sh +++ b/scripts/tests/cirque_tests.sh @@ -30,6 +30,7 @@ GITHUB_ACTION_RUN=${GITHUB_ACTION_RUN:-"0"} # Using the same ot-br-posix version as chip OPENTHREAD=$REPO_DIR/third_party/openthread/repo OPENTHREAD_CHECKOUT=$(cd "$REPO_DIR" && git rev-parse :third_party/openthread/repo) +OT_BR_POSIX_CHECKOUT=$(cd "$REPO_DIR" && git rev-parse :third_party/ot-br-posix/repo) CIRQUE_CACHE_PATH=${GITHUB_CACHE_PATH:-"/tmp/cirque-cache/"} OT_SIMULATION_CACHE="$CIRQUE_CACHE_PATH/ot-simulation-cmake.tgz" @@ -118,7 +119,7 @@ function cirquetest_bootstrap() { git config --global --add safe.directory /home/runner/work/connectedhomeip/connectedhomeip - "$REPO_DIR"/integrations/docker/images/stage-2/chip-cirque-device-base/build.sh + "$REPO_DIR"/integrations/docker/images/stage-2/chip-cirque-device-base/build.sh --build-arg OT_BR_POSIX_CHECKOUT="$OT_BR_POSIX_CHECKOUT" __cirquetest_build_ot_lazy pip3 install -r requirements_nogrpc.txt @@ -132,7 +133,7 @@ function cirquetest_run_test() { mkdir -p "$DEVICE_LOG_DIR" __cirquetest_start_flask sleep 5 - "$TEST_DIR/$CURRENT_TEST.py" "$@" + CHIP_CIRQUE_BASE_IMAGE="ghcr.io/project-chip/chip-cirque-device-base" "$TEST_DIR/$CURRENT_TEST.py" "$@" exitcode=$? __cirquetest_clean_flask # TODO: Do docker system prune, we cannot filter which container diff --git a/src/platform/Linux/ThreadStackManagerImpl.cpp b/src/platform/Linux/ThreadStackManagerImpl.cpp old mode 100755 new mode 100644 index f1ee3a7dac7c5e..f8cdcb2f453e44 --- a/src/platform/Linux/ThreadStackManagerImpl.cpp +++ b/src/platform/Linux/ThreadStackManagerImpl.cpp @@ -665,7 +665,7 @@ void ThreadStackManagerImpl::_OnNetworkScanFinished(GAsyncResult * res) if (g_variant_n_children(scan_result.get()) > 0) { GAutoPtr iter; - g_variant_get(scan_result.get(), "a(tstayqqyyyybb)", &MakeUniquePointerReceiver(iter).Get()); + g_variant_get(scan_result.get(), "a(tstayqqynyybb)", &MakeUniquePointerReceiver(iter).Get()); if (!iter) { delete scanResult; @@ -679,17 +679,17 @@ void ThreadStackManagerImpl::_OnNetworkScanFinished(GAsyncResult * res) guint16 panid; guint16 joiner_udp_port; guint8 channel; - guint8 rssi; + gint16 rssi; guint8 lqi; guint8 version; gboolean is_native; gboolean is_joinable; - while (g_variant_iter_loop(iter.get(), "(tstayqqyyyybb)", &ext_address, &network_name, &ext_panid, &steering_data, &panid, + while (g_variant_iter_loop(iter.get(), "(tstayqqynyybb)", &ext_address, &network_name, &ext_panid, &steering_data, &panid, &joiner_udp_port, &channel, &rssi, &lqi, &version, &is_native, &is_joinable)) { ChipLogProgress(DeviceLayer, - "Thread Network: %s (%016" PRIx64 ") ExtPanId(%016" PRIx64 ") RSSI %u LQI %u" + "Thread Network: %s (%016" PRIx64 ") ExtPanId(%016" PRIx64 ") RSSI %d LQI %u" " Version %u", network_name, ext_address, ext_panid, rssi, lqi, version); NetworkCommissioning::ThreadScanResponse networkScanned; @@ -706,8 +706,19 @@ void ThreadStackManagerImpl::_OnNetworkScanFinished(GAsyncResult * res) networkScanned.channel = channel; networkScanned.version = version; networkScanned.extendedAddress = 0; - networkScanned.rssi = rssi; - networkScanned.lqi = lqi; + if (rssi > std::numeric_limits::max()) + { + networkScanned.rssi = std::numeric_limits::max(); + } + else if (rssi < std::numeric_limits::min()) + { + networkScanned.rssi = std::numeric_limits::min(); + } + else + { + networkScanned.rssi = static_cast(rssi); + } + networkScanned.lqi = lqi; scanResult->push_back(networkScanned); } diff --git a/src/platform/Linux/dbus/openthread/introspect.xml b/src/platform/Linux/dbus/openthread/introspect.xml index e583697e1f63ec..a520c0afbfae5f 100644 --- a/src/platform/Linux/dbus/openthread/introspect.xml +++ b/src/platform/Linux/dbus/openthread/introspect.xml @@ -31,7 +31,7 @@ limitations under the License. uint16 panid uint16 joiner_udp_port uint8 channel - uint8 rssi + int16 rssi uint8 lqi uint8 version bool is_native @@ -40,7 +40,7 @@ limitations under the License. --> - + diff --git a/src/test_driver/linux-cirque/CommissioningFailureOnReportTest.py b/src/test_driver/linux-cirque/CommissioningFailureOnReportTest.py index 877e141e588cd6..81f351778925d8 100755 --- a/src/test_driver/linux-cirque/CommissioningFailureOnReportTest.py +++ b/src/test_driver/linux-cirque/CommissioningFailureOnReportTest.py @@ -42,7 +42,7 @@ DEVICE_CONFIG = { 'device0': { 'type': 'MobileDevice', - 'base_image': 'project-chip/chip-cirque-device-base', + 'base_image': '@default', 'capability': ['TrafficControl', 'Mount'], 'rcp_mode': True, 'docker_network': 'Ipv6', @@ -51,7 +51,7 @@ }, 'device1': { 'type': 'CHIPEndDevice', - 'base_image': 'project-chip/chip-cirque-device-base', + 'base_image': '@default', 'capability': ['Thread', 'TrafficControl', 'Mount'], 'rcp_mode': True, 'docker_network': 'Ipv6', diff --git a/src/test_driver/linux-cirque/CommissioningFailureTest.py b/src/test_driver/linux-cirque/CommissioningFailureTest.py index e56f396f2668f4..aec2f753d74e2d 100755 --- a/src/test_driver/linux-cirque/CommissioningFailureTest.py +++ b/src/test_driver/linux-cirque/CommissioningFailureTest.py @@ -42,7 +42,7 @@ DEVICE_CONFIG = { 'device0': { 'type': 'MobileDevice', - 'base_image': 'project-chip/chip-cirque-device-base', + 'base_image': '@default', 'capability': ['TrafficControl', 'Mount'], 'rcp_mode': True, 'docker_network': 'Ipv6', @@ -51,7 +51,7 @@ }, 'device1': { 'type': 'CHIPEndDevice', - 'base_image': 'project-chip/chip-cirque-device-base', + 'base_image': '@default', 'capability': ['Thread', 'TrafficControl', 'Mount'], 'rcp_mode': True, 'docker_network': 'Ipv6', diff --git a/src/test_driver/linux-cirque/CommissioningTest.py b/src/test_driver/linux-cirque/CommissioningTest.py index 6b6a93b9cd245b..463d24deeb9a05 100755 --- a/src/test_driver/linux-cirque/CommissioningTest.py +++ b/src/test_driver/linux-cirque/CommissioningTest.py @@ -43,7 +43,7 @@ DEVICE_CONFIG = { 'device0': { 'type': 'MobileDevice', - 'base_image': 'project-chip/chip-cirque-device-base', + 'base_image': '@default', 'capability': ['TrafficControl', 'Mount'], 'rcp_mode': True, 'docker_network': 'Ipv6', @@ -52,7 +52,7 @@ }, 'device1': { 'type': 'CHIPEndDevice', - 'base_image': 'project-chip/chip-cirque-device-base', + 'base_image': '@default', 'capability': ['Thread', 'TrafficControl', 'Mount'], 'rcp_mode': True, 'docker_network': 'Ipv6', @@ -61,7 +61,7 @@ }, 'device2': { 'type': 'CHIPEndDevice', - 'base_image': 'project-chip/chip-cirque-device-base', + 'base_image': '@default', 'capability': ['Thread', 'TrafficControl', 'Mount'], 'rcp_mode': True, 'docker_network': 'Ipv6', diff --git a/src/test_driver/linux-cirque/CommissioningWindowTest.py b/src/test_driver/linux-cirque/CommissioningWindowTest.py index a984da8db62db4..fac5b5bda334dc 100755 --- a/src/test_driver/linux-cirque/CommissioningWindowTest.py +++ b/src/test_driver/linux-cirque/CommissioningWindowTest.py @@ -43,7 +43,7 @@ DEVICE_CONFIG = { 'device0': { 'type': 'MobileDevice', - 'base_image': 'project-chip/chip-cirque-device-base', + 'base_image': '@default', 'capability': ['TrafficControl', 'Mount'], 'rcp_mode': True, 'docker_network': 'Ipv6', @@ -52,7 +52,7 @@ }, 'device1': { 'type': 'CHIPEndDevice', - 'base_image': 'project-chip/chip-cirque-device-base', + 'base_image': '@default', 'capability': ['Thread', 'TrafficControl', 'Mount'], 'rcp_mode': True, 'docker_network': 'Ipv6', diff --git a/src/test_driver/linux-cirque/EchoOverTcpTest.py b/src/test_driver/linux-cirque/EchoOverTcpTest.py index 98afc41f447c33..ca346d8971584b 100755 --- a/src/test_driver/linux-cirque/EchoOverTcpTest.py +++ b/src/test_driver/linux-cirque/EchoOverTcpTest.py @@ -36,7 +36,7 @@ DEVICE_CONFIG = { 'device0': { 'type': 'CHIP-Echo-Requester', - 'base_image': 'project-chip/chip-cirque-device-base', + 'base_image': '@default', 'capability': ['Thread', 'Interactive', 'TrafficControl', 'Mount'], 'rcp_mode': True, 'docker_network': 'Ipv6', @@ -45,7 +45,7 @@ }, 'device1': { 'type': 'CHIP-Echo-Responder', - 'base_image': 'project-chip/chip-cirque-device-base', + 'base_image': '@default', 'capability': ['Thread', 'Interactive', 'TrafficControl', 'Mount'], 'rcp_mode': True, 'docker_network': 'Ipv6', diff --git a/src/test_driver/linux-cirque/EchoTest.py b/src/test_driver/linux-cirque/EchoTest.py index a144be49c7b79a..12157591e7158d 100755 --- a/src/test_driver/linux-cirque/EchoTest.py +++ b/src/test_driver/linux-cirque/EchoTest.py @@ -36,7 +36,7 @@ DEVICE_CONFIG = { 'device0': { 'type': 'CHIP-Echo-Requester', - 'base_image': 'project-chip/chip-cirque-device-base', + 'base_image': '@default', 'capability': ['Thread', 'Interactive', 'TrafficControl', 'Mount'], 'rcp_mode': True, 'docker_network': 'Ipv6', @@ -45,7 +45,7 @@ }, 'device1': { 'type': 'CHIP-Echo-Responder', - 'base_image': 'project-chip/chip-cirque-device-base', + 'base_image': '@default', 'capability': ['Thread', 'Interactive', 'TrafficControl', 'Mount'], 'rcp_mode': True, 'docker_network': 'Ipv6', diff --git a/src/test_driver/linux-cirque/FailsafeTest.py b/src/test_driver/linux-cirque/FailsafeTest.py index 98d11d69f61ea2..ab5e5e58b06eca 100755 --- a/src/test_driver/linux-cirque/FailsafeTest.py +++ b/src/test_driver/linux-cirque/FailsafeTest.py @@ -42,7 +42,7 @@ DEVICE_CONFIG = { 'device0': { 'type': 'MobileDevice', - 'base_image': 'project-chip/chip-cirque-device-base', + 'base_image': '@default', 'capability': ['TrafficControl', 'Mount'], 'rcp_mode': True, 'docker_network': 'Ipv6', @@ -51,7 +51,7 @@ }, 'device1': { 'type': 'CHIPEndDevice', - 'base_image': 'project-chip/chip-cirque-device-base', + 'base_image': '@default', 'capability': ['Thread', 'TrafficControl', 'Mount'], 'rcp_mode': True, 'docker_network': 'Ipv6', diff --git a/src/test_driver/linux-cirque/InteractionModelTest.py b/src/test_driver/linux-cirque/InteractionModelTest.py index 1d8ad29f6cab77..f9543436f147ba 100755 --- a/src/test_driver/linux-cirque/InteractionModelTest.py +++ b/src/test_driver/linux-cirque/InteractionModelTest.py @@ -36,7 +36,7 @@ DEVICE_CONFIG = { 'device0': { 'type': 'CHIP-IM-Initiator', - 'base_image': 'project-chip/chip-cirque-device-base', + 'base_image': '@default', 'capability': ['Thread', 'Interactive', 'TrafficControl', 'Mount'], 'rcp_mode': True, 'docker_network': 'Ipv6', @@ -45,7 +45,7 @@ }, 'device1': { 'type': 'CHIP-IM-Responder', - 'base_image': 'project-chip/chip-cirque-device-base', + 'base_image': '@default', 'capability': ['Thread', 'Interactive', 'TrafficControl', 'Mount'], 'rcp_mode': True, 'docker_network': 'Ipv6', diff --git a/src/test_driver/linux-cirque/MobileDeviceTest.py b/src/test_driver/linux-cirque/MobileDeviceTest.py index 508e636cb4f197..2a7c0acc5d500a 100755 --- a/src/test_driver/linux-cirque/MobileDeviceTest.py +++ b/src/test_driver/linux-cirque/MobileDeviceTest.py @@ -42,7 +42,7 @@ DEVICE_CONFIG = { 'device0': { 'type': 'MobileDevice', - 'base_image': 'project-chip/chip-cirque-device-base', + 'base_image': '@default', 'capability': ['TrafficControl', 'Mount'], 'rcp_mode': True, 'docker_network': 'Ipv6', @@ -51,7 +51,7 @@ }, 'device1': { 'type': 'CHIPEndDevice', - 'base_image': 'project-chip/chip-cirque-device-base', + 'base_image': '@default', 'capability': ['Thread', 'TrafficControl', 'Mount'], 'rcp_mode': True, 'docker_network': 'Ipv6', diff --git a/src/test_driver/linux-cirque/OnOffClusterTest.py b/src/test_driver/linux-cirque/OnOffClusterTest.py index c2281059646b94..e1df90f2aaeb74 100755 --- a/src/test_driver/linux-cirque/OnOffClusterTest.py +++ b/src/test_driver/linux-cirque/OnOffClusterTest.py @@ -42,14 +42,14 @@ DEVICE_CONFIG = { 'device0': { 'type': 'CHIP-Server', - 'base_image': 'project-chip/chip-cirque-device-base', + 'base_image': '@default', 'capability': ['Thread', 'Interactive', 'Mount'], 'rcp_mode': True, "mount_pairs": [[CHIP_REPO, CHIP_REPO]], }, 'device1': { 'type': 'CHIP-Tool', - 'base_image': 'project-chip/chip-cirque-device-base', + 'base_image': '@default', 'capability': ['Thread', 'Interactive', 'Mount'], 'rcp_mode': True, "mount_pairs": [[CHIP_REPO, CHIP_REPO]], diff --git a/src/test_driver/linux-cirque/PythonCommissioningTest.py b/src/test_driver/linux-cirque/PythonCommissioningTest.py index ff8814368345ff..fdb314d3858603 100755 --- a/src/test_driver/linux-cirque/PythonCommissioningTest.py +++ b/src/test_driver/linux-cirque/PythonCommissioningTest.py @@ -43,7 +43,7 @@ DEVICE_CONFIG = { 'device0': { 'type': 'MobileDevice', - 'base_image': 'project-chip/chip-cirque-device-base', + 'base_image': '@default', 'capability': ['TrafficControl', 'Mount'], 'rcp_mode': True, 'docker_network': 'Ipv6', @@ -52,7 +52,7 @@ }, 'device1': { 'type': 'CHIPEndDevice', - 'base_image': 'project-chip/chip-cirque-device-base', + 'base_image': '@default', 'capability': ['Thread', 'TrafficControl', 'Mount'], 'rcp_mode': True, 'docker_network': 'Ipv6', @@ -61,7 +61,7 @@ }, 'device2': { 'type': 'CHIPEndDevice', - 'base_image': 'project-chip/chip-cirque-device-base', + 'base_image': '@default', 'capability': ['Thread', 'TrafficControl', 'Mount'], 'rcp_mode': True, 'docker_network': 'Ipv6', diff --git a/src/test_driver/linux-cirque/SplitCommissioningTest.py b/src/test_driver/linux-cirque/SplitCommissioningTest.py index 78a08e82ec4989..78acabb7085ed7 100755 --- a/src/test_driver/linux-cirque/SplitCommissioningTest.py +++ b/src/test_driver/linux-cirque/SplitCommissioningTest.py @@ -41,7 +41,7 @@ DEVICE_CONFIG = { 'device0': { 'type': 'MobileDevice', - 'base_image': 'project-chip/chip-cirque-device-base', + 'base_image': '@default', 'capability': ['TrafficControl', 'Mount'], 'rcp_mode': True, 'docker_network': 'Ipv6', @@ -50,7 +50,7 @@ }, 'device1': { 'type': 'CHIPEndDevice', - 'base_image': 'project-chip/chip-cirque-device-base', + 'base_image': '@default', 'capability': ['Thread', 'TrafficControl', 'Mount'], 'rcp_mode': True, 'docker_network': 'Ipv6', @@ -59,7 +59,7 @@ }, 'device2': { 'type': 'CHIPEndDevice', - 'base_image': 'project-chip/chip-cirque-device-base', + 'base_image': '@default', 'capability': ['Thread', 'TrafficControl', 'Mount'], 'rcp_mode': True, 'docker_network': 'Ipv6', diff --git a/src/test_driver/linux-cirque/helper/CHIPTestBase.py b/src/test_driver/linux-cirque/helper/CHIPTestBase.py index 62489b24bfc360..036ba25a8538ff 100644 --- a/src/test_driver/linux-cirque/helper/CHIPTestBase.py +++ b/src/test_driver/linux-cirque/helper/CHIPTestBase.py @@ -23,7 +23,7 @@ import time import traceback from enum import IntEnum -from typing import List, Union +from typing import List, Mapping, Union from urllib.parse import urljoin import requests @@ -45,7 +45,7 @@ class TestResult(IntEnum): class CHIPVirtualHome: - def __init__(self, cirque_url, device_config): + def __init__(self, cirque_url, device_config: Mapping[str, dict]): self.home_id = None self.logger = None self.cirque_url = cirque_url @@ -56,6 +56,10 @@ def __init__(self, cirque_url, device_config): self.thread_devices = [] self.ap_devices = [] + for device in device_config.values(): + if device.get("base_image", "@default") == "@default": + device["base_image"] = self.default_base_image + # The entrance of the whole test def run_test(self, save_logs=True): test_ret = TestResult.OK @@ -417,3 +421,7 @@ def get_device_pretty_name(self, device_id): def get_device_pretty_id(self, device_id): return "{}({}...)".format(self.get_device_pretty_name(device_id), device_id[:8]) + + @property + def default_base_image(cls): + return os.environ.get("CHIP_CIRQUE_BASE_IMAGE", "project-chip/chip-cirque-device-base") diff --git a/src/test_driver/linux-cirque/topologies/one_node_one_android.json b/src/test_driver/linux-cirque/topologies/one_node_one_android.json index 3b8abea4b9548f..8bb2b58d7e26c5 100644 --- a/src/test_driver/linux-cirque/topologies/one_node_one_android.json +++ b/src/test_driver/linux-cirque/topologies/one_node_one_android.json @@ -1,7 +1,7 @@ { "device0": { "type": "CHIP-00", - "base_image": "project-chip/chip-cirque-device-base", + "base_image": "@default", "capability": ["Thread", "Interactive", "Mount"], "mount_pairs": [["{chip_repo}", "{chip_repo}"]], "rcp_mode": true diff --git a/src/test_driver/linux-cirque/topologies/three_node_with_ipv6.json b/src/test_driver/linux-cirque/topologies/three_node_with_ipv6.json index f97eede81b18df..7f1d252349a6fe 100644 --- a/src/test_driver/linux-cirque/topologies/three_node_with_ipv6.json +++ b/src/test_driver/linux-cirque/topologies/three_node_with_ipv6.json @@ -1,21 +1,21 @@ { "device0": { "type": "CHIP-00", - "base_image": "project-chip/chip-cirque-device-base", + "base_image": "@default", "docker_network": "Ipv6", "capability": ["Interactive", "Mount"], "mount_pairs": [["{chip_repo}", "{chip_repo}"]] }, "device1": { "type": "CHIP-01", - "base_image": "project-chip/chip-cirque-device-base", + "base_image": "@default", "docker_network": "Ipv6", "capability": ["Interactive", "Mount"], "mount_pairs": [["{chip_repo}", "{chip_repo}"]] }, "device2": { "type": "CHIP-02", - "base_image": "project-chip/chip-cirque-device-base", + "base_image": "@default", "docker_network": "Ipv6", "capability": ["Interactive", "Mount"], "mount_pairs": [["{chip_repo}", "{chip_repo}"]] diff --git a/src/test_driver/linux-cirque/topologies/three_node_with_ipvlan.json b/src/test_driver/linux-cirque/topologies/three_node_with_ipvlan.json index 54c07d4f46ec4e..bb6108c5d171d6 100644 --- a/src/test_driver/linux-cirque/topologies/three_node_with_ipvlan.json +++ b/src/test_driver/linux-cirque/topologies/three_node_with_ipvlan.json @@ -1,21 +1,21 @@ { "device0": { "type": "CHIP-00", - "base_image": "project-chip/chip-cirque-device-base", + "base_image": "@default", "docker_network": "IpvLan", "capability": ["Interactive", "Mount"], "mount_pairs": [["{chip_repo}", "{chip_repo}"]] }, "device1": { "type": "CHIP-01", - "base_image": "project-chip/chip-cirque-device-base", + "base_image": "@default", "docker_network": "IpvLan", "capability": ["Interactive", "Mount"], "mount_pairs": [["{chip_repo}", "{chip_repo}"]] }, "device2": { "type": "CHIP-02", - "base_image": "project-chip/chip-cirque-device-base", + "base_image": "@default", "docker_network": "IpvLan", "capability": ["Interactive", "Mount"], "mount_pairs": [["{chip_repo}", "{chip_repo}"]] diff --git a/src/test_driver/linux-cirque/topologies/three_node_with_thread.json b/src/test_driver/linux-cirque/topologies/three_node_with_thread.json index 0b9696e12bcefb..8febbc985019e1 100644 --- a/src/test_driver/linux-cirque/topologies/three_node_with_thread.json +++ b/src/test_driver/linux-cirque/topologies/three_node_with_thread.json @@ -1,21 +1,21 @@ { "device0": { "type": "CHIP-00", - "base_image": "project-chip/chip-cirque-device-base", + "base_image": "@default", "capability": ["Thread", "Interactive", "Mount"], "mount_pairs": [["{chip_repo}", "{chip_repo}"]], "rcp_mode": true }, "device1": { "type": "CHIP-01", - "base_image": "project-chip/chip-cirque-device-base", + "base_image": "@default", "capability": ["Thread", "Interactive", "Mount"], "mount_pairs": [["{chip_repo}", "{chip_repo}"]], "rcp_mode": true }, "device2": { "type": "CHIP-02", - "base_image": "project-chip/chip-cirque-device-base", + "base_image": "@default", "capability": ["Thread", "Interactive", "Mount"], "mount_pairs": [["{chip_repo}", "{chip_repo}"]], "rcp_mode": true diff --git a/src/test_driver/linux-cirque/topologies/two_node_with_thread.json b/src/test_driver/linux-cirque/topologies/two_node_with_thread.json index 4da678ec784031..683fa96c25aec6 100644 --- a/src/test_driver/linux-cirque/topologies/two_node_with_thread.json +++ b/src/test_driver/linux-cirque/topologies/two_node_with_thread.json @@ -1,14 +1,14 @@ { "device0": { "type": "CHIP-00", - "base_image": "project-chip/chip-cirque-device-base", + "base_image": "@default", "capability": ["Thread", "Interactive", "Mount"], "mount_pairs": [["{chip_repo}", "{chip_repo}"]], "rcp_mode": true }, "device1": { "type": "CHIP-01", - "base_image": "project-chip/chip-cirque-device-base", + "base_image": "@default", "capability": ["Thread", "Interactive", "Mount"], "mount_pairs": [["{chip_repo}", "{chip_repo}"]], "rcp_mode": true