Update live-test.yaml #76
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests | |
on: | |
push: | |
branches: | |
- saga | |
pull_request: | |
env: | |
IMAGE_TAGGED: coap:${{ github.sha }} | |
REPO_IMAGE_TAGGED: ${{ vars.REGISTRY_LOGIN_SERVER }}/coap:${{ github.sha }} | |
REPO_IMAGE_LATEST: ${{ vars.REGISTRY_LOGIN_SERVER }}/coap:latest | |
jobs: | |
tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 1.22.1 | |
- name: Build client | |
working-directory: client | |
run: go build | |
- name: Build server | |
working-directory: server | |
run: go build | |
- name: Build image | |
run: | | |
docker build -t ${{ env.IMAGE_TAGGED }} . | |
- name: Run image | |
env: | |
STORAGE_CONNECTION_STRING: ${{ secrets.STORAGE_CONNECTION_STRING }} | |
STORAGE_CONTAINER_NAME: ${{ vars.STORAGE_CONTAINER_NAME }} | |
run: | | |
docker run --cidfile container.cid --network=host -p 5683:5683/udp -p 5684:5684/udp -p 5688:5688/udp -p 5689:5689/udp -e STORAGE_CONNECTION_STRING -e STORAGE_CONTAINER_NAME -d ${{ env.IMAGE_TAGGED }} | |
- name: Get container ID | |
run: | | |
CONTAINER_ID=$(docker ps -q --filter "ancestor=${{ env.IMAGE_TAGGED }}") | |
echo "CONTAINER_ID=$CONTAINER_ID" >> $GITHUB_ENV | |
- run: docker container logs ${{ env.CONTAINER_ID }} | |
- name: Wait for server | |
timeout-minutes: 1 | |
run: | | |
while ! nc -uvz localhost 5683; do sleep 1; done | |
- name: Run test client (IPv4, old ports) | |
working-directory: client | |
run: ./coap-client -udpPort 5688 -dTLSPort 5689 | |
- name: Run test client (IPv6, old ports) | |
working-directory: client | |
run: ./coap-client -udp6 -udpPort 5688 -dTLSPort 5689 | |
- name: Run test client (IPv4, new ports) | |
working-directory: client | |
run: ./coap-client -udpPort 5683 -dTLSPort 5684 | |
- name: Run test client (IPv6, new ports) | |
working-directory: client | |
run: ./coap-client -udp6 -udpPort 5683 -dTLSPort 5684 | |
- name: Get log file | |
run: | | |
LOG_FILES=`docker exec ${{ env.CONTAINER_ID }} bash -c 'ls /var/log/academy/'` | |
echo $LOG_FILES | tr ' ' '\n' | while read file ; do | |
echo $file | |
docker cp ${CONTAINER_ID}:/var/log/academy/$file ./ | |
done | |
- name: Test log files | |
run: | | |
cat *-coap-*.log > all-coap.log | |
cat all-coap.log | |
grep -E "^20[0-9]{2}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}+[^,]+,coap:dTLS:udp6,request$" all-coap.log | |
grep -E "^20[0-9]{2}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}+[^,]+,coap:UDP:udp6,request$" all-coap.log | |
grep -E "^20[0-9]{2}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}+[^,]+,coap:dTLS:udp4,request$" all-coap.log | |
grep -E "^20[0-9]{2}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}+[^,]+,coap:UDP:udp4,request$" all-coap.log | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: metric-logs-${{ github.sha }} | |
path: | | |
*-coap-*.log | |
- name: Docker logs | |
if: always() | |
run: docker container logs ${{ env.CONTAINER_ID }} | |
- name: Push image to the infrastructure container registry as latest | |
if: github.ref == 'refs/heads/saga' | |
run: | | |
docker login -u ${{ vars.REGISTRY_USERNAME }} -p ${{ secrets.REGISTRY_PASSWORD }} ${{ vars.REGISTRY_LOGIN_SERVER }} | |
docker tag ${{ env.IMAGE_TAGGED }} ${{ env.REPO_IMAGE_TAGGED }} | |
docker push ${{ env.REPO_IMAGE_TAGGED }} | |
docker tag ${{ env.IMAGE_TAGGED }} ${{ env.REPO_IMAGE_LATEST }} | |
docker push ${{ env.REPO_IMAGE_LATEST }} |