add testcase librabbitmq

This commit is contained in:
dan
2023-01-15 02:28:55 +08:00
parent 892b23d97b
commit d52a67a9d6
6 changed files with 368 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
{
"path": "$OET_PATH/testcases/cli-test/librabbitmq",
"cases": [
{
"name": "oe_test_librabbitmq_amqp-declare-queue"
},
{
"name": "oe_test_librabbitmq_amqp-consume"
},
{
"name": "oe_test_librabbitmq_amqp-delete-queue"
},
{
"name": "oe_test_librabbitmq_amqp-get"
},
{
"name": "oe_test_librabbitmq_amqp-publish"
}
]
}

View File

@@ -0,0 +1,79 @@
# Copyright (c) 2022. Huawei Technologies Co.,Ltd.ALL rights reserved.
# This program is licensed under Mulan PSL v2.
# You can use it according to the terms and conditions of the Mulan PSL v2.
# http://license.coscl.org.cn/MulanPSL2
# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.
# #############################################
# @Author : huike
# @Contact : 754873891@qq.com
# @Date : 2022/11/20
# @License : Mulan PSL v2
# @Desc : verify the uasge of librabbitmq command
# ############################################
source ${OET_PATH}/libs/locallibs/common_lib.sh
function pre_test() {
LOG_INFO "Start to prepare the test environment."
DNF_INSTALL "librabbitmq rabbitmq-server"
openssl genrsa -out privkey.pem 2048
openssl rsa -pubout -in privkey.pem -out pubkey.pem
openssl rsa -pubout -in privkey.pem -out cert.pem
nohup systemctl start rabbitmq-server &
SLEEP_WAIT 30
rabbitmq-plugins enable rabbitmq_management
rabbitmqctl add_user admin admin
rabbitmqctl set_user_tags admin administrator
rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
rabbitmqctl change_password admin admin
amqp-declare-queue -q test_queue -d -s 127.0.0.1 --port=5672 --vhost=/ --username=admin --password=admin --heartbeat=1
LOG_INFO "End to prepare the test environment."
}
function run_test() {
LOG_INFO "Start to run test."
nohup amqp-consume -A -q test_queue -c 5 -p 10 -u amqp://127.0.0.1:5672 --ssl --cacert=cacert.pem --key=privkey.pem --cert=cert.pem cat >./info.out 2>&1 &
SLEEP_WAIT 3
amqp-publish -r test_queue -b "test_body"
SLEEP_WAIT 10
grep "test_body" ./info.out
CHECK_RESULT $? 0 0 "Check amqp-consume -r -b failed"
kill -9 $(ps -ef | grep amqp-consume | grep -Ev 'grep|bash' | awk '{print $2}')
nohup amqp-consume -A -q test_queue -c 5 -p 10 -s 127.0.0.1 --port=5672 --vhost=/ --username=admin --password=admin --heartbeat=1 cat >./info1.out 2>&1 &
SLEEP_WAIT 3
amqp-publish -r test_queue -b "test_body"
SLEEP_WAIT 3
grep "test_body" ./info1.out
CHECK_RESULT $? 0 0 "Check amqp-consume -r -b failed"
kill -9 $(ps -ef | grep amqp-consume | grep -Ev 'grep|bash' | awk '{print $2}')
nohup amqp-consume -dx -c 5 -p 10 -s 127.0.0.1 --port=5672 -e test-ex -r test-routing -x --vhost=/ --username=guest --password=guest --heartbeat=1 cat >./info2.out 2>&1 &
SLEEP_WAIT 3
echo 'aaaaa' | amqp-publish -e test-ex -l --username=guest --password=guest -r test-routing
SLEEP_WAIT 10
grep "aaaaa" ./info2.out
CHECK_RESULT $? 0 0 "Check amqp-consume -e -x failed"
amqp-consume --help | grep 'Usage: amqp-consume \[OPTIONS\]'
CHECK_RESULT $? 0 0 "Check amqp-consume --help failed"
amqp-consume --usage | grep 'Usage: amqp-consume'
CHECK_RESULT $? 0 0 "Check amqp-consume --usage failed"
amqp-consume -? | grep 'Usage: amqp-consume \[OPTIONS\]'
CHECK_RESULT $? 0 0 "Check amqp-consume -? failed"
LOG_INFO "End to run test."
}
function post_test() {
LOG_INFO "Start to restore the test environment."
rabbitmqctl delete_user admin
kill -9 $(ps -ef | grep amqp-consume | grep -Ev 'grep|bash' | awk '{print $2}')
rabbitmq-plugins disable rabbitmq_management
rm -rf privkey.pem pubkey.pem cert.pem *.out info* rabbitmqadmin
systemctl stop rabbitmq-server
DNF_REMOVE
LOG_INFO "End to restore the test environment."
}
main $@

View File

@@ -0,0 +1,61 @@
# Copyright (c) 2022. Huawei Technologies Co.,Ltd.ALL rights reserved.
# This program is licensed under Mulan PSL v2.
# You can use it according to the terms and conditions of the Mulan PSL v2.
# http://license.coscl.org.cn/MulanPSL2
# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.
# #############################################
# @Author : huike
# @Contact : 754873891@qq.com
# @Date : 2022/11/20
# @License : Mulan PSL v2
# @Desc : verify the uasge of librabbitmq command
# ############################################
source ${OET_PATH}/libs/locallibs/common_lib.sh
function pre_test() {
LOG_INFO "Start to prepare the test environment."
DNF_INSTALL "librabbitmq rabbitmq-server"
openssl genrsa -out privkey.pem 2048
openssl rsa -pubout -in privkey.pem -out pubkey.pem
openssl rsa -pubout -in privkey.pem -out cert.pem
nohup systemctl start rabbitmq-server &
SLEEP_WAIT 30
rabbitmq-plugins enable rabbitmq_management
rabbitmqctl add_user admin admin
rabbitmqctl set_user_tags admin administrator
rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
rabbitmqctl change_password admin admin
LOG_INFO "End to prepare the test environment."
}
function run_test() {
LOG_INFO "Start to run test."
amqp-declare-queue -q test_queue -d -s 127.0.0.1 --port=5672 --vhost=/ --username=admin --password=admin --heartbeat=1 | grep 'test_queue'
CHECK_RESULT $? 0 0 "Check amqp-declare-queue -q -d -s --port --vhost --username --password --heartbeat failed"
amqp-declare-queue -u amqp://127.0.0.1:5672 -q test_queue1 -d --heartbeat=1 --ssl --cacert=cacert.pem --key=privkey.pem --cert=cert.pem | grep 'test_queue1'
CHECK_RESULT $? 0 0 "Check amqp-declare-queue -u -q -d --heartbeat failed"
amqp-declare-queue --usage 2>&1 | grep 'Usage: amqp-declare-queue'
CHECK_RESULT $? 0 0 "Check amqp-declare-queue --usage failed"
amqp-declare-queue -? | grep 'Usage: amqp-declare-queue \[OPTIONS\]'
CHECK_RESULT $? 0 0 "Check amqp-declare-queue -? failed"
amqp-declare-queue --help | grep 'Usage: amqp-declare-queue \[OPTIONS\]'
CHECK_RESULT $? 0 0 "Check amqp-declare-queue --help failed"
LOG_INFO "End to run test."
}
function post_test() {
LOG_INFO "Start to restore the test environment."
rabbitmq-plugins disable rabbitmq_management
rabbitmqctl delete_user admin
rm -rf privkey.pem pubkey.pem cert.pem
systemctl stop rabbitmq-server
DNF_REMOVE
LOG_INFO "End to restore the test environment."
}
main $@

View File

@@ -0,0 +1,65 @@
# Copyright (c) 2022. Huawei Technologies Co.,Ltd.ALL rights reserved.
# This program is licensed under Mulan PSL v2.
# You can use it according to the terms and conditions of the Mulan PSL v2.
# http://license.coscl.org.cn/MulanPSL2
# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.
# #############################################
# @Author : huike
# @Contact : 754873891@qq.com
# @Date : 2022/11/20
# @License : Mulan PSL v2
# @Desc : verify the uasge of librabbitmq command
# ############################################
source ${OET_PATH}/libs/locallibs/common_lib.sh
function pre_test() {
LOG_INFO "Start to prepare the test environment."
DNF_INSTALL "librabbitmq rabbitmq-server"
openssl genrsa -out privkey.pem 2048
openssl rsa -pubout -in privkey.pem -out pubkey.pem
openssl rsa -pubout -in privkey.pem -out cert.pem
nohup systemctl start rabbitmq-server &
SLEEP_WAIT 30
rabbitmq-plugins enable rabbitmq_management
rabbitmqctl add_user admin admin
rabbitmqctl set_user_tags admin administrator
rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
rabbitmqctl change_password admin admin
amqp-declare-queue -q test_queue -d -s 127.0.0.1 --port=5672 --vhost=/ --username=admin --password=admin --heartbeat=1
amqp-publish -r test_queue -b "test_body1" -C String -t "OK" -p -E utf-8 -H "key:value" -s 127.0.0.1 --port=5672 --vhost=/ --username=admin --password=admin --heartbeat=1
amqp-declare-queue -u amqp://127.0.0.1:5672 -q test_queue1 -d --heartbeat=1 --ssl --cacert=cacert.pem --key=privkey.pem --cert=cert.pem
amqp-publish -r test_queue1 -b "test_body1" -C String -t "OK" -p -E utf-8 -H "key:value" -u amqp://127.0.0.1:5672 --ssl --cacert=cacert.pem --key=privkey.pem --cert=cert.pem
LOG_INFO "End to prepare the test environment."
}
function run_test() {
LOG_INFO "Start to run test."
amqp-delete-queue --if-unused -q test_queue -s 127.0.0.1 --port=5672 --vhost=/ --username=admin --password=admin --heartbeat=1 | grep '[[:digit:]]'
CHECK_RESULT $? 0 0 "Check amqp-delete-queue -s -q --port --vhost --username --password failed"
amqp-delete-queue -u -e -q test_queue1 -u amqp://127.0.0.1:5672 --ssl --cacert=cacert.pem --key=privkey.pem --cert=cert.pem | grep '[[:digit:]]'
CHECK_RESULT $? 0 0 "Check amqp-delete-queue -u -e -q -u --ssl --cacert --key --cert failed"
amqp-delete-queue --help | grep 'Usage: amqp-delete-queue \[OPTIONS\]'
CHECK_RESULT $? 0 0 "Check amqp-delete-queue --help failed"
amqp-delete-queue -? | grep 'Usage: amqp-delete-queue \[OPTIONS\]'
CHECK_RESULT $? 0 0 "Check amqp-delete-queue -? failed"
amqp-delete-queue --usage | grep 'Usage: amqp-delete-queue \[-?\]'
CHECK_RESULT $? 0 0 "Check amqp-delete-queue --usage failed"
LOG_INFO "End to run test."
}
function post_test() {
LOG_INFO "Start to restore the test environment."
rabbitmqctl delete_user admin
rabbitmq-plugins disable rabbitmq_management
rm -rf privkey.pem pubkey.pem cert.pem rabbitmqadmin*
systemctl stop rabbitmq-server
DNF_REMOVE
LOG_INFO "End to restore the test environment."
}
main $@

View File

@@ -0,0 +1,65 @@
# Copyright (c) 2022. Huawei Technologies Co.,Ltd.ALL rights reserved.
# This program is licensed under Mulan PSL v2.
# You can use it according to the terms and conditions of the Mulan PSL v2.
# http://license.coscl.org.cn/MulanPSL2
# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.
# #############################################
# @Author : huike
# @Contact : 754873891@qq.com
# @Date : 2022/11/20
# @License : Mulan PSL v2
# @Desc : verify the uasge of librabbitmq command
# ############################################
source ${OET_PATH}/libs/locallibs/common_lib.sh
function pre_test() {
LOG_INFO "Start to prepare the test environment."
DNF_INSTALL "librabbitmq rabbitmq-server"
openssl genrsa -out privkey.pem 2048
openssl rsa -pubout -in privkey.pem -out pubkey.pem
openssl rsa -pubout -in privkey.pem -out cert.pem
nohup systemctl start rabbitmq-server &
SLEEP_WAIT 30
rabbitmq-plugins enable rabbitmq_management
rabbitmqctl add_user admin admin
rabbitmqctl set_user_tags admin administrator
rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
rabbitmqctl change_password admin admin
amqp-declare-queue -u amqp://127.0.0.1:5672 -q test_queue1 -d --heartbeat=1 --ssl --cacert=cacert.pem --key=privkey.pem --cert=cert.pem
amqp-publish -r test_queue1 -b "test_body1" -C String -t "OK" -p -E utf-8 -H "key:value" -u amqp://127.0.0.1:5672 --ssl --cacert=cacert.pem --key=privkey.pem --cert=cert.pem
amqp-declare-queue -q test_queue -d -s 127.0.0.1 --port=5672 --vhost=/ --username=admin --password=admin --heartbeat=1
amqp-publish -r test_queue -b "test_body1" -C String -t "OK" -p -E utf-8 -H "key:value" -s 127.0.0.1 --port=5672 --vhost=/ --username=admin --password=admin --heartbeat=1
LOG_INFO "End to prepare the test environment."
}
function run_test() {
LOG_INFO "Start to run test."
amqp-get -q test_queue1 -u amqp://127.0.0.1:5672 --ssl --cacert=cacert.pem --key=privkey.pem --cert=cert.pem | grep 'test_body1'
CHECK_RESULT $? 0 0 "Check amqp-get -q -u --ssl --cacert --key --cert failed"
amqp-get -q test_queue -s 127.0.0.1 --port=5672 --vhost=/ --username=admin --password=admin --heartbeat=1 | grep 'test_body1'
CHECK_RESULT $? 0 0 "Check amqp-get -q -s --port --vost --username --password --heartbeat failed"
amqp-get --help | grep 'Usage: amqp-get \[OPTIONS\]'
CHECK_RESULT $? 0 0 "Check amqp-get --help failed"
amqp-get -? | grep 'Usage: amqp-get \[OPTIONS\]'
CHECK_RESULT $? 0 0 "Check amqp-get -? failed"
amqp-get --usage | grep 'Usage: amqp-get'
CHECK_RESULT $? 0 0 "Check amqp-get --usage failed"
LOG_INFO "End to run test."
}
function post_test() {
LOG_INFO "Start to restore the test environment."
rabbitmqctl delete_user admin
rabbitmq-plugins disable rabbitmq_management
systemctl stop rabbitmq-server
rm -rf privkey.pem pubkey.pem cert.pem rabbitmqadmin
DNF_REMOVE
LOG_INFO "End to restore the test environment."
}
main $@

View File

@@ -0,0 +1,78 @@
# Copyright (c) 2022. Huawei Technologies Co.,Ltd.ALL rights reserved.
# This program is licensed under Mulan PSL v2.
# You can use it according to the terms and conditions of the Mulan PSL v2.
# http://license.coscl.org.cn/MulanPSL2
# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.
# #############################################
# @Author : huike
# @Contact : 754873891@qq.com
# @Date : 2022/11/20
# @License : Mulan PSL v2
# @Desc : verify the uasge of librabbitmq command
# ############################################
source ${OET_PATH}/libs/locallibs/common_lib.sh
function pre_test() {
LOG_INFO "Start to prepare the test environment."
DNF_INSTALL "librabbitmq rabbitmq-server"
openssl genrsa -out privkey.pem 2048
openssl rsa -pubout -in privkey.pem -out pubkey.pem
openssl rsa -pubout -in privkey.pem -out cert.pem
nohup systemctl start rabbitmq-server &
SLEEP_WAIT 30
rabbitmq-plugins enable rabbitmq_management
rabbitmqctl add_user admin admin
rabbitmqctl set_user_tags admin administrator
rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
rabbitmqctl change_password admin admin
wget http://localhost:15672/cli/rabbitmqadmin
chmod 777 rabbitmqadmin
./rabbitmqadmin declare exchange name=test-ex type=topic
./rabbitmqadmin declare queue name=test-queue durable=true
./rabbitmqadmin declare binding source=test-ex destination=test-queue routing_key=test-routing
nohup amqp-consume -dx -c 5 -p 10 -s 127.0.0.1 --port=5672 -e test-ex -r test-routing --vhost=/ --username=admin --password=admin --heartbeat=1 cat >./info1.out 2>&1 &
nohup amqp-consume -A -q test-queue -c 5 -p 10 -u amqp://127.0.0.1:5672 --ssl --cacert=cacert.pem --key=privkey.pem --cert=cert.pem cat >./info.out 2>&1 &
SLEEP_WAIT 3
LOG_INFO "End to prepare the test environment."
}
function run_test() {
LOG_INFO "Start to run test."
echo 'aaaaa' | amqp-publish -e test-ex -l --username=admin --password=admin -r test-routing
SLEEP_WAIT 5
grep "aaaaa" ./info1.out
CHECK_RESULT $? 0 0 "Check amqp-consume -e -l failed"
amqp-publish -r test-queue -b "test_body" -C String -t "OK" -p -E utf-8 -H "key:value" -s 127.0.0.1 --port=5672 --vhost=/ --username=admin --password=admin --heartbeat=1
SLEEP_WAIT 5
grep "test_body" ./info.out
CHECK_RESULT $? 0 0 "Check amqp-consume -r -b -C -t -p -E -H -s --port --vhost --username --password --heartbeat failed"
amqp-publish -r test-queue -b "test_body1" -C String -t "OK" -p -E utf-8 -H "key:value" -u amqp://127.0.0.1:5672 --ssl --cacert=cacert.pem --key=privkey.pem --cert=cert.pem
SLEEP_WAIT 5
grep "test_body1" ./info.out
CHECK_RESULT $? 0 0 "Check amqp-consume -r -b C -t -E -P -E -H -u --ssl --cacert --cert failed"
amqp-publish --help | grep 'Usage: amqp-publish \[OPTIONS\]'
CHECK_RESULT $? 0 0 "Check amqp-publish --help failed"
amqp-publish --usage | grep 'Usage: amqp-publish \[-?\]'
CHECK_RESULT $? 0 0 "Check amqp-publish --usage failed"
amqp-publish -? | grep 'Usage: amqp-publish \[OPTIONS\]'
CHECK_RESULT $? 0 0 "Check amqp-publish -? failed"
LOG_INFO "End to run test."
}
function post_test() {
LOG_INFO "Start to restore the test environment."
rabbitmqctl delete_user admin
rabbitmq-plugins disable rabbitmq_management
kill -9 $(ps -ef | grep amqp-consume | grep -Ev 'grep|bash' | awk '{print $2}')
rm -rf privkey.pem pubkey.pem cert.pem *.out info* rabbitmqadmin
systemctl stop rabbitmq-server
DNF_REMOVE
LOG_INFO "End to restore the test environment."
}
main $@