From 4c93db044d075629bf5fa595d06e3aa5aaa4e0b9 Mon Sep 17 00:00:00 2001 From: Dusan Borovcanin Date: Tue, 31 Dec 2024 14:54:06 +0100 Subject: [PATCH] Move SMQ scripts to MG Signed-off-by: Dusan Borovcanin --- scripts/ci.sh | 10 +++++----- scripts/csv/channels.csv | 3 +++ scripts/csv/clients.csv | 10 ++++++++++ scripts/provision-dev.sh | 30 +++++++++++++++--------------- scripts/run.sh | 20 ++++++++++---------- 5 files changed, 43 insertions(+), 30 deletions(-) create mode 100644 scripts/csv/channels.csv create mode 100644 scripts/csv/clients.csv diff --git a/scripts/ci.sh b/scripts/ci.sh index 48097ea4e..6944ea2aa 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh @@ -49,7 +49,7 @@ setup_protoc() { } setup_mg() { - echo "Setting up Magistrala..." + echo "Setting up SuperMQ..." for p in $(ls *.pb.go); do mv $p $p.tmp done @@ -70,15 +70,15 @@ setup_mg() { fi done echo "Compile check for rabbitmq..." - MG_MESSAGE_BROKER_TYPE=rabbitmq make http + SMQ_MESSAGE_BROKER_TYPE=rabbitmq make http echo "Compile check for redis..." - MG_ES_TYPE=redis make http + SMQ_ES_TYPE=redis make http make -j$NPROC } setup_lint() { # binary will be $(go env GOBIN)/golangci-lint - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOBIN) $GOLANGCI_LINT_VERSION + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/main/install.sh | sh -s -- -b $(go env GOBIN) $GOLANGCI_LINT_VERSION } setup() { @@ -105,7 +105,7 @@ run_test() { } push() { - if test -n "$BRANCH_NAME" && test "$BRANCH_NAME" = "master"; then + if test -n "$BRANCH_NAME" && test "$BRANCH_NAME" = "main"; then echo "Pushing Docker images..." make -j$NPROC latest fi diff --git a/scripts/csv/channels.csv b/scripts/csv/channels.csv new file mode 100644 index 000000000..9b367f7c2 --- /dev/null +++ b/scripts/csv/channels.csv @@ -0,0 +1,3 @@ +channel_1 +channel_2 +channel_3 diff --git a/scripts/csv/clients.csv b/scripts/csv/clients.csv new file mode 100644 index 000000000..b5bc8e7fb --- /dev/null +++ b/scripts/csv/clients.csv @@ -0,0 +1,10 @@ +client_1 +client_2 +client_3 +client_4 +client_5 +client_6 +client_7 +client_8 +client_9 +client_10 diff --git a/scripts/provision-dev.sh b/scripts/provision-dev.sh index 49b508088..437d1a6e5 100755 --- a/scripts/provision-dev.sh +++ b/scripts/provision-dev.sh @@ -5,9 +5,9 @@ # ### -# Provisions example user, thing and channel on a clean Magistrala installation. +# Provisions example user, client and channel on a clean SuperMQ installation. # -# Expects a running Magistrala installation. +# Expects a running SuperMQ installation. # # ### @@ -25,26 +25,26 @@ CHANNEL=$4 #provision user: printf "Provisoning user with email $EMAIL and password $PASSWORD \n" -curl -s -S --cacert docker/ssl/certs/magistrala-server.crt --insecure -X POST -H "Content-Type: application/json" https://localhost/users -d '{"credentials": {"identity": "'"$EMAIL"'","secret": "'"$PASSWORD"'"}, "status": "enabled", "role": "admin" }' +curl -s -S --cacert docker/ssl/certs/supermq-server.crt --insecure -X POST -H "Content-Type: application/json" https://localhost/users -d '{"credentials": {"identity": "'"$EMAIL"'","secret": "'"$PASSWORD"'"}, "status": "enabled", "role": "admin" }' #get jwt token -JWTTOKEN=$(curl -s -S --cacert docker/ssl/certs/magistrala-server.crt --insecure -X POST -H "Content-Type: application/json" https://localhost/users/tokens/issue -d '{"identity":"'"$EMAIL"'", "secret":"'"$PASSWORD"'"}' | grep -oP '"access_token":"\K[^"]+' ) +JWTTOKEN=$(curl -s -S --cacert docker/ssl/certs/supermq-server.crt --insecure -X POST -H "Content-Type: application/json" https://localhost/users/tokens/issue -d '{"identity":"'"$EMAIL"'", "secret":"'"$PASSWORD"'"}' | grep -oP '"access_token":"\K[^"]+' ) printf "JWT TOKEN for user is $JWTTOKEN \n" -#provision thing -printf "Provisioning thing with name $DEVICE \n" -DEVICEID=$(curl -s -S --cacert docker/ssl/certs/magistrala-server.crt --insecure -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $JWTTOKEN" https://localhost/things -d '{"name":"'"$DEVICE"'", "status": "enabled"}' | grep -oP '"id":"\K[^"]+' ) -curl -s -S --cacert docker/ssl/certs/magistrala-server.crt --insecure -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $JWTTOKEN" https://localhost/things/$DEVICEID +#provision client +printf "Provisioning client with name $DEVICE \n" +DEVICEID=$(curl -s -S --cacert docker/ssl/certs/supermq-server.crt --insecure -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $JWTTOKEN" https://localhost/clients -d '{"name":"'"$DEVICE"'", "status": "enabled"}' | grep -oP '"id":"\K[^"]+' ) +curl -s -S --cacert docker/ssl/certs/supermq-server.crt --insecure -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $JWTTOKEN" https://localhost/clients/$DEVICEID -#get thing token -DEVICETOKEN=$(curl -s -S --cacert docker/ssl/certs/magistrala-server.crt --insecure -H "Authorization: Bearer $JWTTOKEN" https://localhost/things/$DEVICEID | grep -oP '"secret":"\K[^"]+' ) +#get client token +DEVICETOKEN=$(curl -s -S --cacert docker/ssl/certs/supermq-server.crt --insecure -H "Authorization: Bearer $JWTTOKEN" https://localhost/clients/$DEVICEID | grep -oP '"secret":"\K[^"]+' ) printf "Device token is $DEVICETOKEN \n" #provision channel printf "Provisioning channel with name $CHANNEL \n" -CHANNELID=$(curl -s -S --cacert docker/ssl/certs/magistrala-server.crt --insecure -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $JWTTOKEN" https://localhost/channels -d '{"name":"'"$CHANNEL"'", "status": "enabled"}' | grep -oP '"id":"\K[^"]+' ) -curl -s -S --cacert docker/ssl/certs/magistrala-server.crt --insecure -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $JWTTOKEN" https://localhost/channels/$CHANNELID +CHANNELID=$(curl -s -S --cacert docker/ssl/certs/supermq-server.crt --insecure -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $JWTTOKEN" https://localhost/channels -d '{"name":"'"$CHANNEL"'", "status": "enabled"}' | grep -oP '"id":"\K[^"]+' ) +curl -s -S --cacert docker/ssl/certs/supermq-server.crt --insecure -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $JWTTOKEN" https://localhost/channels/$CHANNELID -#connect thing to channel -printf "Connecting thing of id $DEVICEID to channel of id $CHANNELID \n" -curl -s -S --cacert docker/ssl/certs/magistrala-server.crt --insecure -X PUT -H "Authorization: Bearer $JWTTOKEN" https://localhost/channels/$CHANNELID/things/$DEVICEID +#connect client to channel +printf "Connecting client of id $DEVICEID to channel of id $CHANNELID \n" +curl -s -S --cacert docker/ssl/certs/supermq-server.crt --insecure -X PUT -H "Authorization: Bearer $JWTTOKEN" https://localhost/channels/$CHANNELID/clients/$DEVICEID diff --git a/scripts/run.sh b/scripts/run.sh index 0cdd52ca6..635f7d8cf 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -3,7 +3,7 @@ # SPDX-License-Identifier: Apache-2.0 ### -# Runs all Magistrala microservices (must be previously built and installed). +# Runs all SuperMQ microservices (must be previously built and installed). # # Expects that PostgreSQL and needed messaging DB are alredy running. # Additionally, MQTT microservice demands that Redis is up and running. @@ -12,9 +12,9 @@ BUILD_DIR=../build -# Kill all magistrala-* stuff +# Kill all supermq-* stuff function cleanup { - pkill magistrala + pkill supermq pkill nats } @@ -38,32 +38,32 @@ done ### # Users ### -MG_USERS_LOG_LEVEL=info MG_USERS_HTTP_PORT=9002 MG_USERS_GRPC_PORT=7001 MG_USERS_ADMIN_EMAIL=admin@magistrala.com MG_USERS_ADMIN_PASSWORD=12345678 MG_USERS_ADMIN_USERNAME=admin MG_EMAIL_TEMPLATE=../docker/templates/users.tmpl $BUILD_DIR/magistrala-users & +SMQ_USERS_LOG_LEVEL=info SMQ_USERS_HTTP_PORT=9002 SMQ_USERS_GRPC_PORT=7001 SMQ_USERS_ADMIN_EMAIL=admin@supermq.com SMQ_USERS_ADMIN_PASSWORD=12345678 SMQ_USERS_ADMIN_USERNAME=admin SMQ_EMAIL_TEMPLATE=../docker/templates/users.tmpl $BUILD_DIR/supermq-users & ### -# Things +# Clients ### -MG_THINGS_LOG_LEVEL=info MG_THINGS_HTTP_PORT=9000 MG_THINGS_AUTH_GRPC_PORT=7000 MG_THINGS_AUTH_HTTP_PORT=9002 $BUILD_DIR/magistrala-things & +SMQ_CLIENTS_LOG_LEVEL=info SMQ_CLIENTS_HTTP_PORT=9000 SMQ_CLIENTS_AUTH_GRPC_PORT=7000 SMQ_CLIENTS_AUTH_HTTP_PORT=9002 $BUILD_DIR/supermq-clients & ### # HTTP ### -MG_HTTP_ADAPTER_LOG_LEVEL=info MG_HTTP_ADAPTER_PORT=8008 MG_THINGS_AUTH_GRPC_URL=localhost:7000 $BUILD_DIR/magistrala-http & +SMQ_HTTP_ADAPTER_LOG_LEVEL=info SMQ_HTTP_ADAPTER_PORT=8008 SMQ_CLIENTS_AUTH_GRPC_URL=localhost:7000 $BUILD_DIR/supermq-http & ### # WS ### -MG_WS_ADAPTER_LOG_LEVEL=info MG_WS_ADAPTER_HTTP_PORT=8190 MG_THINGS_AUTH_GRPC_URL=localhost:7000 $BUILD_DIR/magistrala-ws & +SMQ_WS_ADAPTER_LOG_LEVEL=info SMQ_WS_ADAPTER_HTTP_PORT=8190 SMQ_CLIENTS_AUTH_GRPC_URL=localhost:7000 $BUILD_DIR/supermq-ws & ### # MQTT ### -MG_MQTT_ADAPTER_LOG_LEVEL=info MG_THINGS_AUTH_GRPC_URL=localhost:7000 $BUILD_DIR/magistrala-mqtt & +SMQ_MQTT_ADAPTER_LOG_LEVEL=info SMQ_CLIENTS_AUTH_GRPC_URL=localhost:7000 $BUILD_DIR/supermq-mqtt & ### # CoAP ### -MG_COAP_ADAPTER_LOG_LEVEL=info MG_COAP_ADAPTER_PORT=5683 MG_THINGS_AUTH_GRPC_URL=localhost:7000 $BUILD_DIR/magistrala-coap & +SMQ_COAP_ADAPTER_LOG_LEVEL=info SMQ_COAP_ADAPTER_PORT=5683 SMQ_CLIENTS_AUTH_GRPC_URL=localhost:7000 $BUILD_DIR/supermq-coap & trap cleanup EXIT