Skip to content

Commit

Permalink
Add test-bridge target
Browse files Browse the repository at this point in the history
  • Loading branch information
Danielius1922 committed Jan 24, 2024
1 parent 946cabd commit 7856097
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .github/workflows/test-with-cfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ jobs:
if: ${{ failure() }}
run: docker logs -t devsim-net-host && cat .tmp/devsim-net-host/0.log

# Run after integration tests, because they first clean-up the output directory
# Run after integration tests, because they always clean-up the output directory
- name: Run bridge tests
run: |
make test-bridge
- name: Run unit tests
if: ${{ inputs.coverage }}
run: |
Expand Down
28 changes: 28 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ CERT_TOOL_SIGN_ALG ?= ECDSA-SHA256
# supported values: P256, P384, P521
CERT_TOOL_ELLIPTIC_CURVE ?= P256
DEVSIM_IMAGE ?= ghcr.io/iotivity/iotivity-lite/cloud-server-discovery-resource-observable-debug:vnext
HUB_TEST_DEVICE_IMAGE = ghcr.io/plgd-dev/hub/test-cloud-server:vnext-pr1202

default: build

Expand Down Expand Up @@ -83,8 +84,35 @@ test: env build-testcontainer
-v $(TMP_PATH):/tmp \
$(SERVICE_NAME):$(VERSION_TAG) -test.parallel 1 -test.v -test.coverprofile=/tmp/coverage.txt

test-bridge:
mkdir -p $(TMP_PATH)/bridge
go build -cover -C ./cmd/ocfbridge -o ./ocfbridge
pkill -KILL ocfbridge || true
GOCOVERDIR=$(TMP_PATH)/bridge ./cmd/ocfbridge/ocfbridge -config ./cmd/ocfbridge/config.yaml &

docker pull $(HUB_TEST_DEVICE_IMAGE)
docker run \
--network=host \
--rm \
--name hub-device-tests \
--env TEST_DEVICE_NAME="bridged-device-0" \
--env TEST_DEVICE_TYPE="bridged" \
--env GRPC_GATEWAY_TEST_DISABLED=1 \
--env IOTIVITY_LITE_TEST_RUN="(TestOffboard|TestOffboardWithRepeat)$$" \
-v $(TMP_PATH):/tmp \
$(HUB_TEST_DEVICE_IMAGE)

pkill -TERM ocfbridge || true
while pgrep -x ocfbridge > /dev/null; do \
echo "waiting for ocfbridge to exit"; \
sleep 1; \
done
go tool covdata textfmt -i=$(TMP_PATH)/bridge -o bridge.coverage.txt

clean:
docker rm -f devsim-net-host || true
docker rm -f hub-device-tests || true
pkill -KILL ocfbridge || true
sudo rm -rf .tmp/*

.PHONY: build-testcontainer build certificates clean env test unit-test

0 comments on commit 7856097

Please sign in to comment.