Skip to content

Commit

Permalink
Merge branch 'main' of github.com:opencomputeproject/SAI-Challenger i…
Browse files Browse the repository at this point in the history
…nto thrift_server

Signed-off-by: Yurii Lisovskyi <[email protected]>
  • Loading branch information
yuriilisovskyi committed Oct 2, 2023
2 parents b34c526 + a994202 commit 94d3bca
Show file tree
Hide file tree
Showing 14 changed files with 104 additions and 104 deletions.
43 changes: 23 additions & 20 deletions .github/workflows/sc-client-server-deb10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/**'
Expand All @@ -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:
Expand All @@ -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<<EOF' >> $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
Expand All @@ -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<<EOF' >> $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
Expand Down Expand Up @@ -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

Expand Down
39 changes: 21 additions & 18 deletions .github/workflows/sc-client-server-deb11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/**'
Expand All @@ -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:
Expand All @@ -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<<EOF' >> $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
Expand All @@ -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<<EOF' >> $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
Expand Down Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/sc-standalone-deb10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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<<EOF' >> $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: |
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/sc-standalone-deb11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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<<EOF' >> $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: |
Expand Down
24 changes: 9 additions & 15 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ TARGET=""
SAI_INTERFACE="redis"
BASE_OS="buster"
NOSNAPPI=""
CACHE=""

declare -A base_os_map
base_os_map["deb10"]="buster"
Expand All @@ -41,8 +40,6 @@ print-help() {
echo " Docker image base OS"
echo " --nosnappi"
echo " Do not include snappi to the final image"
echo " --nocache"
echo " Rebuild Docker images (--no-cache)"
echo
exit 0
}
Expand Down Expand Up @@ -77,9 +74,6 @@ while [[ $# -gt 0 ]]; do
"--nosnappi")
NOSNAPPI="y"
;;
"--nocache")
CACHE="--no-cache "
;;
esac
shift
done
Expand Down Expand Up @@ -151,20 +145,20 @@ trap print-build-options EXIT

# Build base Docker image
if [ "${IMAGE_TYPE}" = "standalone" ]; then
docker build -f dockerfiles/${BASE_OS}/Dockerfile -t sc-base:${BASE_OS} ${CACHE} .
docker build -f dockerfiles/${BASE_OS}/Dockerfile -t sc-base:${BASE_OS} .
elif [ "${IMAGE_TYPE}" = "server" ]; then
find ${ASIC_PATH}/../ -type f -name \*.py -exec install -D {} .build/{} \;
find ${ASIC_PATH}/../ -type f -name \*.json -exec install -D {} .build/{} \;
if [ "${SAI_INTERFACE}" = "thrift" ]; then
docker build -f dockerfiles/${BASE_OS}/Dockerfile.saithrift-server -t sc-thrift-server-base:${BASE_OS} ${CACHE} .
docker build -f dockerfiles/${BASE_OS}/Dockerfile.saithrift-server -t sc-thrift-server-base:${BASE_OS} .
else
docker build -f dockerfiles/${BASE_OS}/Dockerfile.server -t sc-server-base:${BASE_OS} ${CACHE} .
docker build -f dockerfiles/${BASE_OS}/Dockerfile.server -t sc-server-base:${BASE_OS} .
fi
rm -rf .build/
else
docker build -f dockerfiles/${BASE_OS}/Dockerfile.client --build-arg NOSNAPPI=${NOSNAPPI} -t sc-client:${BASE_OS} ${CACHE} .
docker build -f dockerfiles/${BASE_OS}/Dockerfile.client --build-arg NOSNAPPI=${NOSNAPPI} -t sc-client:${BASE_OS} .
if [ "${SAI_INTERFACE}" = "thrift" ]; then
docker build -f dockerfiles/${BASE_OS}/Dockerfile.saithrift-client -t sc-thrift-client:${BASE_OS} ${CACHE} .
docker build -f dockerfiles/${BASE_OS}/Dockerfile.saithrift-client -t sc-thrift-client:${BASE_OS} .
fi
exit 0
fi
Expand All @@ -174,15 +168,15 @@ pushd "${ASIC_PATH}/${TARGET}"
IMG_NAME=$(echo "${ASIC_TYPE}-${TARGET}" | tr '[:upper:]' '[:lower:]')
if [ "${IMAGE_TYPE}" = "standalone" ]; then
if [ "${SAI_INTERFACE}" = "thrift" ]; then
docker build -f Dockerfile.saithrift --build-arg BASE_OS=${BASE_OS} -t sc-thrift-${IMG_NAME}:${BASE_OS} ${CACHE} .
docker build -f Dockerfile.saithrift --build-arg BASE_OS=${BASE_OS} -t sc-thrift-${IMG_NAME}:${BASE_OS} .
else
docker build -f Dockerfile --build-arg BASE_OS=${BASE_OS} -t sc-${IMG_NAME}:${BASE_OS} ${CACHE} .
docker build -f Dockerfile --build-arg BASE_OS=${BASE_OS} -t sc-${IMG_NAME}:${BASE_OS} .
fi
elif [ "${IMAGE_TYPE}" = "server" ]; then
if [ "${SAI_INTERFACE}" = "thrift" ]; then
docker build -f Dockerfile.saithrift-server --build-arg BASE_OS=${BASE_OS} -t sc-thrift-server-${IMG_NAME}:${BASE_OS} ${CACHE} .
docker build -f Dockerfile.saithrift-server --build-arg BASE_OS=${BASE_OS} -t sc-thrift-server-${IMG_NAME}:${BASE_OS} .
else
docker build -f Dockerfile.server --build-arg BASE_OS=${BASE_OS} -t sc-server-${IMG_NAME}:${BASE_OS} ${CACHE} .
docker build -f Dockerfile.server --build-arg BASE_OS=${BASE_OS} -t sc-server-${IMG_NAME}:${BASE_OS} .
fi
fi
popd
4 changes: 3 additions & 1 deletion common/sai.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
49 changes: 25 additions & 24 deletions common/sai_client/sai_redis_client/sai_redis_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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):
Expand Down Expand Up @@ -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)
Expand Down
Loading

0 comments on commit 94d3bca

Please sign in to comment.