canonical / edgex-snap-testing

4 stars 2 forks source link

Upgrade API version to v3 for ekuiper suite #200

Closed MonicaisHer closed 1 year ago

MonicaisHer commented 1 year ago

This PR will enable the ekuiper test to pass once the ekuiper PR has been merged

MonicaisHer commented 1 year ago

Test passed ekuiper snap testing locally using snap built from https://github.com/canonical/edgex-ekuiper-snap/pull/55:

$ LOCAL_SNAP=~/Desktop/copy-symbolic-link/edgex-ekuiper-snap/edgex-ekuiper_1.4.2+snap.3+git43.c6b9687_amd64.snap go test -v ./test/suites/ekuiper/
2023/05/08 14:17:53 [CLEAN]
2023/05/08 14:17:53 [exec] sudo snap remove --purge edgex-ekuiper
2023/05/08 14:17:53 [stderr] snap "edgex-ekuiper" is not installed
2023/05/08 14:17:53 [exec] sudo snap remove --purge edgexfoundry
2023/05/08 14:17:53 [stderr] snap "edgexfoundry" is not installed
2023/05/08 14:17:53 [exec] sudo snap remove --purge edgex-device-virtual
2023/05/08 14:17:53 [stderr] snap "edgex-device-virtual" is not installed
2023/05/08 14:17:53 [SETUP]
2023/05/08 14:17:53 [exec] sudo snap install --dangerous /home/mengyi/Desktop/copy-symbolic-link/edgex-ekuiper-snap/edgex-ekuiper_1.4.2+snap.3+git43.c6b9687_amd64.snap
2023/05/08 14:17:57 [stdout] edgex-ekuiper 1.4.2+snap.3+git43.c6b9687 installed
2023/05/08 14:17:57 [exec] sudo snap install edgexfoundry --channel=latest/edge
2023/05/08 14:18:04 [stdout] edgexfoundry (edge) 3.0.0-dev.150 from Canonical** installed
2023/05/08 14:18:04 [exec] sudo snap install edgex-device-virtual --channel=latest/edge
2023/05/08 14:18:10 [stdout] edgex-device-virtual (edge) 3.0.0-dev.40 from Canonical** installed
2023/05/08 14:18:10 [exec] sudo snap connect edgexfoundry:edgex-secretstore-token edgex-ekuiper:edgex-secretstore-token
2023/05/08 14:18:11 [exec] sudo snap start --enable edgexfoundry
2023/05/08 14:18:38 [stdout] Started.
2023/05/08 14:18:38 Retry 1/180: Waiting for ports: 59880 (core-data), 59881 (core-metadata), 59882 (core-command), 8200 (vault), 8500 (consul), 6379 (redis), 8000 (nginx(http)), 59842 (security-proxy-auth), 8443 (nginx(https))
2023/05/08 14:18:39 Retry 2/180: Waiting for ports: 59880 (core-data), 59881 (core-metadata), 59882 (core-command), 59842 (security-proxy-auth)
=== RUN   TestConfigOption
=== RUN   TestConfigOption/Test_config_option
    config_test.go:26: Set EdgeX Redis Message bus port to 11111 and verify
    exec.go:19: [exec] sudo snap set edgex-ekuiper config.edgex.default.port='11111'
    exec.go:19: [exec] sudo snap start --enable edgex-ekuiper
    exec.go:101: [stdout] Started.
    net.go:143: Retry 1/60: Waiting for ports: 20498 (ekuiper), 59720 (ekuiper/rest-api)
    net.go:143: Retry 2/60: Waiting for ports: 20498 (ekuiper)
    config_test.go:36: Creating stream and rule to trigger the process of applying config option in edgex-ekuiper
    exec.go:19: [exec] edgex-ekuiper.kuiper create stream stream1 '()WITH(FORMAT="JSON",TYPE="edgex")'
    exec.go:19: [exec] edgex-ekuiper.kuiper create rule rule_log '
                                        {
                                                "sql":"SELECT * FROM stream1 WHERE meta(deviceName) != \"device-test\"",
                                                "actions":[
                                                        {
                                                                "log":{}
                                                        }
                                                ]
                                        }'
    net.go:143: Retry 1/180: Waiting for ports: 59880 (core-data), 59881 (core-metadata), 59882 (core-command), 8200 (vault), 8500 (consul), 6379 (redis), 8000 (nginx(http)), 59842 (security-proxy-auth), 8443 (nginx(https))
    config.go:228: Retry 1/10: Waiting for expected content in logs: port:11111
    exec.go:19: [exec] sudo journalctl --since "2023-05-08 14:18:39" --no-pager | grep "edgex-ekuiper"|| true
    config.go:233: Found expected content in logs: port:11111
    config_test.go:52: Unset and check default port
    exec.go:19: [exec] sudo snap unset edgex-ekuiper config.edgex.default.port
    exec.go:19: [exec] sudo snap restart edgex-ekuiper
    exec.go:101: [stdout] Restarted.
    net.go:143: Retry 1/180: Waiting for ports: 59880 (core-data), 59881 (core-metadata), 59882 (core-command), 8200 (vault), 8500 (consul), 6379 (redis), 8000 (nginx(http)), 59842 (security-proxy-auth), 8443 (nginx(https))
    config.go:228: Retry 1/10: Waiting for expected content in logs: port:6379
    exec.go:19: [exec] sudo journalctl --since "2023-05-08 14:18:42" --no-pager | grep "edgex-ekuiper"|| true
    config.go:233: Found expected content in logs: port:6379
=== NAME  TestConfigOption
    exec.go:19: [exec] sudo snap unset edgex-ekuiper config.edgex.default.port
    exec.go:19: [exec] sudo snap stop --disable edgex-ekuiper
    exec.go:101: [stdout] Stopped.
--- PASS: TestConfigOption (6.37s)
    --- PASS: TestConfigOption/Test_config_option (5.53s)
=== RUN   TestCommon
=== RUN   TestCommon/content_interfaces
=== RUN   TestCommon/content_interfaces/seed_secretstore_token
    exec.go:19: [exec] sudo cat /var/snap/edgexfoundry/current/secrets/edgex-ekuiper/secrets-token.json
    exec.go:19: [exec] sudo cat /var/snap/edgex-ekuiper/current/edgex-ekuiper/secrets-token.json
=== RUN   TestCommon/config
=== RUN   TestCommon/config/autostart
=== RUN   TestCommon/config/autostart/set_and_unset_global_autostart
    exec.go:19: [exec] sudo snap stop --disable edgex-ekuiper
    exec.go:101: [stdout] Stopped.
    exec.go:19: [exec] snap services edgex-ekuiper | awk 'FNR == 2 {print $2}'
    exec.go:101: [stdout] disabled
    exec.go:19: [exec] snap services edgex-ekuiper | awk 'FNR == 2 {print $3}'
    exec.go:101: [stdout] inactive
    exec.go:19: [exec] sudo snap set edgex-ekuiper autostart='true'
    exec.go:19: [exec] snap services edgex-ekuiper | awk 'FNR == 2 {print $2}'
    exec.go:101: [stdout] enabled
    exec.go:19: [exec] snap services edgex-ekuiper | awk 'FNR == 2 {print $3}'
    exec.go:101: [stdout] active
    exec.go:19: [exec] sudo snap unset edgex-ekuiper autostart
    exec.go:19: [exec] snap services edgex-ekuiper | awk 'FNR == 2 {print $2}'
    exec.go:101: [stdout] enabled
    exec.go:19: [exec] snap services edgex-ekuiper | awk 'FNR == 2 {print $3}'
    exec.go:101: [stdout] active
    exec.go:19: [exec] sudo snap set edgex-ekuiper autostart='false'
    exec.go:19: [exec] snap services edgex-ekuiper | awk 'FNR == 2 {print $2}'
    exec.go:101: [stdout] disabled
    exec.go:19: [exec] snap services edgex-ekuiper | awk 'FNR == 2 {print $3}'
    exec.go:101: [stdout] inactive
    exec.go:19: [exec] sudo snap unset edgex-ekuiper autostart
    exec.go:19: [exec] sudo snap stop --disable edgex-ekuiper
    exec.go:101: [stdout] Stopped.
=== RUN   TestCommon/net
    exec.go:19: [exec] sudo snap start --enable edgex-ekuiper
    exec.go:101: [stdout] Started.
=== RUN   TestCommon/net/ports_open
    net.go:143: Retry 1/60: Waiting for ports: 20498 (ekuiper), 59720 (ekuiper/rest-api)
=== NAME  TestCommon/net
    net.go:143: Retry 1/60: Waiting for ports: 20498 (ekuiper), 59720 (ekuiper/rest-api)
=== RUN   TestCommon/net/ports_not_listening_on_all_interfaces
    exec.go:19: [exec] sudo lsof -nPi :20498 || true
    net.go:263: Looking for '*:20498 (LISTEN)'
    exec.go:19: [exec] sudo lsof -nPi :59720 || true
    net.go:263: Looking for '*:59720 (LISTEN)'
=== RUN   TestCommon/net/ports_listening_on_localhost
    exec.go:19: [exec] sudo lsof -nPi :20498 || true
    net.go:263: Looking for '127.0.0.1:20498 (LISTEN)'
    exec.go:19: [exec] sudo lsof -nPi :59720 || true
    net.go:263: Looking for '127.0.0.1:59720 (LISTEN)'
=== NAME  TestCommon/net
    exec.go:19: [exec] sudo snap stop --disable edgex-ekuiper
    exec.go:101: [stdout] 2023-05-08T14:18:51+02:00 INFO Waiting for "snap.edgex-ekuiper.kuiperd.service" to stop.
    exec.go:101: [stdout] Stopped.
=== RUN   TestCommon/packaging
=== RUN   TestCommon/packaging/semantic_snap_version
    exec.go:19: [exec] snap info edgex-ekuiper | grep installed | awk '{print $2}'
    exec.go:101: [stdout] 1.4.2+snap.3+git43.c6b9687
--- PASS: TestCommon (10.75s)
    --- PASS: TestCommon/content_interfaces (0.01s)
        --- PASS: TestCommon/content_interfaces/seed_secretstore_token (0.01s)
    --- PASS: TestCommon/config (4.00s)
        --- PASS: TestCommon/config/autostart (4.00s)
            --- PASS: TestCommon/config/autostart/set_and_unset_global_autostart (4.00s)
    --- PASS: TestCommon/net (6.48s)
        --- PASS: TestCommon/net/ports_open (0.00s)
        --- PASS: TestCommon/net/ports_not_listening_on_all_interfaces (0.15s)
        --- PASS: TestCommon/net/ports_listening_on_localhost (0.12s)
    --- PASS: TestCommon/packaging (0.26s)
        --- PASS: TestCommon/packaging/semantic_snap_version (0.26s)
=== RUN   TestStreamsAndRules
    exec.go:19: [exec] sudo snap start --enable edgex-ekuiper
    exec.go:101: [stdout] Started.
    exec.go:19: [exec] sudo snap start --enable edgex-device-virtual
    exec.go:101: [stdout] Started.
=== RUN   TestStreamsAndRules/create_stream
    exec.go:19: [exec] edgex-ekuiper.kuiper create stream stream1 '()WITH(FORMAT="JSON",TYPE="edgex")'
=== RUN   TestStreamsAndRules/create_rule_log
    exec.go:19: [exec] edgex-ekuiper.kuiper create rule rule_log '
                                {
                                        "sql":"SELECT * FROM stream1 WHERE meta(deviceName) != \"device-test\"",
                                        "actions":[
                                                {
                                                        "log":{}
                                                }
                                        ]
                                }'
=== RUN   TestStreamsAndRules/create_rule_edgex_message_bus
    exec.go:19: [exec] edgex-ekuiper.kuiper create rule rule_edgex_message_bus '
                                {
                                   "sql":"SELECT * FROM stream1 WHERE meta(deviceName) != \"device-test\"",
                                   "actions": [
                                          {
                                                 "edgex": {
                                                        "connectionSelector": "edgex.redisMsgBus",
                                                        "topicPrefix": "edgex/events/device", 
                                                        "messageType": "request",
                                                        "deviceName": "device-test"
                                                 }
                                          }
                                   ]
                                }'
=== NAME  TestStreamsAndRules
    net.go:143: Retry 1/60: Waiting for ports: 59900 (device-virtual)
    net.go:143: Retry 2/60: Waiting for ports: 59900 (device-virtual)
=== RUN   TestStreamsAndRules/query_readings_count
    exec.go:19: [exec] ../../utils/login-test-user.sh
    readings.go:19: ID Token for 'example' user: eyJhbGciOiJFUzM4NCIsImtpZCI6IjNhMTAwOTk5LWRmMWMtOTFjNi1lOWViLWRkZTViN2ZhMjMwNCJ9.eyJhdWQiOiJlZGdleCIsImV4cCI6MTY4MzU1MTkzOSwiaWF0IjoxNjgzNTQ4MzM5LCJpc3MiOiIvdjEvaWRlbnRpdHkvb2lkYyIsIm5hbWUiOiJ0ZXN0IiwibmFtZXNwYWNlIjoicm9vdCIsInN1YiI6IjE5MTcxYWNmLTE4NTItOGRmMy1lZGFmLTQ0MDU5NWI2MWQwNyJ9.av-a0W-LpJH8_w7A7Nh5QMsOeyBTHhNaThEGv6UWpHKbY_4YyvmMWy2yWOo3dSOCDkUz3Sfxx9dr3pK8uJPzHniHxFv9Xaj5no11eH3i1l1LsHXRfepjKXRdoYxhFCY9

    readings.go:58: Waiting for readings in Core Data, current retry: 1/60
    readings.go:58: Waiting for readings in Core Data, current retry: 2/60
    readings.go:58: Waiting for readings in Core Data, current retry: 3/60
    readings.go:58: Waiting for readings in Core Data, current retry: 4/60
    readings.go:58: Waiting for readings in Core Data, current retry: 5/60
    readings.go:58: Waiting for readings in Core Data, current retry: 6/60
    readings.go:58: Waiting for readings in Core Data, current retry: 7/60
    readings.go:58: Waiting for readings in Core Data, current retry: 8/60
    readings.go:58: Waiting for readings in Core Data, current retry: 9/60
    readings.go:58: Waiting for readings in Core Data, current retry: 10/60
    readings.go:58: Waiting for readings in Core Data, current retry: 11/60
    readings.go:58: Waiting for readings in Core Data, current retry: 12/60
    readings.go:58: Waiting for readings in Core Data, current retry: 13/60
    readings.go:58: Waiting for readings in Core Data, current retry: 14/60
    readings.go:61: Found readings in Core Data
=== RUN   TestStreamsAndRules/check_rule_log
    streams_rules_test.go:89: Waiting for readings to come from edgex to ekuiper, current retry count: 1/60
    streams_rules_test.go:92: Readings are coming to ekuiper now
=== RUN   TestStreamsAndRules/check_rule_edgex_message_bus
    net.go:143: Retry 1/60: Waiting for ports: 59900 (device-virtual)
    exec.go:19: [exec] ../../utils/login-test-user.sh
    readings.go:19: ID Token for 'example' user: eyJhbGciOiJFUzM4NCIsImtpZCI6IjNhMTAwOTk5LWRmMWMtOTFjNi1lOWViLWRkZTViN2ZhMjMwNCJ9.eyJhdWQiOiJlZGdleCIsImV4cCI6MTY4MzU1MTk1NCwiaWF0IjoxNjgzNTQ4MzU0LCJpc3MiOiIvdjEvaWRlbnRpdHkvb2lkYyIsIm5hbWUiOiJ0ZXN0IiwibmFtZXNwYWNlIjoicm9vdCIsInN1YiI6IjE5MTcxYWNmLTE4NTItOGRmMy1lZGFmLTQ0MDU5NWI2MWQwNyJ9.JPsWukNk4WK3LTLNCR4Moui-3XgK1fN0dDYZzG6FHlOtrb-rl7jgXYgF4_8lKLtQS9LBh4CLe9y9raVkOMdL8imr3tSL3BJhXCC1qTSp-WkYapaIxKfdscQccHWQqxXC

=== NAME  TestStreamsAndRules
    exec.go:19: [exec] sudo snap stop --disable edgex-ekuiper
    exec.go:101: [stdout] Stopped.
    exec.go:19: [exec] sudo snap stop --disable edgex-device-virtual
    exec.go:101: [stdout] 2023-05-08T14:19:16+02:00 INFO Waiting for "snap.edgex-device-virtual.device-virtual.service" to stop.
    exec.go:101: [stdout] Stopped.
--- PASS: TestStreamsAndRules (23.07s)
    --- PASS: TestStreamsAndRules/create_stream (0.04s)
    --- PASS: TestStreamsAndRules/create_rule_log (0.04s)
    --- PASS: TestStreamsAndRules/create_rule_edgex_message_bus (0.04s)
    --- PASS: TestStreamsAndRules/query_readings_count (14.56s)
    --- PASS: TestStreamsAndRules/check_rule_log (1.00s)
    --- PASS: TestStreamsAndRules/check_rule_edgex_message_bus (0.24s)
PASS
2023/05/08 14:19:19 [TEARDOWN]
2023/05/08 14:19:19 [exec] (sudo journalctl --since "2023-05-08 14:17:53" --no-pager | grep "edgex-ekuiper"|| true) > edgex-ekuiper.log
Wrote snap logs to /home/mengyi/Desktop/copy-symbolic-link/edgex-snap-testing/test/suites/ekuiper/edgex-ekuiper.log
2023/05/08 14:19:19 [exec] (sudo journalctl --since "2023-05-08 14:17:53" --no-pager | grep "edgexfoundry"|| true) > edgexfoundry.log
Wrote snap logs to /home/mengyi/Desktop/copy-symbolic-link/edgex-snap-testing/test/suites/ekuiper/edgexfoundry.log
2023/05/08 14:19:19 [exec] (sudo journalctl --since "2023-05-08 14:17:53" --no-pager | grep "edgex-device-virtual"|| true) > edgex-device-virtual.log
Wrote snap logs to /home/mengyi/Desktop/copy-symbolic-link/edgex-snap-testing/test/suites/ekuiper/edgex-device-virtual.log
2023/05/08 14:19:19 Removing installed snap: true
2023/05/08 14:19:19 [exec] sudo snap remove --purge edgex-ekuiper
2023/05/08 14:19:23 [stdout] edgex-ekuiper removed
2023/05/08 14:19:23 [exec] sudo snap remove --purge edgexfoundry
2023/05/08 14:19:24 [stdout] 2023-05-08T14:19:24+02:00 INFO Waiting for "snap.edgexfoundry.support-notifications.service" to stop.
2023/05/08 14:19:26 [stdout] 2023-05-08T14:19:26+02:00 INFO Waiting for "snap.edgexfoundry.core-data.service" to stop.
2023/05/08 14:19:27 [stdout] 2023-05-08T14:19:27+02:00 INFO Waiting for "snap.edgexfoundry.support-scheduler.service" to stop.
2023/05/08 14:19:28 [stdout] 2023-05-08T14:19:28+02:00 INFO Waiting for "snap.edgexfoundry.core-metadata.service" to stop.
2023/05/08 14:19:33 [stdout] edgexfoundry removed
2023/05/08 14:19:33 [exec] sudo snap remove --purge edgex-device-virtual
2023/05/08 14:19:36 [stdout] edgex-device-virtual removed
ok      edgex-snap-testing/test/suites/ekuiper  102.837s