From 76f066d552dac0f076e13afbf1f7c15088f9efa6 Mon Sep 17 00:00:00 2001 From: Mengyi Wang Date: Thu, 30 Mar 2023 16:08:46 +0200 Subject: [PATCH 1/6] Extend the UC testing workflow to add config provider snap Extend the UC testing workflow to add config provider snap --- test/suites/ubuntu-core-edgex-image/README.md | 47 +++++++++++++++---- test/suites/ubuntu-core-edgex-image/build.sh | 45 +++++++++++++----- test/suites/ubuntu-core-edgex-image/run.sh | 2 +- test/suites/ubuntu-core-edgex-image/test.sh | 38 ++++++++++----- 4 files changed, 100 insertions(+), 32 deletions(-) diff --git a/test/suites/ubuntu-core-edgex-image/README.md b/test/suites/ubuntu-core-edgex-image/README.md index 9515f73c..6bfa1c5c 100644 --- a/test/suites/ubuntu-core-edgex-image/README.md +++ b/test/suites/ubuntu-core-edgex-image/README.md @@ -49,15 +49,44 @@ Once you see the SSH command and the IP address, open a new terminal to test the ``` $ USER= ./test.sh -# {"apiVersion":"v2","timestamp":"Wed Mar 22 18:05:07 UTC 2023","serviceName":"core-data"} -# {"apiVersion":"v2","timestamp":"Wed Mar 22 18:05:07 UTC 2023","serviceName":"core-metadata"} -# {"apiVersion":"v2","timestamp":"Wed Mar 22 18:05:07 UTC 2023","serviceName":"core-command"} -# { -# "security": false -# } +# Install curl on host: +curl 8.0.1 from Wouter van Bommel (woutervb) installed -# Service Startup Current Notes -# edgex-device-virtual.device-virtual enabled active - +# Check status of core services inside of the emulator: +{"apiVersion":"v2","timestamp":"Thu Mar 30 13:36:10 UTC 2023","serviceName":"core-data"} +{"apiVersion":"v2","timestamp":"Thu Mar 30 13:36:10 UTC 2023","serviceName":"core-metadata"} +{"apiVersion":"v2","timestamp":"Thu Mar 30 13:36:10 UTC 2023","serviceName":"core-command"} -# 2023-03-22T17:51:27Z edgex-device-virtual.device-virtual[3874]: level=INFO ts=2023-03-22T17:51:27.022824501Z app=device-virtual source=variables.go:377 msg="Variables override of 'Service.StartupMsg' by environment variable: SERVICE_STARTUPMSG=Startup message from gadget!" +# Verify that the security is avaliable as a snap option of edgexfoundry within the emulator: +{ + "security": false +} + +# Check the status of the device-virtual service within the emulator: +Service Startup Current Notes +edgex-device-virtual.device-virtual enabled active - + +# Access the service endpoints via API Gateway outside of the emulator: +{"message":"Unauthorized"} + +# List snaps and check edgex-config-provider-example is in the list: +Name Version Rev Tracking Publisher Notes +core20 20230308 1852 latest/stable canonical** base +core22 20230316 583 latest/stable canonical** base +curl 8.0.1 1579 latest/stable woutervb - +edgex-config-provider-example 2.3 6 latest/edge farshidtz - +edgex-device-virtual 2.3.0 335 latest/stable canonical** - +edgexfoundry 2.3.0+1 4108 latest/stable canonical** - +pc 22-0.3 x1 - - gadget +pc-kernel 5.15.0-69.76.1 1258 22/stable canonical** kernel +snapd 2.58.3 18596 latest/stable canonical** snapd + +# Verify that Device Virtual only has one profile, as configured in the config provider: +1 + +# Verify that Device Virtual has the startup message set from the provider: +2023-03-30T12:47:58Z edgex-device-virtual.device-virtual[3965]: level=INFO ts=2023-03-30T12:47:58.514769034Z app=device-virtual source=message.go:55 msg="CONFIG BY EXAMPLE PROVIDER" + +# Query the metadata of Device Virtual from your host machine: +{"message":"Unauthorized"} ``` diff --git a/test/suites/ubuntu-core-edgex-image/build.sh b/test/suites/ubuntu-core-edgex-image/build.sh index da6c0e04..77978d77 100755 --- a/test/suites/ubuntu-core-edgex-image/build.sh +++ b/test/suites/ubuntu-core-edgex-image/build.sh @@ -1,38 +1,49 @@ #!/bin/bash -ex +# Remove the pc-gadget directory if it already exists rm -rf pc-gadget git clone https://github.com/snapcore/pc-gadget.git --branch=22 -# build gadget snap +# Build gadget snap cd pc-gadget -# extend the size of disk partitions to have sufficient capacity for EdgeX snaps -yq e '(.volumes.pc.structure[] | select(.name=="ubuntu-seed") | .size)="1500M"' gadget.yaml -i -# setup default options for snaps +# Extend the size of disk partitions to have sufficient capacity for EdgeX snaps +yq e -i '(.volumes.pc.structure[] | select(.name=="ubuntu-seed") | .size)="1500M"' gadget.yaml + +# Set up default options for snaps # AZGf0KNnh8aqdkbGATNuRuxnt1GNRKkV (edgexfoundry snap) # AmKuVTOfsN0uEKsyJG34M8CaMfnIqxc0 (edgex-device-virtual snap) -yq e '.defaults += { +yq e -i '.defaults += { "AZGf0KNnh8aqdkbGATNuRuxnt1GNRKkV": { "app-options": true, "security": false }, "AmKuVTOfsN0uEKsyJG34M8CaMfnIqxc0": { "autostart": true, - "app-options": true, "apps": { "device-virtual": { "config": { - "service-startupmsg": "Startup message from gadget!", "edgex-security-secret-store": false } } } } -}' gadget.yaml -i +}' gadget.yaml + +# Connect edgex-device-virtual's plug (consumer) to +# edgex-config-provider-example's slot (provider) +# to override the default configuration files. +yq e -i '.connections += [ + { + "plug": "AmKuVTOfsN0uEKsyJG34M8CaMfnIqxc0:device-virtual-config", + "slot": "WWPGZGi1bImphPwrRfw46aP7YMyZYl6w:device-virtual-config" + } + ] + ' gadget.yaml snapcraft -# configure model assertion +# Configure model assertion cd ../ DEVELOPER_ID=$(snapcraft whoami | grep 'id:' | awk '{print $2}') TIMESTAMP=$(date -Iseconds --utc) @@ -40,8 +51,20 @@ yq e -i ".authority-id = \"$DEVELOPER_ID\"" model.yaml yq e -i ".brand-id = \"$DEVELOPER_ID\"" model.yaml yq e -i ".timestamp = \"$TIMESTAMP\"" model.yaml -# sign the model assertion +# Add the config provider snap, which contains configuration files, to the model assertion +yq e -i ' + .snaps += [ + { + "name": "edgex-config-provider-example", + "type": "app", + "default-channel": "latest/edge", + "id": "WWPGZGi1bImphPwrRfw46aP7YMyZYl6w" + } + ] +' model.yaml + +# Sign the model assertion yq eval model.yaml -o=json | snap sign -k $KEY_NAME > model.signed.yaml -# check the signed model +# Check the signed model cat model.signed.yaml diff --git a/test/suites/ubuntu-core-edgex-image/run.sh b/test/suites/ubuntu-core-edgex-image/run.sh index 1b114d0b..ae262376 100755 --- a/test/suites/ubuntu-core-edgex-image/run.sh +++ b/test/suites/ubuntu-core-edgex-image/run.sh @@ -17,6 +17,6 @@ sudo qemu-system-x86_64 \ -machine accel=kvm \ -serial mon:stdio \ -net nic,model=virtio \ - -net user,hostfwd=tcp::8022-:22,hostfwd=tcp::59880-:59880,hostfwd=tcp::8443-:8443 + -net user,hostfwd=tcp::8022-:22,hostfwd=tcp::8443-:8443 diff --git a/test/suites/ubuntu-core-edgex-image/test.sh b/test/suites/ubuntu-core-edgex-image/test.sh index 66911d30..9e1fd64e 100755 --- a/test/suites/ubuntu-core-edgex-image/test.sh +++ b/test/suites/ubuntu-core-edgex-image/test.sh @@ -1,23 +1,39 @@ #!/bin/bash -e -ssh "$USER@localhost" -p 8022 "snap install curl" +SSH_USER="$USER" +SSH_PORT="8022" -# check status of core services inside of the emulator +printf "# Install curl on host:\n" +snap install curl; echo + +printf "# Check status of core services inside of the emulator:\n" ports=(59880 59881 59882) for port in "${ports[@]}" do - ssh "$USER@localhost" -p 8022 "curl -s http://localhost:$port/api/v2/ping; printf '\n'" + ssh "$SSH_USER@localhost" -p $SSH_PORT "curl -s http://localhost:$port/api/v2/ping"; echo done +echo + +printf "# Verify that the security is avaliable as a snap option of edgexfoundry within the emulator:\n" +ssh "$SSH_USER@localhost" -p $SSH_PORT "snap get edgexfoundry security -d"; echo + +printf "# Check the status of the device-virtual service within the emulator:\n" +ssh "$SSH_USER@localhost" -p $SSH_PORT "snap services edgex-device-virtual"; echo + + +printf "# Access the service endpoints via API Gateway outside of the emulator:\n" +curl --insecure --show-err https://localhost:8443/core-data/api/v2/ping; echo +echo -# verify that the security is avaliable as a snap option of edgexfoundry within the emulator -ssh "$USER@localhost" -p 8022 "snap get edgexfoundry security -d; printf '\n'" +printf "# List snaps and check edgex-config-provider-example is in the list:\n" +ssh "$SSH_USER@localhost" -p $SSH_PORT 'snap list'; echo -# check the status of the device-virtual service within the emulator -ssh "$USER@localhost" -p 8022 "snap services edgex-device-virtual; printf '\n'" +printf "# Verify that Device Virtual only has one profile, as configured in the config provider:\n" +ssh "$SSH_USER@localhost" -p $SSH_PORT 'curl --silent http://localhost:59881/api/v2/deviceprofile/all' | jq '.totalCount'; echo -# verify that device-virtual has the startup message set from the gadget within the emulator -ssh "$USER@localhost" -p 8022 'snap logs -n=all edgex-device-virtual | grep "Startup message"; printf '\n'' +printf "# Verify that Device Virtual has the startup message set from the provider:\n" +ssh "$SSH_USER@localhost" -p $SSH_PORT 'snap logs -n=all edgex-device-virtual | grep "CONFIG BY EXAMPLE PROVIDER"'; echo -# access the service endpoints via API Gateway outside of the emulator -curl --insecure --show-err https://localhost:8443/core-data/api/v2/ping +printf "# Query the metadata of Device Virtual from your host machine:\n" +curl --insecure --silent --show-err https://localhost:8443/core-data/api/v2/reading/all; echo From de6959fc19344762c420a64341092fe247181d32 Mon Sep 17 00:00:00 2001 From: Mengyi Wang Date: Fri, 31 Mar 2023 10:22:00 +0200 Subject: [PATCH 2/6] Update the format - disable the security feature of edgexfoundry in V2 format - directly modify the 'mmodel.yaml' file - update the format in the 'test.sh' script --- test/suites/ubuntu-core-edgex-image/build.sh | 14 +------ .../suites/ubuntu-core-edgex-image/model.yaml | 4 ++ test/suites/ubuntu-core-edgex-image/test.sh | 40 +++++++++---------- 3 files changed, 24 insertions(+), 34 deletions(-) diff --git a/test/suites/ubuntu-core-edgex-image/build.sh b/test/suites/ubuntu-core-edgex-image/build.sh index 77978d77..e408860b 100755 --- a/test/suites/ubuntu-core-edgex-image/build.sh +++ b/test/suites/ubuntu-core-edgex-image/build.sh @@ -16,7 +16,7 @@ yq e -i '(.volumes.pc.structure[] | select(.name=="ubuntu-seed") | .size)="1500M yq e -i '.defaults += { "AZGf0KNnh8aqdkbGATNuRuxnt1GNRKkV": { "app-options": true, - "security": false + "security-secret-store": "off" }, "AmKuVTOfsN0uEKsyJG34M8CaMfnIqxc0": { "autostart": true, @@ -51,18 +51,6 @@ yq e -i ".authority-id = \"$DEVELOPER_ID\"" model.yaml yq e -i ".brand-id = \"$DEVELOPER_ID\"" model.yaml yq e -i ".timestamp = \"$TIMESTAMP\"" model.yaml -# Add the config provider snap, which contains configuration files, to the model assertion -yq e -i ' - .snaps += [ - { - "name": "edgex-config-provider-example", - "type": "app", - "default-channel": "latest/edge", - "id": "WWPGZGi1bImphPwrRfw46aP7YMyZYl6w" - } - ] -' model.yaml - # Sign the model assertion yq eval model.yaml -o=json | snap sign -k $KEY_NAME > model.signed.yaml diff --git a/test/suites/ubuntu-core-edgex-image/model.yaml b/test/suites/ubuntu-core-edgex-image/model.yaml index 222f0cce..bab04149 100644 --- a/test/suites/ubuntu-core-edgex-image/model.yaml +++ b/test/suites/ubuntu-core-edgex-image/model.yaml @@ -41,3 +41,7 @@ snaps: type: app default-channel: latest/stable id: AmKuVTOfsN0uEKsyJG34M8CaMfnIqxc0 + - name: edgex-config-provider-example + type: app + default-channel: latest/edge + id: WWPGZGi1bImphPwrRfw46aP7YMyZYl6w diff --git a/test/suites/ubuntu-core-edgex-image/test.sh b/test/suites/ubuntu-core-edgex-image/test.sh index 9e1fd64e..5f0b8b6c 100755 --- a/test/suites/ubuntu-core-edgex-image/test.sh +++ b/test/suites/ubuntu-core-edgex-image/test.sh @@ -1,39 +1,37 @@ -#!/bin/bash -e +#!/bin/bash -ex SSH_USER="$USER" SSH_PORT="8022" -printf "# Install curl on host:\n" -snap install curl; echo +# Install curl on host +snap install curl; echo -e "\n" -printf "# Check status of core services inside of the emulator:\n" +# Check status of core services inside of the emulator ports=(59880 59881 59882) for port in "${ports[@]}" do - ssh "$SSH_USER@localhost" -p $SSH_PORT "curl -s http://localhost:$port/api/v2/ping"; echo + ssh "$SSH_USER@localhost" -p $SSH_PORT "curl -s http://localhost:$port/api/v2/ping"; echo -e "\n" done -echo -printf "# Verify that the security is avaliable as a snap option of edgexfoundry within the emulator:\n" -ssh "$SSH_USER@localhost" -p $SSH_PORT "snap get edgexfoundry security -d"; echo +# Verify that the security is avaliable as a snap option of edgexfoundry within the emulator +ssh "$SSH_USER@localhost" -p $SSH_PORT "snap get edgexfoundry security -d"; echo -e "\n" -printf "# Check the status of the device-virtual service within the emulator:\n" -ssh "$SSH_USER@localhost" -p $SSH_PORT "snap services edgex-device-virtual"; echo +# Check the status of the device-virtual service within the emulator +ssh "$SSH_USER@localhost" -p $SSH_PORT "snap services edgex-device-virtual"; echo -e "\n" -printf "# Access the service endpoints via API Gateway outside of the emulator:\n" -curl --insecure --show-err https://localhost:8443/core-data/api/v2/ping; echo -echo +# Access the service endpoints via API Gateway outside of the emulator +curl --insecure --show-err https://localhost:8443/core-data/api/v2/ping; echo -e "\n" -printf "# List snaps and check edgex-config-provider-example is in the list:\n" -ssh "$SSH_USER@localhost" -p $SSH_PORT 'snap list'; echo +# List snaps and check edgex-config-provider-example is in the list +ssh "$SSH_USER@localhost" -p $SSH_PORT 'snap list'; echo -e "\n" -printf "# Verify that Device Virtual only has one profile, as configured in the config provider:\n" -ssh "$SSH_USER@localhost" -p $SSH_PORT 'curl --silent http://localhost:59881/api/v2/deviceprofile/all' | jq '.totalCount'; echo +# Verify that Device Virtual only has one profile, as configured in the config provider +ssh "$SSH_USER@localhost" -p $SSH_PORT 'curl --silent http://localhost:59881/api/v2/deviceprofile/all' | jq '.totalCount'; echo -e "\n" -printf "# Verify that Device Virtual has the startup message set from the provider:\n" -ssh "$SSH_USER@localhost" -p $SSH_PORT 'snap logs -n=all edgex-device-virtual | grep "CONFIG BY EXAMPLE PROVIDER"'; echo +# Verify that Device Virtual has the startup message set from the provider +ssh "$SSH_USER@localhost" -p $SSH_PORT 'snap logs -n=all edgex-device-virtual | grep "CONFIG BY EXAMPLE PROVIDER"'; echo -e "\n" -printf "# Query the metadata of Device Virtual from your host machine:\n" -curl --insecure --silent --show-err https://localhost:8443/core-data/api/v2/reading/all; echo +# Query the metadata of Device Virtual from your host machine +curl --insecure --silent --show-err https://localhost:8443/core-data/api/v2/reading/all; echo -e "\n" From af44979e38c6dc69bd337757dc996bc4f7b8abfe Mon Sep 17 00:00:00 2001 From: Mengyi Wang Date: Fri, 31 Mar 2023 16:36:23 +0200 Subject: [PATCH 3/6] Remove echo newlines --- test/suites/ubuntu-core-edgex-image/test.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/suites/ubuntu-core-edgex-image/test.sh b/test/suites/ubuntu-core-edgex-image/test.sh index 5f0b8b6c..dcf276d8 100755 --- a/test/suites/ubuntu-core-edgex-image/test.sh +++ b/test/suites/ubuntu-core-edgex-image/test.sh @@ -4,34 +4,34 @@ SSH_USER="$USER" SSH_PORT="8022" # Install curl on host -snap install curl; echo -e "\n" +snap install curl # Check status of core services inside of the emulator ports=(59880 59881 59882) for port in "${ports[@]}" do - ssh "$SSH_USER@localhost" -p $SSH_PORT "curl -s http://localhost:$port/api/v2/ping"; echo -e "\n" + ssh "$SSH_USER@localhost" -p $SSH_PORT "curl -s http://localhost:$port/api/v2/ping" done # Verify that the security is avaliable as a snap option of edgexfoundry within the emulator -ssh "$SSH_USER@localhost" -p $SSH_PORT "snap get edgexfoundry security -d"; echo -e "\n" +ssh "$SSH_USER@localhost" -p $SSH_PORT "snap get edgexfoundry security -d" # Check the status of the device-virtual service within the emulator -ssh "$SSH_USER@localhost" -p $SSH_PORT "snap services edgex-device-virtual"; echo -e "\n" +ssh "$SSH_USER@localhost" -p $SSH_PORT "snap services edgex-device-virtual" # Access the service endpoints via API Gateway outside of the emulator -curl --insecure --show-err https://localhost:8443/core-data/api/v2/ping; echo -e "\n" +curl --insecure --show-err https://localhost:8443/core-data/api/v2/ping # List snaps and check edgex-config-provider-example is in the list -ssh "$SSH_USER@localhost" -p $SSH_PORT 'snap list'; echo -e "\n" +ssh "$SSH_USER@localhost" -p $SSH_PORT 'snap list' # Verify that Device Virtual only has one profile, as configured in the config provider -ssh "$SSH_USER@localhost" -p $SSH_PORT 'curl --silent http://localhost:59881/api/v2/deviceprofile/all' | jq '.totalCount'; echo -e "\n" +ssh "$SSH_USER@localhost" -p $SSH_PORT 'curl --silent http://localhost:59881/api/v2/deviceprofile/all' | jq '.totalCount' # Verify that Device Virtual has the startup message set from the provider -ssh "$SSH_USER@localhost" -p $SSH_PORT 'snap logs -n=all edgex-device-virtual | grep "CONFIG BY EXAMPLE PROVIDER"'; echo -e "\n" +ssh "$SSH_USER@localhost" -p $SSH_PORT 'snap logs -n=all edgex-device-virtual | grep "CONFIG BY EXAMPLE PROVIDER"' # Query the metadata of Device Virtual from your host machine -curl --insecure --silent --show-err https://localhost:8443/core-data/api/v2/reading/all; echo -e "\n" +curl --insecure --silent --show-err https://localhost:8443/core-data/api/v2/reading/all From f4342e24908a8bd39efbb441c9de1504ae96e40d Mon Sep 17 00:00:00 2001 From: Mengyi Wang Date: Mon, 3 Apr 2023 17:04:41 +0200 Subject: [PATCH 4/6] Simplfy scripts, update default channel --- test/suites/ubuntu-core-edgex-image/README.md | 7 ------- .../suites/ubuntu-core-edgex-image/model.yaml | 2 +- test/suites/ubuntu-core-edgex-image/run.sh | 2 +- test/suites/ubuntu-core-edgex-image/test.sh | 19 +++++++------------ 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/test/suites/ubuntu-core-edgex-image/README.md b/test/suites/ubuntu-core-edgex-image/README.md index 6bfa1c5c..0ef5fe73 100644 --- a/test/suites/ubuntu-core-edgex-image/README.md +++ b/test/suites/ubuntu-core-edgex-image/README.md @@ -49,8 +49,6 @@ Once you see the SSH command and the IP address, open a new terminal to test the ``` $ USER= ./test.sh -# Install curl on host: -curl 8.0.1 from Wouter van Bommel (woutervb) installed # Check status of core services inside of the emulator: {"apiVersion":"v2","timestamp":"Thu Mar 30 13:36:10 UTC 2023","serviceName":"core-data"} @@ -66,9 +64,6 @@ curl 8.0.1 from Wouter van Bommel (woutervb) installed Service Startup Current Notes edgex-device-virtual.device-virtual enabled active - -# Access the service endpoints via API Gateway outside of the emulator: -{"message":"Unauthorized"} - # List snaps and check edgex-config-provider-example is in the list: Name Version Rev Tracking Publisher Notes core20 20230308 1852 latest/stable canonical** base @@ -87,6 +82,4 @@ snapd 2.58.3 18596 latest/stable canonical** # Verify that Device Virtual has the startup message set from the provider: 2023-03-30T12:47:58Z edgex-device-virtual.device-virtual[3965]: level=INFO ts=2023-03-30T12:47:58.514769034Z app=device-virtual source=message.go:55 msg="CONFIG BY EXAMPLE PROVIDER" -# Query the metadata of Device Virtual from your host machine: -{"message":"Unauthorized"} ``` diff --git a/test/suites/ubuntu-core-edgex-image/model.yaml b/test/suites/ubuntu-core-edgex-image/model.yaml index bab04149..0d69372c 100644 --- a/test/suites/ubuntu-core-edgex-image/model.yaml +++ b/test/suites/ubuntu-core-edgex-image/model.yaml @@ -43,5 +43,5 @@ snaps: id: AmKuVTOfsN0uEKsyJG34M8CaMfnIqxc0 - name: edgex-config-provider-example type: app - default-channel: latest/edge + default-channel: latest/stable id: WWPGZGi1bImphPwrRfw46aP7YMyZYl6w diff --git a/test/suites/ubuntu-core-edgex-image/run.sh b/test/suites/ubuntu-core-edgex-image/run.sh index ae262376..50e71da0 100755 --- a/test/suites/ubuntu-core-edgex-image/run.sh +++ b/test/suites/ubuntu-core-edgex-image/run.sh @@ -17,6 +17,6 @@ sudo qemu-system-x86_64 \ -machine accel=kvm \ -serial mon:stdio \ -net nic,model=virtio \ - -net user,hostfwd=tcp::8022-:22,hostfwd=tcp::8443-:8443 + -net user,hostfwd=tcp::8022-:22 diff --git a/test/suites/ubuntu-core-edgex-image/test.sh b/test/suites/ubuntu-core-edgex-image/test.sh index dcf276d8..a0d775d6 100755 --- a/test/suites/ubuntu-core-edgex-image/test.sh +++ b/test/suites/ubuntu-core-edgex-image/test.sh @@ -2,6 +2,7 @@ SSH_USER="$USER" SSH_PORT="8022" +alias remote_call="ssh \"$SSH_USER@localhost\" -p $SSH_PORT" # Install curl on host snap install curl @@ -11,27 +12,21 @@ ports=(59880 59881 59882) for port in "${ports[@]}" do - ssh "$SSH_USER@localhost" -p $SSH_PORT "curl -s http://localhost:$port/api/v2/ping" + remote_call "curl -s http://localhost:$port/api/v2/ping" done # Verify that the security is avaliable as a snap option of edgexfoundry within the emulator -ssh "$SSH_USER@localhost" -p $SSH_PORT "snap get edgexfoundry security -d" +remote_call "snap get edgexfoundry security -d" # Check the status of the device-virtual service within the emulator -ssh "$SSH_USER@localhost" -p $SSH_PORT "snap services edgex-device-virtual" - - -# Access the service endpoints via API Gateway outside of the emulator -curl --insecure --show-err https://localhost:8443/core-data/api/v2/ping +remote_call "snap services edgex-device-virtual" # List snaps and check edgex-config-provider-example is in the list -ssh "$SSH_USER@localhost" -p $SSH_PORT 'snap list' +remote_call 'snap list' # Verify that Device Virtual only has one profile, as configured in the config provider -ssh "$SSH_USER@localhost" -p $SSH_PORT 'curl --silent http://localhost:59881/api/v2/deviceprofile/all' | jq '.totalCount' +remote_call 'curl --silent http://localhost:59881/api/v2/deviceprofile/all' | jq '.totalCount' # Verify that Device Virtual has the startup message set from the provider -ssh "$SSH_USER@localhost" -p $SSH_PORT 'snap logs -n=all edgex-device-virtual | grep "CONFIG BY EXAMPLE PROVIDER"' +remote_call 'snap logs -n=all edgex-device-virtual | grep "CONFIG BY EXAMPLE PROVIDER"' -# Query the metadata of Device Virtual from your host machine -curl --insecure --silent --show-err https://localhost:8443/core-data/api/v2/reading/all From 09f9b8e6b7bf51372d7cf42bd27bacddd5827bc1 Mon Sep 17 00:00:00 2001 From: Mengyi Wang Date: Tue, 4 Apr 2023 09:56:07 +0200 Subject: [PATCH 5/6] Update test.sh and output in readme --- test/suites/ubuntu-core-edgex-image/README.md | 48 +++++++++++-------- test/suites/ubuntu-core-edgex-image/test.sh | 11 +++-- 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/test/suites/ubuntu-core-edgex-image/README.md b/test/suites/ubuntu-core-edgex-image/README.md index 0ef5fe73..4de86756 100644 --- a/test/suites/ubuntu-core-edgex-image/README.md +++ b/test/suites/ubuntu-core-edgex-image/README.md @@ -49,37 +49,47 @@ Once you see the SSH command and the IP address, open a new terminal to test the ``` $ USER= ./test.sh - -# Check status of core services inside of the emulator: -{"apiVersion":"v2","timestamp":"Thu Mar 30 13:36:10 UTC 2023","serviceName":"core-data"} -{"apiVersion":"v2","timestamp":"Thu Mar 30 13:36:10 UTC 2023","serviceName":"core-metadata"} -{"apiVersion":"v2","timestamp":"Thu Mar 30 13:36:10 UTC 2023","serviceName":"core-command"} - -# Verify that the security is avaliable as a snap option of edgexfoundry within the emulator: ++ SSH_USER= ++ SSH_PORT=8022 ++ remote_call 'snap install curl' ++ ssh @localhost -p 8022 'snap install curl' +curl 8.0.1 from Wouter van Bommel (woutervb) installed ++ ports=(59880 59881 59882) ++ for port in "${ports[@]}" ++ remote_call 'curl -s http://localhost:59880/api/v2/ping' ++ ssh @localhost -p 8022 'curl -s http://localhost:59880/api/v2/ping' +{"apiVersion":"v2","timestamp":"Tue Apr 4 07:33:14 UTC 2023","serviceName":"core-data"}+ for port in "${ports[@]}" ++ remote_call 'curl -s http://localhost:59881/api/v2/ping' ++ ssh @localhost -p 8022 'curl -s http://localhost:59881/api/v2/ping' +{"apiVersion":"v2","timestamp":"Tue Apr 4 07:33:14 UTC 2023","serviceName":"core-metadata"}+ for port in "${ports[@]}" ++ remote_call 'curl -s http://localhost:59882/api/v2/ping' ++ ssh @localhost -p 8022 'curl -s http://localhost:59882/api/v2/ping' +{"apiVersion":"v2","timestamp":"Tue Apr 4 07:33:14 UTC 2023","serviceName":"core-command"}+ remote_call 'snap get edgexfoundry security-secret-store -d' ++ ssh @localhost -p 8022 'snap get edgexfoundry security-secret-store -d' { - "security": false + "security-secret-store": "off" } - -# Check the status of the device-virtual service within the emulator: ++ remote_call 'snap services edgex-device-virtual' ++ ssh @localhost -p 8022 'snap services edgex-device-virtual' Service Startup Current Notes edgex-device-virtual.device-virtual enabled active - - -# List snaps and check edgex-config-provider-example is in the list: ++ remote_call 'snap list' ++ ssh @localhost -p 8022 'snap list' Name Version Rev Tracking Publisher Notes core20 20230308 1852 latest/stable canonical** base core22 20230316 583 latest/stable canonical** base curl 8.0.1 1579 latest/stable woutervb - -edgex-config-provider-example 2.3 6 latest/edge farshidtz - +edgex-config-provider-example 2.3 6 latest/stable farshidtz - edgex-device-virtual 2.3.0 335 latest/stable canonical** - edgexfoundry 2.3.0+1 4108 latest/stable canonical** - pc 22-0.3 x1 - - gadget pc-kernel 5.15.0-69.76.1 1258 22/stable canonical** kernel snapd 2.58.3 18596 latest/stable canonical** snapd - -# Verify that Device Virtual only has one profile, as configured in the config provider: -1 - -# Verify that Device Virtual has the startup message set from the provider: -2023-03-30T12:47:58Z edgex-device-virtual.device-virtual[3965]: level=INFO ts=2023-03-30T12:47:58.514769034Z app=device-virtual source=message.go:55 msg="CONFIG BY EXAMPLE PROVIDER" ++ remote_call 'curl --silent http://localhost:59881/api/v2/deviceprofile/all' ++ ssh @localhost -p 8022 'curl --silent http://localhost:59881/api/v2/deviceprofile/all' ++ jq .totalCount +0 ++ remote_call 'snap logs -n=all edgex-device-virtual | grep "CONFIG BY EXAMPLE PROVIDER"' ++ ssh @localhost -p 8022 'snap logs -n=all edgex-device-virtual | grep "CONFIG BY EXAMPLE PROVIDER"' ``` diff --git a/test/suites/ubuntu-core-edgex-image/test.sh b/test/suites/ubuntu-core-edgex-image/test.sh index a0d775d6..1ac430b1 100755 --- a/test/suites/ubuntu-core-edgex-image/test.sh +++ b/test/suites/ubuntu-core-edgex-image/test.sh @@ -2,10 +2,13 @@ SSH_USER="$USER" SSH_PORT="8022" -alias remote_call="ssh \"$SSH_USER@localhost\" -p $SSH_PORT" +remote_call() { + ssh "$SSH_USER@localhost" -p $SSH_PORT "$@" +} -# Install curl on host -snap install curl + +# Install curl on emulator +remote_call "snap install curl" # Check status of core services inside of the emulator ports=(59880 59881 59882) @@ -16,7 +19,7 @@ do done # Verify that the security is avaliable as a snap option of edgexfoundry within the emulator -remote_call "snap get edgexfoundry security -d" +remote_call "snap get edgexfoundry security-secret-store -d" # Check the status of the device-virtual service within the emulator remote_call "snap services edgex-device-virtual" From a97a64ba0eca9b7eabb42cac3c94ec1dede32bbf Mon Sep 17 00:00:00 2001 From: Mengyi Wang Date: Tue, 4 Apr 2023 11:36:53 +0200 Subject: [PATCH 6/6] [skip ci] Enable dubugging, add style flag to yq --- test/suites/ubuntu-core-edgex-image/build.sh | 14 ++++++++- .../kernel-options/cmdline.full | 29 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100755 test/suites/ubuntu-core-edgex-image/kernel-options/cmdline.full diff --git a/test/suites/ubuntu-core-edgex-image/build.sh b/test/suites/ubuntu-core-edgex-image/build.sh index e408860b..e051d120 100755 --- a/test/suites/ubuntu-core-edgex-image/build.sh +++ b/test/suites/ubuntu-core-edgex-image/build.sh @@ -28,7 +28,8 @@ yq e -i '.defaults += { } } } -}' gadget.yaml +} | .defaults.AZGf0KNnh8aqdkbGATNuRuxnt1GNRKkV.security-secret-store style="double"' gadget.yaml + # Connect edgex-device-virtual's plug (consumer) to # edgex-config-provider-example's slot (provider) @@ -40,7 +41,18 @@ yq e -i '.connections += [ } ] ' gadget.yaml +# Add kernel options for extended logging and a debugging shell +cp -r ../kernel-options/ . +yq e -i '.parts += { + "kernel-options": + { + "source": "kernel-options/", + "plugin": "dump" + } + }' snapcraft.yaml + +# Build gadget snap snapcraft # Configure model assertion diff --git a/test/suites/ubuntu-core-edgex-image/kernel-options/cmdline.full b/test/suites/ubuntu-core-edgex-image/kernel-options/cmdline.full new file mode 100755 index 00000000..93ebee7d --- /dev/null +++ b/test/suites/ubuntu-core-edgex-image/kernel-options/cmdline.full @@ -0,0 +1,29 @@ +# this is the first serial console, pick a suitable one for your device +console=ttyS0 + +# set to get more output from snapd +#snapd.debug=1 + +# these will output more device status/logging to our console, +# which is kinda annoying in that it goes to the same place we +# have our shell, but I think it's more useful to be able to see +# than have a perfectly pristine console, if you have multiple +# consoles you could of course use a different console for +# systemd output and your debug shell +rd.systemd.journald.forward_to_console=1 +systemd.journald.forward_to_console=1 + +# to disable console-conf from running on ttyS0 so we can setup +# our debug shell there, this is the most key part here, without +# this console-conf will kill/prevent from starting our debug shell +systemd.mask=serial-getty@ttyS0.service + +# create our debug shell on ttyS0 +systemd.debug-shell=ttyS0 + +# needed in order to allow the debug-shell to run on UC20 +dangerous + +# standard Ubuntu Core kernel command line parameters +panic=-1 +