From c2d359d93092b44d967a2440af7ff2ed22f0495f Mon Sep 17 00:00:00 2001 From: Andriy Kokhan Date: Sat, 30 Sep 2023 12:02:23 +0300 Subject: [PATCH 1/4] [CI/CD] Fixed checks what Docker images have to be rebuild (#206) Signed-off-by: Andriy Kokhan --- .github/workflows/sc-client-server-deb10.yml | 43 +++++++++++--------- .github/workflows/sc-client-server-deb11.yml | 39 ++++++++++-------- .github/workflows/sc-standalone-deb10.yml | 4 +- .github/workflows/sc-standalone-deb11.yml | 4 +- 4 files changed, 50 insertions(+), 40 deletions(-) diff --git a/.github/workflows/sc-client-server-deb10.yml b/.github/workflows/sc-client-server-deb10.yml index 53626639..de4ca19f 100644 --- a/.github/workflows/sc-client-server-deb10.yml +++ b/.github/workflows/sc-client-server-deb10.yml @@ -7,7 +7,6 @@ on: paths: - '.github/workflows/sc-client-server-deb10.yml' - 'dockerfiles/buster/Dockerfile.client' - - 'dockerfiles/buster/Dockerfile.saithrift-client' - 'dockerfiles/buster/Dockerfile.server' - 'npu/broadcom/BCM56850/saivs/Dockerfile.server' - 'common/**' @@ -23,11 +22,12 @@ on: - 'sai.env' env: - DOCKER_BASE: 'dockerfiles/buster/Dockerfile' - DOCKER_REDIS: 'npu/broadcom/BCM56850/saivs/Dockerfile' - DOCKER_THRIFT: 'npu/broadcom/BCM56850/saivs/Dockerfile.saithrift' - REDIS_RPC: 0 - THRIFT_RPC: 0 + DOCKER_CLIENT: 'dockerfiles/buster/Dockerfile.client' + DOCKER_SERVER_BASE: 'dockerfiles/buster/Dockerfile.server' + DOCKER_SERVER: 'npu/broadcom/BCM56850/saivs/Dockerfile.server' + REDIS_CLIENT: 0 + REDIS_SERVER: 0 + jobs: build-sc-server: @@ -43,23 +43,25 @@ jobs: - name: Check what files were updated id: check_changes run: | - echo 'changed_files=$(git diff --name-only origin/HEAD | xargs)' >> $GITHUB_OUTPUT + echo 'changed_files<> $GITHUB_OUTPUT + echo "$(git diff --name-only HEAD~1)" >> $GITHUB_OUTPUT + echo 'EOF' >> $GITHUB_OUTPUT - name: Check what Docker images have to be rebuild run: | - for file in "$DOCKER_BASE" "$DOCKER_REDIS" "sai.env"; do + for file in "$DOCKER_SERVER_BASE" "$DOCKER_SERVER" "sai.env"; do if [[ "${{ steps.check_changes.outputs.changed_files }}" == *"$file"* ]]; then - echo "REDIS_RPC=1" >> $GITHUB_ENV + echo "REDIS_SERVER=1" >> $GITHUB_ENV fi done - name: Build server Docker image run: ./build.sh -i server -o deb10 - if: ${{ env.REDIS_RPC == '1' }} + if: ${{ env.REDIS_SERVER == '1' }} - name: Pull SAI-C server run: ./run.sh -i server -o deb10 - if: ${{ env.REDIS_RPC == '0' }} + if: ${{ env.REDIS_SERVER == '0' }} - name: Save server Docker image run: docker save sc-server-trident2-saivs > sc-server.tar @@ -82,24 +84,25 @@ jobs: - name: Check what files were updated id: check_changes run: | - echo 'changed_files=$(git diff --name-only origin/HEAD | xargs)' >> $GITHUB_OUTPUT + echo 'changed_files<> $GITHUB_OUTPUT + echo "$(git diff --name-only HEAD~1)" >> $GITHUB_OUTPUT + echo 'EOF' >> $GITHUB_OUTPUT - name: Check what Docker images have to be rebuild run: | - changed_files=$(git diff --name-only origin/HEAD | xargs) - for file in "$DOCKER_BASE" "$DOCKER_REDIS" "sai.env"; do - if [[ "$changed_files" == *"$file"* ]]; then - echo "REDIS_RPC=1" + for file in "$DOCKER_CLIENT" "sai.env"; do + if [[ "${{ steps.check_changes.outputs.changed_files }}" == *"$file"* ]]; then + echo "REDIS_CLIENT=1" >> $GITHUB_ENV fi done - name: Build client Docker image run: ./build.sh -i client -o deb10 --nosnappi - if: ${{ env.REDIS_RPC == '1' }} + if: ${{ env.REDIS_CLIENT == '1' }} - name: Pull SAI-C client run: ./run.sh -i client -o deb10 - if: ${{ env.REDIS_RPC == '0' }} + if: ${{ env.REDIS_CLIENT == '0' }} - name: Save client Docker image run: docker save sc-client > sc-client.tar @@ -147,10 +150,10 @@ jobs: run: ./run.sh -i server -o deb10 - name: Update SAI-C server package run: ./exec.sh -i server --no-tty pip3 install /sai-challenger/common /sai-challenger - if: ${{ env.REDIS_RPC == '0' }} + if: ${{ env.REDIS_SERVER == '0' }} - name: Update SAI-C client package run: ./exec.sh -i client --no-tty pip3 install /sai-challenger/common /sai-challenger - if: ${{ env.REDIS_RPC == '0' }} + if: ${{ env.REDIS_CLIENT == '0' }} - name: Create veth links between client and server dockers run: sudo ./veth-create-host.sh sc-server-trident2-saivs-run sc-client-run diff --git a/.github/workflows/sc-client-server-deb11.yml b/.github/workflows/sc-client-server-deb11.yml index 1a332b11..b6639c5b 100644 --- a/.github/workflows/sc-client-server-deb11.yml +++ b/.github/workflows/sc-client-server-deb11.yml @@ -7,7 +7,6 @@ on: paths: - '.github/workflows/sc-client-server-deb11.yml' - 'dockerfiles/bullseye/Dockerfile.client' - - 'dockerfiles/bullseye/Dockerfile.saithrift-client' - 'dockerfiles/bullseye/Dockerfile.server' - 'npu/broadcom/BCM56850/saivs/Dockerfile.server' - 'common/**' @@ -23,11 +22,11 @@ on: - 'sai.env' env: - DOCKER_BASE: 'dockerfiles/bullseye/Dockerfile' - DOCKER_REDIS: 'npu/broadcom/BCM56850/saivs/Dockerfile' - DOCKER_THRIFT: 'npu/broadcom/BCM56850/saivs/Dockerfile.saithrift' - REDIS_RPC: 0 - THRIFT_RPC: 0 + DOCKER_CLIENT: 'dockerfiles/bullseye/Dockerfile.client' + DOCKER_SERVER_BASE: 'dockerfiles/bullseye/Dockerfile.server' + DOCKER_SERVER: 'npu/broadcom/BCM56850/saivs/Dockerfile.server' + REDIS_CLIENT: 0 + REDIS_SERVER: 0 jobs: build-sc-server: @@ -43,23 +42,25 @@ jobs: - name: Check what files were updated id: check_changes run: | - echo 'changed_files=$(git diff --name-only origin/HEAD | xargs)' >> $GITHUB_OUTPUT + echo 'changed_files<> $GITHUB_OUTPUT + echo "$(git diff --name-only HEAD~1)" >> $GITHUB_OUTPUT + echo 'EOF' >> $GITHUB_OUTPUT - name: Check what Docker images have to be rebuild run: | - for file in "$DOCKER_BASE" "$DOCKER_REDIS" "sai.env"; do + for file in "$DOCKER_SERVER_BASE" "$DOCKER_SERVER" "sai.env"; do if [[ "${{ steps.check_changes.outputs.changed_files }}" == *"$file"* ]]; then - echo "REDIS_RPC=1" >> $GITHUB_ENV + echo "REDIS_SERVER=1" >> $GITHUB_ENV fi done - name: Build server Docker image run: ./build.sh -i server -o deb11 - if: ${{ env.REDIS_RPC == '1' }} + if: ${{ env.REDIS_SERVER == '1' }} - name: Pull SAI-C server run: ./run.sh -i server -o deb11 - if: ${{ env.REDIS_RPC == '0' }} + if: ${{ env.REDIS_SERVER == '0' }} - name: Save server Docker image run: docker save sc-server-trident2-saivs > sc-server.tar @@ -82,23 +83,25 @@ jobs: - name: Check what files were updated id: check_changes run: | - echo 'changed_files=$(git diff --name-only origin/HEAD | xargs)' >> $GITHUB_OUTPUT + echo 'changed_files<> $GITHUB_OUTPUT + echo "$(git diff --name-only HEAD~1)" >> $GITHUB_OUTPUT + echo 'EOF' >> $GITHUB_OUTPUT - name: Check what Docker images have to be rebuild run: | - for file in "$DOCKER_BASE" "$DOCKER_REDIS" "sai.env"; do + for file in "$DOCKER_CLIENT" "sai.env"; do if [[ "${{ steps.check_changes.outputs.changed_files }}" == *"$file"* ]]; then - echo "REDIS_RPC=1" >> $GITHUB_ENV + echo "REDIS_CLIENT=1" >> $GITHUB_ENV fi done - name: Build client Docker image run: ./build.sh -i client -o deb11 --nosnappi - if: ${{ env.REDIS_RPC == '1' }} + if: ${{ env.REDIS_CLIENT == '1' }} - name: Pull SAI-C client run: ./run.sh -i client -o deb11 - if: ${{ env.REDIS_RPC == '0' }} + if: ${{ env.REDIS_CLIENT == '0' }} - name: Save client Docker image run: docker save sc-client > sc-client.tar @@ -146,10 +149,10 @@ jobs: run: ./run.sh -i server -o deb11 - name: Update SAI-C server package run: ./exec.sh -i server --no-tty pip3 install /sai-challenger/common /sai-challenger - if: ${{ env.REDIS_RPC == '0' }} + if: ${{ env.REDIS_SERVER == '0' }} - name: Update SAI-C client package run: ./exec.sh -i client --no-tty pip3 install /sai-challenger/common /sai-challenger - if: ${{ env.REDIS_RPC == '0' }} + if: ${{ env.REDIS_CLIENT == '0' }} - name: Create veth links between client and server dockers run: sudo ./veth-create-host.sh sc-server-trident2-saivs-run sc-client-run diff --git a/.github/workflows/sc-standalone-deb10.yml b/.github/workflows/sc-standalone-deb10.yml index 57688b62..d88caef9 100644 --- a/.github/workflows/sc-standalone-deb10.yml +++ b/.github/workflows/sc-standalone-deb10.yml @@ -42,7 +42,9 @@ jobs: - name: Check what files were updated id: check_changes run: | - echo 'changed_files=$(git diff --name-only origin/HEAD | xargs)' >> $GITHUB_OUTPUT + echo 'changed_files<> $GITHUB_OUTPUT + echo "$(git diff --name-only HEAD~1)" >> $GITHUB_OUTPUT + echo 'EOF' >> $GITHUB_OUTPUT - name: Check what Docker images have to be rebuild run: | diff --git a/.github/workflows/sc-standalone-deb11.yml b/.github/workflows/sc-standalone-deb11.yml index f237ae68..094e5360 100644 --- a/.github/workflows/sc-standalone-deb11.yml +++ b/.github/workflows/sc-standalone-deb11.yml @@ -42,7 +42,9 @@ jobs: - name: Check what files were updated id: check_changes run: | - echo 'changed_files=$(git diff --name-only origin/HEAD | xargs)' >> $GITHUB_OUTPUT + echo 'changed_files<> $GITHUB_OUTPUT + echo "$(git diff --name-only HEAD~1)" >> $GITHUB_OUTPUT + echo 'EOF' >> $GITHUB_OUTPUT - name: Check what Docker images have to be rebuild run: | From 233a8960f3341b8dd6783b42587f4c972fcd2d11 Mon Sep 17 00:00:00 2001 From: Andriy Kokhan Date: Sat, 30 Sep 2023 13:47:05 +0300 Subject: [PATCH 2/4] Updated to SAI v1.13+ (#205) * Added nlohmann-json3-dev as new sairedis dependency * Extended list of unsupported types in get_by_type() --------- Signed-off-by: Andriy Kokhan --- common/sai.py | 4 +++- dockerfiles/bullseye/Dockerfile.server | 3 ++- dockerfiles/buster/Dockerfile.server | 3 ++- sai.env | 14 +++++++------- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/common/sai.py b/common/sai.py index 3b7fd28b..d83eb1a8 100644 --- a/common/sai.py +++ b/common/sai.py @@ -338,7 +338,9 @@ def get_by_type(self, obj, attr, attr_type, do_assert=False): unsupported_types = [ "sai_port_eye_values_list_t", "sai_prbs_rx_state_t", "sai_port_err_status_list_t", "sai_fabric_port_reachability_t", - "sai_port_lane_latch_status_list_t", "sai_latch_status_t" + "sai_port_lane_latch_status_list_t", "sai_latch_status_t", + "sai_port_frequency_offset_ppm_list_t", "sai_port_snr_list_t", + "sai_acl_chain_list_t" ] if attr_type == "sai_object_list_t": status, data = self.get(obj, [attr, "1:oid:0x0"], do_assert) diff --git a/dockerfiles/bullseye/Dockerfile.server b/dockerfiles/bullseye/Dockerfile.server index 7e8d732d..60a4ef0a 100644 --- a/dockerfiles/bullseye/Dockerfile.server +++ b/dockerfiles/bullseye/Dockerfile.server @@ -34,7 +34,8 @@ RUN apt-get install -y \ make libtool m4 autoconf dh-exec debhelper automake cmake pkg-config \ libhiredis-dev libnl-3-dev libnl-genl-3-dev libnl-route-3-dev swig \ libgtest-dev libgmock-dev libboost-dev autoconf-archive \ - uuid-dev libboost-serialization-dev libyang-dev libyang1 + uuid-dev libboost-serialization-dev libyang-dev libyang1 \ + nlohmann-json3-dev RUN apt-get install -y \ libnl-3-dev libnl-genl-3-dev libnl-route-3-dev libnl-nf-3-dev libzmq3-dev diff --git a/dockerfiles/buster/Dockerfile.server b/dockerfiles/buster/Dockerfile.server index d1e8c69b..371cff6d 100644 --- a/dockerfiles/buster/Dockerfile.server +++ b/dockerfiles/buster/Dockerfile.server @@ -40,7 +40,8 @@ RUN apt-get install -y \ make libtool m4 autoconf dh-exec debhelper automake cmake pkg-config \ libhiredis-dev libnl-3-dev libnl-genl-3-dev libnl-route-3-dev swig3.0 \ libgtest-dev libgmock-dev libboost-dev autoconf-archive \ - uuid-dev libboost-serialization-dev libyang-dev libyang0.16 + uuid-dev libboost-serialization-dev libyang-dev libyang0.16 \ + nlohmann-json3-dev RUN apt-get install -y \ libnl-3-dev libnl-genl-3-dev libnl-route-3-dev libnl-nf-3-dev libzmq3-dev diff --git a/sai.env b/sai.env index fa38aa3b..ba81acd2 100644 --- a/sai.env +++ b/sai.env @@ -1,13 +1,13 @@ # The sonic-swss-common and sonic-sairedis commits were taken from -# sonic-buildimage master as of Aug 15, 2023 +# sonic-buildimage master as of Sep 29, 2023 # -# https://github.com/sonic-net/sonic-buildimage/tree/4acaaf8 +# https://github.com/sonic-net/sonic-buildimage/tree/81a2f56 -SWSS_COMMON_ID=be425ed -SAIREDIS_ID=eb24302 +SWSS_COMMON_ID=b0f148e +SAIREDIS_ID=c22b76b # SAI version: -# Branch v1.12 -# May 17, 2023 +# Branch master (post v1.13) +# Sep 8, 2023 -SAI_ID=92875f9 +SAI_ID=7f7a758 From dcde9c05005995d425394b43c49ffb72d87e655b Mon Sep 17 00:00:00 2001 From: Andriy Kokhan Date: Sun, 1 Oct 2023 13:13:16 +0300 Subject: [PATCH 3/4] Fixed pytest warnings (#207) Signed-off-by: Andriy Kokhan --- common/sai_dut.py | 2 +- tests/pytest.ini | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 tests/pytest.ini diff --git a/common/sai_dut.py b/common/sai_dut.py index d3f27224..95820a60 100644 --- a/common/sai_dut.py +++ b/common/sai_dut.py @@ -137,7 +137,7 @@ def init(self): # Write to CONFIG_DB SONiC device information needed on syncd start config_db = redis.Redis(host=self.server_ip, port=self.port, db=4) - config_db.hmset("DEVICE_METADATA|localhost", device_metadata) + config_db.hset("DEVICE_METADATA|localhost", mapping=device_metadata) config_db.set("CONFIG_DB_INITIALIZED", "1") def deinit(self): diff --git a/tests/pytest.ini b/tests/pytest.ini new file mode 100644 index 00000000..5fc853f8 --- /dev/null +++ b/tests/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +markers = + dpu: mark DPU specific tests \ No newline at end of file From a9942029411e7be91411d573014645235a70f531 Mon Sep 17 00:00:00 2001 From: Andriy Kokhan Date: Sun, 1 Oct 2023 15:21:00 +0300 Subject: [PATCH 4/4] Refactored Redis RPC I/O failure processing (#208) Signed-off-by: Andriy Kokhan --- .../sai_redis_client/sai_redis_client.py | 49 ++++++++++--------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/common/sai_client/sai_redis_client/sai_redis_client.py b/common/sai_client/sai_redis_client/sai_redis_client.py index ebfbb795..2782302e 100644 --- a/common/sai_client/sai_redis_client/sai_redis_client.py +++ b/common/sai_client/sai_redis_client/sai_redis_client.py @@ -86,16 +86,10 @@ def operate(self, obj, attrs, op): if self.asic_channel is None: self.__assert_syncd_running() + # Clean-up Redis RPC I/O pipe self.r.delete("GETRESPONSE_KEY_VALUE_OP_QUEUE") - - tout = 0.01 - attempts = self.attempts - while len(self.r.lrange("GETRESPONSE_KEY_VALUE_OP_QUEUE", 0, -1)) > 0 and attempts > 0: - time.sleep(0.01) - attempts -= 1 - - if attempts == 0: - return [] + status = self.r.lrange("GETRESPONSE_KEY_VALUE_OP_QUEUE", 0, -1) + assert len(status) == 0, "Redis RPC I/O failure!" # Remove spaces from the key string. # Required by sai_deserialize_route_entry() in sonic-sairedis. @@ -107,22 +101,25 @@ def operate(self, obj, attrs, op): self.r.lpush("ASIC_STATE_KEY_VALUE_OP_QUEUE", obj, attrs, op) self.r.publish(self.asic_channel, "G") - status = [] - attempts = self.attempts - - # Wait upto 3 mins for switch init if obj.startswith("SAI_OBJECT_TYPE_SWITCH") and op == "Screate": + # Wait upto 3 mins for switch init tout = 0.5 attempts = 240 + else: + tout = 0.01 + attempts = self.attempts + # Get response + status = self.r.lrange("GETRESPONSE_KEY_VALUE_OP_QUEUE", 0, -1) while len(status) < 3 and attempts > 0: + assert self.__check_syncd_running(), "FATAL - SyncD has exited or crashed!" time.sleep(tout) attempts -= 1 status = self.r.lrange("GETRESPONSE_KEY_VALUE_OP_QUEUE", 0, -1) self.r.delete("GETRESPONSE_KEY_VALUE_OP_QUEUE") - assert len(status) == 3, "SAI \"{}\" operation failure!".format(op) + assert len(status) == 3, f"SAI \"{op[1:]}\" operation failure!" return status def create(self, obj, attrs, do_assert=True): @@ -543,18 +540,22 @@ def vid_to_rid(self, vid): assert rid.startswith("oid:"), f"Invalid RID format {vid}" return rid + def __check_syncd_running(self): + if self.asic_db == 1: + numsub = self.r.execute_command('PUBSUB', 'NUMSUB', 'ASIC_STATE_CHANNEL') + if numsub[1] >= 1: + # SONiC 202111 or older detected + return "ASIC_STATE_CHANNEL" + numsub = self.r.execute_command('PUBSUB', 'NUMSUB', f'ASIC_STATE_CHANNEL@{self.asic_db}') + if numsub[1] >= 1: + # SONiC 202205 or newer detected + return f"ASIC_STATE_CHANNEL@{self.asic_db}" + return None + def __assert_syncd_running(self, tout=30): for i in range(tout + 1): - if self.asic_db == 1: - numsub = self.r.execute_command('PUBSUB', 'NUMSUB', 'ASIC_STATE_CHANNEL') - if numsub[1] >= 1: - # SONiC 202111 or older detected - self.asic_channel = "ASIC_STATE_CHANNEL" - return - numsub = self.r.execute_command('PUBSUB', 'NUMSUB', f'ASIC_STATE_CHANNEL@{self.asic_db}') - if numsub[1] >= 1: - # SONiC 202205 or newer detected - self.asic_channel = f"ASIC_STATE_CHANNEL@{self.asic_db}" + self.asic_channel = self.__check_syncd_running() + if self.asic_channel: return if i < tout: time.sleep(1)