Merge remote-tracking branch 'xinyu/fix_relup_testcases' into 0623-fix-relup
This commit is contained in:
commit
0d6c4e0996
|
@ -1,36 +1,41 @@
|
|||
-module(http_server).
|
||||
|
||||
-import(minirest, [ return/0
|
||||
, return/1
|
||||
]).
|
||||
-import(minirest, [
|
||||
return/0,
|
||||
return/1
|
||||
]).
|
||||
|
||||
-export([ start/0
|
||||
, stop/0
|
||||
]).
|
||||
-export([
|
||||
start/0,
|
||||
stop/0
|
||||
]).
|
||||
|
||||
-rest_api(#{ name => get_counter
|
||||
, method => 'GET'
|
||||
, path => "/counter"
|
||||
, func => get_counter
|
||||
, descr => "Check counter"
|
||||
}).
|
||||
-rest_api(#{ name => add_counter
|
||||
, method => 'POST'
|
||||
, path => "/counter"
|
||||
, func => add_counter
|
||||
, descr => "Counter plus one"
|
||||
}).
|
||||
-rest_api(#{
|
||||
name => get_counter,
|
||||
method => 'GET',
|
||||
path => "/counter",
|
||||
func => get_counter,
|
||||
descr => "Check counter"
|
||||
}).
|
||||
-rest_api(#{
|
||||
name => add_counter,
|
||||
method => 'POST',
|
||||
path => "/counter",
|
||||
func => add_counter,
|
||||
descr => "Counter plus one"
|
||||
}).
|
||||
|
||||
-export([ get_counter/2
|
||||
, add_counter/2
|
||||
]).
|
||||
-export([
|
||||
get_counter/2,
|
||||
add_counter/2
|
||||
]).
|
||||
|
||||
start() ->
|
||||
application:ensure_all_started(minirest),
|
||||
ets:new(relup_test_message, [named_table, public]),
|
||||
Handlers = [{"/", minirest:handler(#{modules => [?MODULE]})}],
|
||||
Dispatch = [{"/[...]", minirest, Handlers}],
|
||||
minirest:start_http(?MODULE, #{socket_opts => [inet, {port, 8080}]}, Dispatch).
|
||||
minirest:start_http(?MODULE, #{socket_opts => [inet, {port, 7077}]}, Dispatch).
|
||||
|
||||
stop() ->
|
||||
ets:delete(relup_test_message),
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
[config var=PROFILE]
|
||||
[config var=PACKAGE_PATH]
|
||||
[config var=BENCH_PATH]
|
||||
[config var=ONE_MORE_EMQX_PATH]
|
||||
[config var=VSN]
|
||||
[config var=OLD_VSNS]
|
||||
|
||||
|
@ -16,16 +15,17 @@
|
|||
???Eshell
|
||||
???>
|
||||
!http_server:start().
|
||||
?Start http_server listener on 8080 successfully.
|
||||
?Start http_server listener on 7077 successfully.
|
||||
?ok
|
||||
?>
|
||||
|
||||
[shell emqx1]
|
||||
!cd $PACKAGE_PATH
|
||||
!mkdir -p emqx1
|
||||
!tar -C emqx1 -zxf ${PROFILE}-$(echo $old_vsn | sed -r 's/[v|e]//g')-*-ubuntu20.04-amd64.tar.gz
|
||||
!tar -C emqx -zxf ${PROFILE}-$(echo $old_vsn | sed -r 's/[v|e]//g')-*-ubuntu20.04-amd64.tar.gz
|
||||
?SH-PROMPT
|
||||
!cd emqx1
|
||||
|
||||
!cd emqx
|
||||
!export EMQX_NODE_NAME='emqx1@127.0.0.1'
|
||||
!./bin/emqx start
|
||||
?EMQX .* is started successfully!
|
||||
|
@ -33,15 +33,18 @@
|
|||
|
||||
[shell emqx2]
|
||||
!cd $PACKAGE_PATH
|
||||
!tar -C emqx2 -zxf ${PROFILE}-$(echo $old_vsn | sed -r 's/[v|e]//g')-*-ubuntu20.04-amd64.tar.gz
|
||||
!mkdir -p emqx2
|
||||
!tar -C emqx -zxf ${PROFILE}-$(echo $old_vsn | sed -r 's/[v|e]//g')-*-ubuntu20.04-amd64.tar.gz
|
||||
?SH-PROMPT
|
||||
|
||||
!cd emqx2
|
||||
!export EMQX_NODE_NAME='emqx2@127.0.0.1'
|
||||
!export EMQX_listeners__tcp__default__bind=2883
|
||||
!export EMQX_listeners__ssl__default__bind=9883
|
||||
!export EMQX_listeners__ws__default__bind=9083
|
||||
!export EMQX_listeners__wss__default__bind=9084
|
||||
!export EMQX_NODE__NAME='emqx2@127.0.0.1'
|
||||
!export EMQX_STATSD__SERVER='127.0.0.1:8124'
|
||||
!export EMQX_LISTENERS__TCP__DEFAULT__BIND='0.0.0.0:1882'
|
||||
!export EMQX_LISTENERS__SSL__DEFAULT__BIND='0.0.0.0:8882'
|
||||
!export EMQX_LISTENERS__WS__DEFAULT__BIND='0.0.0.0:8082'
|
||||
!export EMQX_LISTENERS__WSS__DEFAULT__BIND='0.0.0.0:8085'
|
||||
!export EMQX_DASHBOARD__LISTENERS__HTTP__BIND='0.0.0.0:18082'
|
||||
!./bin/emqx start
|
||||
?EMQX .* is started successfully!
|
||||
?SH-PROMPT
|
||||
|
@ -54,12 +57,24 @@
|
|||
???["emqx1@127.0.0.1","emqx2@127.0.0.1"]
|
||||
?SH-PROMPT
|
||||
|
||||
# TODO find another way to create resource
|
||||
# !./bin/emqx_ctl resources create 'web_hook' -i 'resource:691c29ba' -c '{"url": "http://127.0.0.1:8080/counter", "method": "POST"}'
|
||||
# ?created
|
||||
# ?SH-PROMPT
|
||||
# !./bin/emqx_ctl rules create 'SELECT * FROM "t/#"' '[{"name":"data_to_webserver", "params": {"$$resource": "resource:691c29ba"}}]'
|
||||
# ?created
|
||||
## create a webhook data bridge with id "my_webhook"
|
||||
!curl --user admin:public --silent --show-error 'http://localhost:18083/api/v5/bridges' -X 'POST' -H 'Content-Type: application/json' --data-binary '{"name":"my_webhook","method":"post","url":"http://127.0.0.1:7077/counter","headers":{"content-type":"application/json"},"pool_size":4,"enable_pipelining":100,"connect_timeout":"5s","request_timeout":"5s","max_retries":3,"type":"webhook","ssl":{"enable":false,"verify":"verify_none"}}' | jq '.status'
|
||||
?connected
|
||||
?SH-PROMPT
|
||||
|
||||
## create a rule that uses the webhook as action, the rule id = "rule_edsy"
|
||||
!curl --user admin:public --silent --show-error 'http://localhost:18083/api/v5/rules' -X 'POST' -H 'Content-Type: application/json' --data-binary '{"id":"rule_edsy","sql":"SELECT\n *\nFROM\n \"t/#\"","actions":["webhook:my_webhook"]}' | jq '.id'
|
||||
?rule_edsy
|
||||
?SH-PROMPT
|
||||
|
||||
[shell emqx1]
|
||||
## verify the bridges and rules are sync to the other node
|
||||
!curl --user admin:public --silent --show-error 'http://localhost:18083/api/v5/bridges/webhook:my_webhook' -X 'GET' -H 'Content-Type: application/json' | jq '.name'
|
||||
?my_webhook
|
||||
?SH-PROMPT
|
||||
!curl --user admin:public --silent --show-error 'http://localhost:18083/api/v5/rules/rule_edsy' -X 'GET' -H 'Content-Type: application/json' | jq '.id'
|
||||
?rule_edsy
|
||||
?SH-PROMPT
|
||||
|
||||
[shell bench]
|
||||
!cd $BENCH_PATH
|
||||
|
@ -153,14 +168,18 @@
|
|||
!sleep 5
|
||||
?SH-PROMPT
|
||||
|
||||
# TODO adjust rule metrics query API
|
||||
# !curl --user admin:public --silent --show-error http://localhost:18083/api/v5/rules | jq --raw-output ".[0].node_metrics[] | select(.node==\"emqx@127.0.0.1\") | .metrics.matched"
|
||||
# ?300
|
||||
# ?SH-PROMPT
|
||||
!curl --user admin:public --silent --show-error http://localhost:18083/api/v5/rules | jq --raw-output ".[0].node_metrics[] | select(.node==\"emqx@127.0.0.1\") | .metrics.matched"
|
||||
?300
|
||||
?SH-PROMPT
|
||||
|
||||
# !curl --user admin:public --silent --show-error http://localhost:18083/api/v5/rules | jq --raw-output ".[0].node_metrics[] | select(.node==\"emqx@127.0.0.1\") | .metrics.\"actions.success\""
|
||||
# ?\{"data":(29[0-9])|(300),"code":0\}
|
||||
# ?SH-PROMPT
|
||||
!curl --user admin:public --silent --show-error http://localhost:18083/api/v5/rules | jq --raw-output ".[0].node_metrics[] | select(.node==\"emqx@127.0.0.1\") | .metrics.\"actions.success\""
|
||||
?\{"data":(29[0-9])|(300),"code":0\}
|
||||
?SH-PROMPT
|
||||
|
||||
## The /counter API is provided by .ci/fvt_test/http_server
|
||||
!curl http://127.0.0.1:7077/counter
|
||||
?\{"data":(29[0-9])|(300),"code":0\}
|
||||
?SH-PROMPT
|
||||
|
||||
[shell emqx2]
|
||||
!cat log/emqx.log.1 |grep -v 691c29ba |tail -n 100
|
||||
|
|
|
@ -15,6 +15,8 @@ on:
|
|||
|
||||
jobs:
|
||||
relup_test:
|
||||
runs-on: aws-amd64
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
profile:
|
||||
|
@ -32,13 +34,13 @@ jobs:
|
|||
arch:
|
||||
- amd64
|
||||
|
||||
runs-on: ubuntu-20.04
|
||||
container: "ghcr.io/emqx/emqx-builder/5.0-16:${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.os }}"
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
steps:
|
||||
- uses: AutoModality/action-clean@v1
|
||||
- uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.8'
|
||||
|
@ -67,10 +69,8 @@ jobs:
|
|||
- name: Get old vsn
|
||||
run: |
|
||||
set -x
|
||||
OLD_VSNS="$(emqx/scripts/relup-base-vsns.sh ${{ matrix.profile }} | xargs echo -n)"
|
||||
NOW_VSN=$(emqx/pkg-vsn.sh ${{ matrix.profile }})
|
||||
echo "OLD_VSNS=$OLD_VSNS" >> $GITHUB_ENV
|
||||
echo "NOW_VSN=$NOW_VSN" >> $GITHUB_ENV
|
||||
echo "OLD_VSNS=$(emqx/scripts/relup-base-vsns.sh ${{ matrix.profile }} | xargs echo -n)" >> $GITHUB_ENV
|
||||
echo "NOW_VSN=$(emqx/pkg-vsn.sh ${{ matrix.profile }})" >> $GITHUB_ENV
|
||||
|
||||
- name: build emqx
|
||||
env:
|
||||
|
@ -101,7 +101,6 @@ jobs:
|
|||
--var PROFILE=$PROFILE \
|
||||
--var PACKAGE_PATH=$(pwd)/packages \
|
||||
--var BENCH_PATH=$(pwd)/emqtt-bench \
|
||||
--var ONE_MORE_EMQX_PATH=$(pwd)/one_more_emqx \
|
||||
--var VSN="$NOW_VSN" \
|
||||
--var OLD_VSNS="$OLD_VSNS" \
|
||||
emqx/.ci/fvt_tests/relup.lux
|
||||
|
|
Loading…
Reference in New Issue