diff --git a/suite2cases/freeradius.json b/suite2cases/freeradius.json new file mode 100644 index 0000000000000000000000000000000000000000..b8ba30ea91bfb6ca09c0bf3173077859de3f9b67 --- /dev/null +++ b/suite2cases/freeradius.json @@ -0,0 +1,124 @@ +{ + "path": "$OET_PATH/testcases/cli-test/freeradius", + "cases": [ + { + "name": "oe_test_freeradius_freeradius_raddebugAndCheckrad", + "machine": { + "type": "kvm", + "num": 1 + } + }, + { + "name": "oe_test_freeradius_freeradius_radiusd", + "machine": { + "type": "kvm", + "num": 1 + } + }, + { + "name": "oe_test_freeradius_freeradius_radiusdAndRadmin", + "machine": { + "type": "kvm", + "num": 1 + } + }, + { + "name": "oe_test_freeradius_freeradius-utils_radclient", + "machine": { + "type": "kvm", + "num": 1 + } + }, + { + "name": "oe_test_freeradius_freeradius-utils_radclient2", + "machine": { + "type": "kvm", + "num": 1 + } + }, + { + "name": "oe_test_freeradius_freeradius-utils_rad_counter", + "machine": { + "type": "kvm", + "num": 1 + } + }, + { + "name": "oe_test_freeradius_freeradius-utils_radcryptAndRadeapclient", + "machine": { + "type": "kvm", + "num": 1 + } + }, + { + "name": "oe_test_freeradius_freeradius-utils_radeapclient", + "machine": { + "type": "kvm", + "num": 1 + } + }, + { + "name": "oe_test_freeradius_freeradius-utils_radlast", + "machine": { + "type": "kvm", + "num": 1 + } + }, + { + "name": "oe_test_freeradius_freeradius-utils_radlastAndRadsniff", + "machine": { + "type": "kvm", + "num": 1 + } + }, + { + "name": "oe_test_freeradius_freeradius-utils_radsniff", + "machine": { + "type": "kvm", + "num": 1 + } + }, + { + "name": "oe_test_freeradius_freeradius-utils_radsniff2", + "machine": { + "type": "kvm", + "num": 1 + } + }, + { + "name": "oe_test_freeradius_freeradius-utils_radsqlrelay", + "machine": { + "type": "kvm", + "num": 1 + } + }, + { + "name": "oe_test_freeradius_freeradius-utils_radtestAndRadwho", + "machine": { + "type": "kvm", + "num": 1 + } + }, + { + "name": "oe_test_freeradius_freeradius-utils_radwho", + "machine": { + "type": "kvm", + "num": 1 + } + }, + { + "name": "oe_test_freeradius_freeradius-utils_radzap", + "machine": { + "type": "kvm", + "num": 1 + } + }, + { + "name": "oe_test_freeradius_freeradius-utils_rlm_ippool_toolAndSmbencrypt", + "machine": { + "type": "kvm", + "num": 1 + } + } + ] +} \ No newline at end of file diff --git a/suite2cases/geos.json b/suite2cases/geos.json new file mode 100644 index 0000000000000000000000000000000000000000..c762220a28601dc9cf56a0c98035fee9cf2da7dd --- /dev/null +++ b/suite2cases/geos.json @@ -0,0 +1,12 @@ +{ + "path": "$OET_PATH/testcases/cli-test/geos", + "cases": [ + { + "name": "oe_test_geos_commandAndbaseFun", + "machine": { + "type": "kvm", + "num": 1 + } + } + ] +} \ No newline at end of file diff --git a/suite2cases/iperf3.json b/suite2cases/iperf3.json new file mode 100644 index 0000000000000000000000000000000000000000..a63de7a4c9b5a80f8bf65ae9752ebcc59c635a57 --- /dev/null +++ b/suite2cases/iperf3.json @@ -0,0 +1,26 @@ +{ + "path": "$OET_PATH/testcases/cli-test/iperf3", + "cases": [ + { + "name": "oe_test_iperf3_command_client", + "machine": { + "type": "kvm", + "num": 2 + } + }, + { + "name": "oe_test_iperf3_command_clientAndShared", + "machine": { + "type": "kvm", + "num": 2 + } + }, + { + "name": "oe_test_iperf3_command_serverAndBase", + "machine": { + "type": "kvm", + "num": 2 + } + } + ] +} \ No newline at end of file diff --git a/suite2cases/sqlite-jdbc.json b/suite2cases/sqlite-jdbc.json new file mode 100644 index 0000000000000000000000000000000000000000..1e88dc5e1566d41f4d7527249c9c187c6894e0b4 --- /dev/null +++ b/suite2cases/sqlite-jdbc.json @@ -0,0 +1,12 @@ +{ + "path": "$OET_PATH/testcases/cli-test/sqlite-jdbc", + "cases": [ + { + "name": "oe_test_sqlite-jdbc_connect", + "machine": { + "type": "kvm", + "num": 1 + } + } + ] +} \ No newline at end of file diff --git a/suite2cases/testNG b/suite2cases/testNG new file mode 100644 index 0000000000000000000000000000000000000000..f05b67353dfb55047a7925b9101d9890870bfd14 --- /dev/null +++ b/suite2cases/testNG @@ -0,0 +1,13 @@ +oe_test_testNG_annotations_assert +oe_test_testNG_annotations_before_after +oe_test_testNG_annotations_common +oe_test_testNG_annotations_group +oe_test_testNG_annotations_listen +oe_test_testNG_annotations_parameters +oe_test_testNG_exception +oe_test_testNG_retry +oe_test_testNG_thread +oe_test_testNG_with_ant +oe_test_testNG_with_Junit +oe_test_testNG_with_maven +oe_test_testNG_with_spring diff --git a/testcases/cli-test/freeradius/common/test.pcap b/testcases/cli-test/freeradius/common/test.pcap new file mode 100644 index 0000000000000000000000000000000000000000..987c17de6261b879b78f9d13762a5195a541182a Binary files /dev/null and b/testcases/cli-test/freeradius/common/test.pcap differ diff --git a/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_rad_counter/oe_test_freeradius_freeradius-utils_rad_counter.sh b/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_rad_counter/oe_test_freeradius_freeradius-utils_rad_counter.sh new file mode 100644 index 0000000000000000000000000000000000000000..c59d7b7971f992e0c5c65ea7ddb430480fbaee4f --- /dev/null +++ b/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_rad_counter/oe_test_freeradius_freeradius-utils_rad_counter.sh @@ -0,0 +1,64 @@ +#!/usr/bin/bash + +# Copyright (c) 2021. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/12/24 +#@Desc : freeradius-utils command parameter automation use case +#################################### + +source ${OET_PATH}/libs/locallibs/common_lib.sh + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + + DNF_INSTALL "freeradius freeradius-utils" + + LOG_INFO "End to prepare the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + + ln -s /etc/raddb/mods-available/counter /etc/raddb/mods-enabled/counter + systemctl start radiusd + SLEEP_WAIT 2 + rad_counter --file /etc/raddb/db.daily --user test + CHECK_RESULT $? 0 0 "rad_counter --user execution failed." + rad_counter --file /etc/raddb/db.daily --match ^te + CHECK_RESULT $? 0 0 "rad_counter --match execution failed." + rad_counter --file /etc/raddb/db.daily --reset 1 + CHECK_RESULT $? 0 0 "rad_counter --reset execution failed." + rad_counter --help | grep -i "usage" + CHECK_RESULT $? 0 0 "rad_counter --help execution failed." + rad_counter --file /etc/raddb/db.daily --hours 1 + CHECK_RESULT $? 0 0 "rad_counter --hours execution failed." + rad_counter --file /etc/raddb/db.daily --minutes 1 + CHECK_RESULT $? 0 0 "rad_counter --minutes execution failed." + rad_counter --file /etc/raddb/db.daily --seconds 1 + CHECK_RESULT $? 0 0 "rad_counter --seconds execution failed." + systemctl stop radiusd + + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + + DNF_REMOVE + rm -rf /etc/raddb + rm -rf /var/log/radius + + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radclient/oe_test_freeradius_freeradius-utils_radclient.sh b/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radclient/oe_test_freeradius_freeradius-utils_radclient.sh new file mode 100644 index 0000000000000000000000000000000000000000..d52349450a3ad2a5fdac02c7bd82160970f5c11a --- /dev/null +++ b/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radclient/oe_test_freeradius_freeradius-utils_radclient.sh @@ -0,0 +1,69 @@ +#!/usr/bin/bash + +# Copyright (c) 2021. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/12/24 +#@Desc : freeradius-utils command parameter automation use case +#################################### + +source ${OET_PATH}/libs/locallibs/common_lib.sh + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + + DNF_INSTALL "freeradius freeradius-utils" + + LOG_INFO "End to prepare the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + + systemctl start radiusd + SLEEP_WAIT 1 + echo "Message-Authenticator = 0x00" | radclient -4 127.0.0.1 status testing123 | grep "Received Access-Accept" + CHECK_RESULT $? 0 0 "radclient -4 execution failed." + echo "Message-Authenticator = 0x00" | radclient -6 [::1] status testing123 | grep "Received Access-Accept" + CHECK_RESULT $? 0 0 "radclient -6 execution failed." + [ $(echo "Message-Authenticator = 0x00" | radclient -c 2 127.0.0.1 status testing123 | grep -c "Received Access-Accept") -eq 2 ] + CHECK_RESULT $? 0 0 "radclient -c execution failed." + echo "Message-Authenticator = 0x00" | radclient -d /etc/raddb 127.0.0.1 status testing123 | grep "Received Access-Accept" + CHECK_RESULT $? 0 0 "radclient -d execution failed." + echo "Message-Authenticator = 0x00" | radclient -D /usr/share/freeradius 127.0.0.1 status testing123 | grep "Received Access-Accept" + CHECK_RESULT $? 0 0 "radclient -D execution failed." + echo "Message-Authenticator = 0x00" >/tmp/test + radclient -f /tmp/test 127.0.0.1 status testing123 | grep "Received Access-Accept" + CHECK_RESULT $? 0 0 "radclient -f execution failed." + echo "Message-Authenticator = 0x00" | radclient -F 127.0.0.1 status testing123 | grep "Received Access-Accept" + CHECK_RESULT $? 0 0 "radclient -F execution failed." + radclient -h 2>&1 | grep -i "Usage" + CHECK_RESULT $? 0 0 "radclient -h execution failed." + echo "Message-Authenticator = 0x00" | radclient -n 30 127.0.0.1 status testing123 | grep "Received Access-Accept" + CHECK_RESULT $? 0 0 "radclient -n execution failed." + systemctl stop radiusd + + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + + DNF_REMOVE + rm -rf /etc/raddb + rm -rf /var/log/radius + rm -rf /tmp/test + + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radclient2/oe_test_freeradius_freeradius-utils_radclient2.sh b/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radclient2/oe_test_freeradius_freeradius-utils_radclient2.sh new file mode 100644 index 0000000000000000000000000000000000000000..656c122e5a1f8bfeb7bb998848e73d279e8974f7 --- /dev/null +++ b/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radclient2/oe_test_freeradius_freeradius-utils_radclient2.sh @@ -0,0 +1,72 @@ +#!/usr/bin/bash + +# Copyright (c) 2021. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/12/24 +#@Desc : freeradius-utils command parameter automation use case +#################################### + +source ${OET_PATH}/libs/locallibs/common_lib.sh + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + + DNF_INSTALL "freeradius freeradius-utils" + + LOG_INFO "End to prepare the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + + systemctl start radiusd + SLEEP_WAIT 1 + echo "Message-Authenticator = 0x00" | radclient -p 30 127.0.0.1 status testing123 | grep "Received Access-Accept" + CHECK_RESULT $? 0 0 "radclient -p execution failed." + a=$(echo "Message-Authenticator = 0x00" | radclient -q 127.0.0.1 status testing123) + [ -z "${a}" ] + CHECK_RESULT $? 0 0 "radclient -q execution failed." + echo "Message-Authenticator = 0x00" | radclient -t 0.0000000000000000000000000000000000000000000000000000000001 127.0.0.1 status testing123 2>&1 | grep "No reply" + CHECK_RESULT $? 0 0 "radclient -t execution failed." + replay_times=5 + a=$(echo "Message-Authenticator = 0x00" | radclient -t 0.0000000000000000000000000000000000000000000000000000000001 -r ${replay_times} 127.0.0.1 status testing123 | grep -c "Sent") + [ "${replay_times}" -eq "${a}" ] + CHECK_RESULT $? 0 0 "radclient -r execution failed." + echo "Message-Authenticator = 0x00" | radclient -s 127.0.0.1 status testing123 | grep "Packet summary" + CHECK_RESULT $? 0 0 "radclient -s execution failed." + echo "testing123" >/tmp/test + echo "Message-Authenticator = 0x00" | radclient -S /tmp/test 127.0.0.1 status | grep "Received Access-Accept" + CHECK_RESULT $? 0 0 "radclient -S execution failed." + radclient -v | grep $(rpm -q freeradius-utils | awk -F '-' '{print $3}') + CHECK_RESULT $? 0 0 "radclient -v execution failed." + echo "Message-Authenticator = 0x00" | radclient -x 127.0.0.1 status testing123 | grep "Message-Authenticator" + CHECK_RESULT $? 0 0 "radclient -x execution failed." + echo "Message-Authenticator = 0x00" | radclient -P udp 127.0.0.1 status testing123 | grep "Received Access-Accept" + CHECK_RESULT $? 0 0 "radclient -P execution failed." + systemctl stop radiusd + + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + + DNF_REMOVE + rm -rf /etc/raddb + rm -rf /var/log/radius + rm -rf /tmp/test + + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radcryptAndRadeapclient/oe_test_freeradius_freeradius-utils_radcryptAndRadeapclient.sh b/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radcryptAndRadeapclient/oe_test_freeradius_freeradius-utils_radcryptAndRadeapclient.sh new file mode 100644 index 0000000000000000000000000000000000000000..77f827df3e0efb83d306cfc336e558ab298cf5f6 --- /dev/null +++ b/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radcryptAndRadeapclient/oe_test_freeradius_freeradius-utils_radcryptAndRadeapclient.sh @@ -0,0 +1,69 @@ +#!/usr/bin/bash + +# Copyright (c) 2021. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/12/24 +#@Desc : freeradius-utils command parameter automation use case +#################################### + +source ${OET_PATH}/libs/locallibs/common_lib.sh + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + + DNF_INSTALL "freeradius freeradius-utils" + + LOG_INFO "End to prepare the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + + radcrypt --des test123 + CHECK_RESULT $? 0 0 "radcrypt --des execution failed." + radcrypt --md5 test123 + CHECK_RESULT $? 0 0 "radcrypt --md5 execution failed." + radcrypt --check test123 $(radcrypt --md5 test123) | grep "Password OK" + CHECK_RESULT $? 0 0 "radcrypt --check execution failed." + systemctl start radiusd + SLEEP_WAIT 1 + echo "Message-Authenticator = 0x00" | radeapclient -4 127.0.0.1 status testing123 | grep "Main loop: done" + CHECK_RESULT $? 0 0 "radeapclient -4 execution failed." + echo "Message-Authenticator = 0x00" | radeapclient -6 [::1] status testing123 | grep "Main loop: done" + CHECK_RESULT $? 0 0 "radeapclient -6 execution failed." + echo "Message-Authenticator = 0x00" | radeapclient -d /etc/raddb 127.0.0.1 status testing123 | grep "Main loop: done" + CHECK_RESULT $? 0 0 "radeapclient -d execution failed." + echo "Message-Authenticator = 0x00" | radeapclient -D /usr/share/freeradius 127.0.0.1 status testing123 | grep "Main loop: done" + CHECK_RESULT $? 0 0 "radeapclient -D execution failed." + echo "Message-Authenticator = 0x00" >/tmp/test + radeapclient -f /tmp/test 127.0.0.1 status testing123 | grep "Main loop: done" + CHECK_RESULT $? 0 0 "radeapclient -f execution failed." + radeapclient -h | grep -i "Usage" + CHECK_RESULT $? 0 0 "radeapclient -h execution failed." + systemctl stop radiusd + + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + + DNF_REMOVE + rm -rf /etc/raddb + rm -rf /var/log/radius + rm -rf /tmp/test + + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radeapclient/oe_test_freeradius_freeradius-utils_radeapclient.sh b/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radeapclient/oe_test_freeradius_freeradius-utils_radeapclient.sh new file mode 100644 index 0000000000000000000000000000000000000000..bd274071d4c969e9f3a380832a0f6805713f9eb9 --- /dev/null +++ b/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radeapclient/oe_test_freeradius_freeradius-utils_radeapclient.sh @@ -0,0 +1,70 @@ +#!/usr/bin/bash + +# Copyright (c) 2021. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/12/24 +#@Desc : freeradius-utils command parameter automation use case +#################################### + +source ${OET_PATH}/libs/locallibs/common_lib.sh + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + + DNF_INSTALL "freeradius freeradius-utils net-tools" + + LOG_INFO "End to prepare the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + + systemctl start radiusd + SLEEP_WAIT 1 + echo "Message-Authenticator = 0x00" | radeapclient -p 30 127.0.0.1 status testing123 | grep "Main loop: done" + CHECK_RESULT $? 0 0 "radeapclient -p execution failed." + a=$(echo "Message-Authenticator = 0x00" | radeapclient -q 127.0.0.1 status testing123) + [ -z "$a" ] + CHECK_RESULT $? 0 0 "radeapclient -q execution failed." + echo "Message-Authenticator = 0x00" | radeapclient -t 0.0000000000000000000000000000000000000000000000000000000001 -x 127.0.0.1 status testing123 | grep "Timeout" + CHECK_RESULT $? 0 0 "radeapclient -t execution failed." + replay_times=5 + a=$(echo "Message-Authenticator = 0x00" | radeapclient -t 0.0000000000000000000000000000000000000000000000000000000001 -r ${replay_times} -x 127.0.0.1 status testing123 | grep -c "Timeout") + [ "${replay_times}" -eq "${a}" ] + CHECK_RESULT $? 0 0 "radeapclient -r execution failed." + echo "Message-Authenticator = 0x00" | radeapclient -s 127.0.0.1 status testing123 | grep "Total approved auths" + CHECK_RESULT $? 0 0 "radeapclient -s execution failed." + echo "testing123" >/tmp/secretfile + echo "Message-Authenticator = 0x00" | radeapclient -S /tmp/secretfile 127.0.0.1 status | grep "Main loop: done" + CHECK_RESULT $? 0 0 "radeapclient -S execution failed." + radeapclient -v | grep -i "id" + CHECK_RESULT $? 0 0 "radeapclient -v execution failed." + echo "Message-Authenticator = 0x00" | radeapclient -x 127.0.0.1 status testing123 | grep "Message-Authenticator" + CHECK_RESULT $? 0 0 "radeapclient -x execution failed." + systemctl stop radiusd + + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + + DNF_REMOVE + rm -rf /etc/raddb + rm -rf /var/log/radius + rm -rf /tmp/secretfile + + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radlast/oe_test_freeradius_freeradius-utils_radlast.sh b/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radlast/oe_test_freeradius_freeradius-utils_radlast.sh new file mode 100644 index 0000000000000000000000000000000000000000..db734139b92588c7b461b5650f8f5981b0145264 --- /dev/null +++ b/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radlast/oe_test_freeradius_freeradius-utils_radlast.sh @@ -0,0 +1,70 @@ +#!/usr/bin/bash + +# Copyright (c) 2021. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/12/24 +#@Desc : freeradius-utils command parameter automation use case +#################################### + +source ${OET_PATH}/libs/locallibs/common_lib.sh + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + + DNF_INSTALL "freeradius freeradius-utils" + + LOG_INFO "End to prepare the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + + cp /var/log/wtmp /var/log/radius/radwtmp + radtimes=3 + a=$(radlast -${radtimes} | grep -c "oot") + [ "$radtimes" -eq "$a" ] + CHECK_RESULT $? 0 0 "radlast -num execution failed." + radlast -a | awk '{print $NF}' | grep -E "([0-9]{1,3}.){3}[0-9]" + CHECK_RESULT $? 0 0 "radlast -a execution failed." + radlast -3 -d + CHECK_RESULT $? 0 0 "radlast -d execution failed." + radlast --file /var/log/radius/radwtmp | grep "radwtmp begins" + CHECK_RESULT $? 0 0 "radlast --file execution failed." + radlast --fulltimes | grep -E "([0-9]{1,2}:){2}[0-9]{1,2}" + CHECK_RESULT $? 0 0 "radlast --fulltimes execution failed." + radlast -i | grep -E "([0-9]{1,3}.){3}[0-9]" + CHECK_RESULT $? 0 0 "radlast -i execution failed." + a=$(radlast -n ${radtimes} | grep -c "oot") + [ "$radtimes" -eq "$a" ] + CHECK_RESULT $? 0 0 "radlast -n execution failed." + radlast -R | awk '{print $3}' | grep -e "Mon" -e "Tue" -e "Wed" -e "Sat" -e "Sun" -e "Thu" -e "Sat" -e "Fri" + CHECK_RESULT $? 0 0 "radlast -R execution failed." + a=$(radlast -s "00:00" | grep "logged in" | sed -n '$p' | awk '{print $(NF-3)}') + b=$(radlast -s "00:00" | grep "logged in" | sed -n '$p' | awk '{print $(NF-3)}' | awk -F ':' '{print $1":"$2+1}') + [ "$(radlast -s "$b" | grep "logged in" | sed -n '$p' | awk '{print $(NF-3)}')" != "$a" ] + CHECK_RESULT $? 0 0 "radlast -s execution failed." + + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + + DNF_REMOVE + rm -rf /etc/raddb + rm -rf /var/log/radius + + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radlastAndRadsniff/oe_test_freeradius_freeradius-utils_radlastAndRadsniff.sh b/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radlastAndRadsniff/oe_test_freeradius_freeradius-utils_radlastAndRadsniff.sh new file mode 100644 index 0000000000000000000000000000000000000000..450d898ae770b73756bab8fdd273b0eb0a87425e --- /dev/null +++ b/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radlastAndRadsniff/oe_test_freeradius_freeradius-utils_radlastAndRadsniff.sh @@ -0,0 +1,70 @@ +#!/usr/bin/bash + +# Copyright (c) 2021. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/12/24 +#@Desc : freeradius-utils command parameter automation use case +#################################### + +source ${OET_PATH}/libs/locallibs/common_lib.sh + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + + DNF_INSTALL "freeradius freeradius-utils net-tools" + + LOG_INFO "End to prepare the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + + cp /var/log/wtmp /var/log/radius/radwtmp + [ $(radlast | grep -c "oot") -gt $(radlast -t "00:00" | grep -c "oot") ] + CHECK_RESULT $? 0 0 "radlast -t execution failed." + radlast -x | grep -e "runlevel" -e "shutdown" + CHECK_RESULT $? 0 0 "radlast -x execution failed." + radlast -h | grep "\-a" + CHECK_RESULT $? 0 0 "radlast -h execution failed." + radlast -V | grep $(last -V | awk '{print $NF}') + CHECK_RESULT $? 0 0 "radlast -V execution failed." + radsniff -a | grep $(ifconfig | sed -n '1p' | awk -F ':' '{print $1}') + CHECK_RESULT $? 0 0 "radsniff -a execution failed." + systemctl start radiusd + SLEEP_WAIT 1 + radsniff -c 2 -I ../common/test.pcap | grep "Captured 2 packets" + CHECK_RESULT $? 0 0 "radsniff -c execution failed." + radsniff -C -I ../common/test.pcap 2>&1 | tee /tmp/test + grep "UDP checksum" /tmp/test + CHECK_RESULT $? 0 0 "radsniff -C execution failed." + radsniff -d /etc/raddb -I ../common/test.pcap | grep "Access-Accept" + CHECK_RESULT $? 0 0 "radsniff -d execution failed." + radsniff -D /usr/share/freeradius -I ../common/test.pcap | grep "Access-Accept" + CHECK_RESULT $? 0 0 "radsniff -D execution failed." + systemctl stop radiusd + + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + + DNF_REMOVE + rm -rf /etc/raddb + rm -rf /var/log/radius + rm -rf /tmp/test + + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radsniff/oe_test_freeradius_freeradius-utils_radsniff.sh b/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radsniff/oe_test_freeradius_freeradius-utils_radsniff.sh new file mode 100644 index 0000000000000000000000000000000000000000..1b72d1708ac1a793ec58165742f12bb1923b0b22 --- /dev/null +++ b/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radsniff/oe_test_freeradius_freeradius-utils_radsniff.sh @@ -0,0 +1,71 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/12/24 +#@Desc : freeradius-utils command parameter automation use case +#################################### + +source ${OET_PATH}/libs/locallibs/common_lib.sh + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + + DNF_INSTALL "freeradius freeradius-utils" + + LOG_INFO "End to prepare the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + + systemctl start radiusd + SLEEP_WAIT 1 + radsniff -e received -I ../common/test.pcap | grep "Access-Accept" + CHECK_RESULT $? 0 0 "radsniff -e execution failed." + radsniff -f udp -I ../common/test.pcap | grep "Access-Accept" + CHECK_RESULT $? 0 0 "radsniff -f execution failed." + radsniff -h | grep "Usage" + CHECK_RESULT $? 0 0 "radsniff -h execution failed." + radsniff -I ../common/test.pcap | grep "Access-Accept" + CHECK_RESULT $? 0 0 "radsniff -I execution failed." + radsniff -I ../common/test.pcap -l Message-Authenticator | grep "Access-Accept" + CHECK_RESULT $? 0 0 "radsniff -l execution failed." + radsniff -I ../common/test.pcap -L Message-AuthenticatoR | grep "Access-Accept" + CHECK_RESULT $? 0 0 "radsniff -L execution failed." + radsniff -m -I ../common/test.pcap | grep "Access-Accept" + CHECK_RESULT $? 0 0 "radsniff -m execution failed." + radsniff -p 1812 -I ../common/test.pcap | grep "1812" + CHECK_RESULT $? 0 0 "radsniff -p execution failed." + radsniff -P /tmp/radsniff.pid + echo "Message-Authenticator = 0x00" | radclient 127.0.0.1 status testing123 + [ "$(cat /tmp/radsniff.pid)" -eq "$(pgrep -f "radsniff -P" | grep -v grep)" ] + CHECK_RESULT $? 0 0 "radsniff -P execution failed." + kill -9 $(cat /tmp/radsniff.pid) + systemctl stop radiusd + + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + + DNF_REMOVE + rm -rf /etc/raddb + rm -rf /var/log/radius + rm -rf /tmp/radsniff.pid + + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radsniff2/oe_test_freeradius_freeradius-utils_radsniff2.sh b/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radsniff2/oe_test_freeradius_freeradius-utils_radsniff2.sh new file mode 100644 index 0000000000000000000000000000000000000000..57b87b7b80320466700c3af6f41bde19a2fb40b2 --- /dev/null +++ b/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radsniff2/oe_test_freeradius_freeradius-utils_radsniff2.sh @@ -0,0 +1,71 @@ +#!/usr/bin/bash + +# Copyright (c) 2021. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/12/24 +#@Desc : freeradius-utils command parameter automation use case +#################################### + +source ${OET_PATH}/libs/locallibs/common_lib.sh + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + + DNF_INSTALL "freeradius freeradius-utils" + + LOG_INFO "End to prepare the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + + systemctl start radiusd + SLEEP_WAIT 1 + [ -z "$(radsniff -q -I ../common/test.pcap)" ] + CHECK_RESULT $? 0 0 "radsniff -q execution failed." + [ -z $(radsniff -I ../common/test.pcap -r 'Message-Authenticator = 0x00') ] + CHECK_RESULT $? 0 0 "radsniff -r execution failed." + [ -z $(radsniff -I ../common/test.pcap -R 'Message-Authenticator = 0x00') ] + CHECK_RESULT $? 0 0 "radsniff -R execution failed." + radsniff -s testing123 -I ../common/test.pcap | grep "Access-Accept" + CHECK_RESULT $? 0 0 "radsniff -s execution failed." + radsniff -S -I ../common/test.pcap | xxd -b | grep "$(xxd -b ../common/test.pcap)" + CHECK_RESULT $? 0 0 "radsniff -S execution failed." + radsniff -v | grep $(rpm -q freeradius-utils | awk -F '-' '{print $3}') + CHECK_RESULT $? 0 0 "radsniff -v execution failed." + radsniff -w /tmp/test.pcap -I ../common/test.pcap + xxd -b /tmp/test.pcap | grep "$(xxd -b ../common/test.pcap)" + CHECK_RESULT $? 0 0 "radsniff -w execution failed." + radsniff -x -I ../common/test.pcap | grep "Authenticator-Field" + CHECK_RESULT $? 0 0 "radsniff -x execution failed." + radsniff -W 2 -I ../common/test.pcap | grep "Muting stats" + CHECK_RESULT $? 0 0 "radsniff -W execution failed." + radsniff -T 100 -I ../common/test.pcap | grep "Access-Accept" + CHECK_RESULT $? 0 0 "radsniff -T execution failed." + systemctl stop radiusd + + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + + DNF_REMOVE + rm -rf /etc/raddb + rm -rf /var/log/radius + rm -rf /tmp/test.pcap + + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radsqlrelay/oe_test_freeradius_freeradius-utils_radsqlrelay.sh b/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radsqlrelay/oe_test_freeradius_freeradius-utils_radsqlrelay.sh new file mode 100644 index 0000000000000000000000000000000000000000..380bc7c00a1dd0cc25cdd6f609a0007a678bb722 --- /dev/null +++ b/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radsqlrelay/oe_test_freeradius_freeradius-utils_radsqlrelay.sh @@ -0,0 +1,97 @@ +#!/usr/bin/bash + +# Copyright (c) 2021. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/12/24 +#@Desc : freeradius-utils command parameter automation use case +#################################### + +source ${OET_PATH}/libs/locallibs/common_lib.sh + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + + DNF_INSTALL "freeradius freeradius-utils perl-DBD-MySQL mysql5 mysql5-server freeradius-mysql" + systemctl start mysqld + SLEEP_WAIT 2 + mysqladmin -uroot password Test123 + mysql -uroot -pTest123 -e "create database radius; + use radius; + source /etc/raddb/mods-config/sql/main/mysql/schema.sql; + " + sed -i 's/driver = "rlm_sql_null"/driver = "rlm_sql_mysql"/g' /etc/raddb/mods-available/sql + sed -i 's/dialect = "sqlite"/dialect = "mysql"/g' /etc/raddb/mods-available/sql + sed -i '/server = "localhost"/a server = "localhost"' /etc/raddb/mods-available/sql + sed -i '/port = 3306/a port = 3306' /etc/raddb/mods-available/sql + sed -i '/login = "radius"/a login = "root"' /etc/raddb/mods-available/sql + sed -i '/password = "radpass"/a password = "Test123"' /etc/raddb/mods-available/sql + ln -s /etc/raddb/mods-available/sql /etc/raddb/mods-enabled/ + echo "insert into radcheck (username,attribute,op,value) values ('wjf','Cleartext-Password',':=','wjf123');" >/tmp/radius.sql + + LOG_INFO "End to prepare the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + + radsqlrelay -? 2>&1 | grep "usage" + CHECK_RESULT $? 0 0 "radsqlrelay -? execution failed." + radsqlrelay -1 -d mysql -b radius -h localhost -p Test123 -u root /tmp/radius.sql + mysql -uroot -pTest123 -e "use radius; + select * from radcheck where username='wjf'; + " | grep "wjf" && [ ! -e /tmp/radius.sql ] + CHECK_RESULT $? 0 0 "radsqlrelay -1 -d -b -h -p -u execution failed." + echo "Test123" >/tmp/passwdfile.txt + mysql -uroot -pTest123 -e "use radius; + delete from radcheck where username='wjf'; + " + echo "insert into radcheck (username,attribute,op,value) values ('wjf','Cleartext-Password',':=','wjf123');" >/tmp/radius.sql + radsqlrelay -1 -d mysql -b radius -h localhost -f /tmp/passwdfile.txt -u root /tmp/radius.sql + mysql -uroot -pTest123 -e "use radius; + select * from radcheck where username='wjf'; + " | grep "wjf" && [ ! -e /tmp/radius.sql ] + CHECK_RESULT $? 0 0 "radsqlrelay -f execution failed." + mysql -uroot -pTest123 -e "use radius; + delete from radcheck where username='wjf'; + " + echo "insert into radcheck (username,attribute,op,value) values ('wjf','Cleartext-Password',':=','wjf123');" >/tmp/radius.sql + radsqlrelay -1 -d mysql -b radius -h 127.0.0.1 -p Test123 -u root -P 3306 /tmp/radius.sql + mysql -uroot -pTest123 -e "use radius; + select * from radcheck where username='wjf'; + " | grep "wjf" && [ ! -e /tmp/radius.sql ] + CHECK_RESULT $? 0 0 "radsqlrelay -P execution failed." + mysql -uroot -pTest123 -e "use radius; + delete from radcheck where username='wjf'; + " + echo "insert into radcheck (username,attribute,op,value) values ('wjf','Cleartext-Password',':=','wjf123');" >/tmp/radius.sql + radsqlrelay -1 -d mysql -b radius -h localhost -p Test123 -u root -x /tmp/radius.sql | grep "Connecting to DBI" + CHECK_RESULT $? 0 0 "radsqlrelay -x execution failed." + + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + + systemctl stop mysqld + SLEEP_WAIT 2 + DNF_REMOVE + rm -rf /var/lib/mysql + rm -rf /etc/raddb + rm -rf /var/log/radius + rm -rf /tmp/passwdfile.txt + + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radtestAndRadwho/oe_test_freeradius_freeradius-utils_radtestAndRadwho.sh b/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radtestAndRadwho/oe_test_freeradius_freeradius-utils_radtestAndRadwho.sh new file mode 100644 index 0000000000000000000000000000000000000000..0614a93f1abc262e4799b2e6fb65a791576e6918 --- /dev/null +++ b/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radtestAndRadwho/oe_test_freeradius_freeradius-utils_radtestAndRadwho.sh @@ -0,0 +1,78 @@ +#!/usr/bin/bash + +# Copyright (c) 2021. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/12/24 +#@Desc : freeradius-utils command parameter automation use case +#################################### + +source ${OET_PATH}/libs/locallibs/common_lib.sh + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + + DNF_INSTALL "freeradius freeradius-utils" + + LOG_INFO "End to prepare the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + + echo "steve Cleartext-Password := \"testing\" + Service-Type = Framed-User, + Framed-Protocol = PPP, + Framed-IP-Address = 172.16.3.33, + Framed-IP-Netmask = 255.255.255.0, + Framed-Routing = Broadcast-Listen, + Framed-Filter-Id = \"std.ppp\", + Framed-MTU = 1500, + Framed-Compression = Van-Jacobsen-TCP-IP + " >>/etc/raddb/users + systemctl start radiusd + SLEEP_WAIT 2 + radtest -d /etc/raddb/ steve testing localhost 0 testing123 | grep "Access-Accept" + CHECK_RESULT $? 0 0 "radtest -d execution failed." + radtest -t pap steve testing localhost 0 testing123 | grep "Access-Accept" + CHECK_RESULT $? 0 0 "radtest -t execution failed." + radtest -P udp steve testing localhost 0 testing123 | grep "Access-Accept" + CHECK_RESULT $? 0 0 "radtest -P execution failed." + radtest -x steve testing localhost 0 testing123 | grep "Access-Accept" + CHECK_RESULT $? 0 0 "radtest -x execution failed." + radtest -4 steve testing localhost 0 testing123 | grep "Access-Accept" + CHECK_RESULT $? 0 0 "radtest -4 execution failed." + radtest -6 steve testing localhost 0 testing123 | grep "\[" + CHECK_RESULT $? 0 0 "radtest -6 execution failed." + systemctl stop radiusd + touch /var/log/radius/radutmp + radwho -c | grep "Name" + CHECK_RESULT $? 0 0 "radwho -c execution failed." + radwho -d /etc/raddb/ | grep "Name" + CHECK_RESULT $? 0 0 "radwho -d execution failed." + radwho -F /var/log/radius/radutmp | grep "Name" + CHECK_RESULT $? 0 0 "radwho -F execution failed." + + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + + DNF_REMOVE + rm -rf /etc/raddb + rm -rf /var/log/radius + + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radwho/oe_test_freeradius_freeradius-utils_radwho.sh b/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radwho/oe_test_freeradius_freeradius-utils_radwho.sh new file mode 100644 index 0000000000000000000000000000000000000000..c2c32eba52bc35f017661aac7eae5e1d1e43e9c9 --- /dev/null +++ b/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radwho/oe_test_freeradius_freeradius-utils_radwho.sh @@ -0,0 +1,69 @@ +#!/usr/bin/bash + +# Copyright (c) 2021. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/12/24 +#@Desc : freeradius-utils command parameter automation use case +#################################### + +source ${OET_PATH}/libs/locallibs/common_lib.sh + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + + DNF_INSTALL "freeradius freeradius-utils" + + LOG_INFO "End to prepare the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + + touch /var/log/radius/radutmp + radwho -i | grep "Name" + CHECK_RESULT $? 0 0 "radwho -i execution failed." + [ -z "$(radwho -n | grep "Name")" ] + CHECK_RESULT $? 0 0 "radwho -n execution failed." + radwho -N 127.0.0.1 | grep "Name" + CHECK_RESULT $? 0 0 "radwho -N execution failed." + radwho -p | grep "Name" + CHECK_RESULT $? 0 0 "radwho -p execution failed." + radwho -P 0 | grep "Name" + CHECK_RESULT $? 0 0 "radwho -P execution failed." + [ -z "$(radwho -r | grep "Login")" ] + CHECK_RESULT $? 0 0 "radwho -r execution failed." + radwho -RZN 127.0.0.1 | grep "NAS-IP-Address" + CHECK_RESULT $? 0 0 "radwho -RZ execution failed." + radwho -s | grep "Name" + CHECK_RESULT $? 0 0 "radwho -s execution failed." + radwho -S | grep "Name" + CHECK_RESULT $? 0 0 "radwho -S execution failed." + radwho -u steve | grep "Name" + CHECK_RESULT $? 0 0 "radwho -u execution failed." + radwho -U steve | grep "Name" + CHECK_RESULT $? 0 0 "radwho -U execution failed." + + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + + DNF_REMOVE + rm -rf /etc/raddb + rm -rf /var/log/radius + + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radzap/oe_test_freeradius_freeradius-utils_radzap.sh b/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radzap/oe_test_freeradius_freeradius-utils_radzap.sh new file mode 100644 index 0000000000000000000000000000000000000000..f72ed762ff7d580a6241d58bd61d0e05b5f567f2 --- /dev/null +++ b/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radzap/oe_test_freeradius_freeradius-utils_radzap.sh @@ -0,0 +1,64 @@ +#!/usr/bin/bash + +# Copyright (c) 2021. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/12/24 +#@Desc : freeradius-utils command parameter automation use case +#################################### + +source ${OET_PATH}/libs/locallibs/common_lib.sh + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + + DNF_INSTALL "freeradius freeradius-utils" + + LOG_INFO "End to prepare the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + + radzap -h 2>&1 | grep "Usage" + CHECK_RESULT $? 0 0 "radzap -h execution failed." + systemctl start radiusd + SLEEP_WAIT 1 + radzap -d /etc/raddb/ -N 127.0.0.1 127.0.0.1 testing123 | grep "Accounting-Response" + CHECK_RESULT $? 0 0 "radzap -d -N execution failed." + radzap -D /usr/share/freeradius -N 127.0.0.1 127.0.0.1 testing123 | grep "Accounting-Response" + CHECK_RESULT $? 0 0 "radzap -D -N execution failed." + touch /var/log/radius/radutmp + radzap -P 0 127.0.0.1 testing123 2>&1 | grep send + CHECK_RESULT $? 0 0 "radzap -P execution failed." + radzap -u steve 127.0.0.1 testing123 2>&1 | grep send + CHECK_RESULT $? 0 0 "radzap -u execution failed." + radzap -U steve 127.0.0.1 testing123 2>&1 | grep send + CHECK_RESULT $? 0 0 "radzap -U execution failed." + radzap -x -N 127.0.0.1 127.0.0.1 testing123 | grep "NAS-IP-Address" + CHECK_RESULT $? 0 0 "radzap -x -N execution failed." + systemctl stop radiusd + + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + + DNF_REMOVE + rm -rf /etc/raddb + rm -rf /var/log/radius + + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_rlm_ippool_toolAndSmbencrypt/oe_test_freeradius_freeradius-utils_rlm_ippool_toolAndSmbencrypt.sh b/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_rlm_ippool_toolAndSmbencrypt/oe_test_freeradius_freeradius-utils_rlm_ippool_toolAndSmbencrypt.sh new file mode 100644 index 0000000000000000000000000000000000000000..e3bf7310e4e6b013c05b2f704d10e63777b8167e --- /dev/null +++ b/testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_rlm_ippool_toolAndSmbencrypt/oe_test_freeradius_freeradius-utils_rlm_ippool_toolAndSmbencrypt.sh @@ -0,0 +1,69 @@ +#!/usr/bin/bash + +# Copyright (c) 2021. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/12/24 +#@Desc : freeradius-utils command parameter automation use case +#################################### + +source ${OET_PATH}/libs/locallibs/common_lib.sh + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + + DNF_INSTALL "freeradius freeradius-utils" + + LOG_INFO "End to prepare the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + + ln -s /etc/raddb/mods-available/ippool /etc/raddb/mods-enabled/ippool + sed -i '/main_pool/a main_pool' /etc/raddb/sites-enabled/default + systemctl start radiusd + SLEEP_WAIT 1 + rlm_ippool_tool -n /etc/raddb/db.ippool /etc/raddb/db.ipindex 192.0.2.131 127.0.0.1 0 | grep Allocated + CHECK_RESULT $? 0 0 "rlm_ippool_tool -n execution failed." + rlm_ippool_tool -a /etc/raddb/db.ippool /etc/raddb/db.ipindex | grep "192.0.2.131" + CHECK_RESULT $? 0 0 "rlm_ippool_tool -a execution failed." + [ "$(rlm_ippool_tool -c /etc/raddb/db.ippool /etc/raddb/db.ipindex)" -eq 1 ] + CHECK_RESULT $? 0 0 "rlm_ippool_tool -c execution failed." + rlm_ippool_tool -r /etc/raddb/db.ippool /etc/raddb/db.ipindex + [ "$(rlm_ippool_tool -c /etc/raddb/db.ippool /etc/raddb/db.ipindex)" -eq 0 ] + CHECK_RESULT $? 0 0 "rlm_ippool_tool -r execution failed." + rlm_ippool_tool -v /etc/raddb/db.ippool /etc/raddb/db.ipindex | grep "KEY" + CHECK_RESULT $? 0 0 "rlm_ippool_tool -v execution failed." + rlm_ippool_tool -vo /etc/raddb/db.ippool /etc/raddb/db.ipindex | grep "NAS" + CHECK_RESULT $? 0 0 "rlm_ippool_tool -o execution failed." + rlm_ippool_tool -u /etc/raddb/db.ippool /etc/raddb/db_new.ippool + [ -e /etc/raddb/db_new.ippool ] + CHECK_RESULT $? 0 0 "rlm_ippool_tool -u execution failed." + systemctl stop radiusd + smbencrypt test 2>&1 | grep "Hash" + CHECK_RESULT $? 0 0 "smbencrypt execution failed." + + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + + DNF_REMOVE + rm -rf /etc/raddb + rm -rf /var/log/radius + + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/cli-test/freeradius/oe_test_freeradius_freeradius_raddebugAndCheckrad/oe_test_freeradius_freeradius_raddebugAndCheckrad.sh b/testcases/cli-test/freeradius/oe_test_freeradius_freeradius_raddebugAndCheckrad/oe_test_freeradius_freeradius_raddebugAndCheckrad.sh new file mode 100644 index 0000000000000000000000000000000000000000..92109ddc76f7241b79c4480871917b2417e9e60d --- /dev/null +++ b/testcases/cli-test/freeradius/oe_test_freeradius_freeradius_raddebugAndCheckrad/oe_test_freeradius_freeradius_raddebugAndCheckrad.sh @@ -0,0 +1,120 @@ +#!/usr/bin/bash + +# Copyright (c) 2021. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/12/22 +#@Desc : freeradius command parameter automation use case +#################################### + +source ${OET_PATH}/libs/locallibs/common_lib.sh + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + + DNF_INSTALL "freeradius" + + LOG_INFO "End to prepare the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + + ln -s /etc/raddb/sites-available/control-socket /etc/raddb/sites-enabled/control-socket + sed -i '/mode = rw/a mode = rw' /etc/raddb/sites-enabled/control-socket + sed -i '1i "test" Cleartext-Password := "pass123"' /etc/raddb/users + systemctl start radiusd + SLEEP_WAIT 1 + raddebug -c "&Framed-IP-Address == 127.0.0.1" & + SLEEP_WAIT 1 + ps -ef | grep "tail -f /var/log/radius" | grep -v grep + status=$? + SLEEP_WAIT 60 + [ -z $(ps -ef | grep "raddebug -c" | grep -v grep) ] && [ "${status}" -eq 0 ] + CHECK_RESULT $? 0 0 "raddebug -c execution failed." + raddebug -d /etc/raddb/ & + SLEEP_WAIT 1 + ps -ef | grep "tail -f /var/log/radius" | grep -v grep + status=$? + SLEEP_WAIT 60 + [ -z $(ps -ef | grep "raddebug -d" | grep -v grep) ] && [ "${status}" -eq 0 ] + CHECK_RESULT $? 0 0 "raddebug -d execution failed." + cp /etc/raddb/radiusd.conf /etc/raddb/test.conf + raddebug -n test & + SLEEP_WAIT 1 + ps -ef | grep "tail -f /var/log/radius" | grep -v grep + status=$? + SLEEP_WAIT 60 + [ -z $(ps -ef | grep "raddebug -n" | grep -v grep) ] && [ "${status}" -eq 0 ] + CHECK_RESULT $? 0 0 "raddebug -n execution failed." + raddebug -D /usr/share/freeradius & + SLEEP_WAIT 1 + ps -ef | grep "tail -f /var/log/radius" | grep -v grep + status=$? + SLEEP_WAIT 60 + [ -z $(ps -ef | grep "raddebug -D" | grep -v grep) ] && [ "${status}" -eq 0 ] + CHECK_RESULT $? 0 0 "raddebug -D execution failed." + raddebug -i "$NODE1_IPV4" & + SLEEP_WAIT 1 + ps -ef | grep "tail -f /var/log/radius" | grep -v grep + status=$? + SLEEP_WAIT 60 + [ -z $(ps -ef | grep "raddebug -i" | grep -v grep) ] && [ "${status}" -eq 0 ] + CHECK_RESULT $? 0 0 "raddebug -i execution failed." + raddebug -I "$NODE1_IPV6" & + SLEEP_WAIT 1 + ps -ef | grep "tail -f /var/log/radius" | grep -v grep + status=$? + SLEEP_WAIT 60 + [ -z $(ps -ef | grep "raddebug -I" | grep -v grep) ] && [ "${status}" -eq 0 ] + CHECK_RESULT $? 0 0 "raddebug -I execution failed." + raddebug -f /var/run/radiusd/radiusd.sock & + SLEEP_WAIT 1 + ps -ef | grep "tail -f /var/log/radius" | grep -v grep + status=$? + SLEEP_WAIT 60 + [ -z $(ps -ef | grep "raddebug -f" | grep -v grep) ] && [ "${status}" -eq 0 ] + CHECK_RESULT $? 0 0 "raddebug -f execution failed." + raddebug -t 2 & + SLEEP_WAIT 1 + ps -ef | grep "tail -f /var/log/radius" | grep -v grep + status=$? + SLEEP_WAIT 2 + [ -z $(ps -ef | grep "raddebug -t" | grep -v grep) ] && [ "${status}" -eq 0 ] + CHECK_RESULT $? 0 0 "raddebug -t execution failed." + raddebug -u test & + SLEEP_WAIT 1 + ps -ef | grep "tail -f /var/log/radius" | grep -v grep + status=$? + SLEEP_WAIT 60 + [ -z $(ps -ef | grep "raddebug -u" | grep -v grep) ] && [ "${status}" -eq 0 ] + CHECK_RESULT $? 0 0 "raddebug -u execution failed." + checkrad other 127.0.0.1 0 test 1 + stat=$? + [ "$stat" -eq 0 ] || [ "$stat" -eq 1 ] + CHECK_RESULT $? 0 0 "checkrad execution failed." + systemctl stop radiusd + + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + + DNF_REMOVE + rm -rf /etc/raddb + rm -rf /var/log/radius + + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/cli-test/freeradius/oe_test_freeradius_freeradius_radiusd/oe_test_freeradius_freeradius_radiusd.sh b/testcases/cli-test/freeradius/oe_test_freeradius_freeradius_radiusd/oe_test_freeradius_freeradius_radiusd.sh new file mode 100644 index 0000000000000000000000000000000000000000..90ff0bb34ceefa320463df364d4d0fbe47b9b447 --- /dev/null +++ b/testcases/cli-test/freeradius/oe_test_freeradius_freeradius_radiusd/oe_test_freeradius_freeradius_radiusd.sh @@ -0,0 +1,86 @@ +#!/usr/bin/bash + +# Copyright (c) 2021. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/12/22 +#@Desc : freeradius command parameter automation use case +#################################### + +source ${OET_PATH}/libs/locallibs/common_lib.sh + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + + DNF_INSTALL "freeradius" + + LOG_INFO "End to prepare the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + + radiusd -d /etc/raddb + ps -ef | grep "radiusd -d" | grep -v grep + CHECK_RESULT $? 0 0 "radiusd -d execution failed." + kill -9 $(pgrep -f "radiusd -d") + radiusd -D /usr/share/freeradius + ps -ef | grep "radiusd -D" | grep -v grep + CHECK_RESULT $? 0 0 "radiusd -D execution failed." + kill -9 $(pgrep -f "radiusd -D") + radiusd -f & + ps -ef | grep "radiusd -f" | grep -v grep + CHECK_RESULT $? 0 0 "radiusd -f execution failed." + kill -9 $(pgrep -f "radiusd -f") + radiusd -h | grep -i "usage" + CHECK_RESULT $? 0 0 "radiusd -h execution failed." + rdport=$(GET_FREE_PORT "$NODE1_IPV4") + radiusd -i "$NODE1_IPV4" -p "${rdport}" + ps -ef | grep "radiusd -i" | grep -v grep + CHECK_RESULT $? 0 0 "radiusd -i -p execution failed." + kill -9 $(pgrep -f "radiusd -i") + radiusd -l /tmp/test.log + ps -ef | grep "radiusd -l" | grep -v grep && [ -s /tmp/test.log ] + CHECK_RESULT $? 0 0 "radiusd -l execution failed." + kill -9 $(pgrep -f "radiusd -l") + cp /etc/raddb/radiusd.conf /etc/raddb/test.conf + radiusd -n test + ps -ef | grep "radiusd -n" | grep -v grep + CHECK_RESULT $? 0 0 "radiusd -n execution failed." + kill -9 $(pgrep -f "radiusd -n") + radiusd -P + result1=$(cat /var/run/radiusd/radiusd.pid) + result2=$(ps -ef | grep "radiusd -P" | grep -v grep | awk '{print $2}') + [ "${result1}" -eq "${result2}" ] + CHECK_RESULT $? 0 0 "radiusd -P execution failed." + kill -9 "${result1}" + radiusd -s & + [ "$(ps -ef | grep "radiusd -s" | grep -v grep | awk '{print $3}')" -ne 1 ] + CHECK_RESULT $? 0 0 "radiusd -s execution failed." + kill -9 $(pgrep -f "radiusd -s") + + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + + DNF_REMOVE + rm -rf /etc/raddb + rm -rf /var/log/radius + rm -rf /tmp/test.log + rm -rf /var/run/radiusd + + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/cli-test/freeradius/oe_test_freeradius_freeradius_radiusdAndRadmin/oe_test_freeradius_freeradius_radiusdAndRadmin.sh b/testcases/cli-test/freeradius/oe_test_freeradius_freeradius_radiusdAndRadmin/oe_test_freeradius_freeradius_radiusdAndRadmin.sh new file mode 100644 index 0000000000000000000000000000000000000000..e1e7c224b855f6bcd5464a200d02140576b68b24 --- /dev/null +++ b/testcases/cli-test/freeradius/oe_test_freeradius_freeradius_radiusdAndRadmin/oe_test_freeradius_freeradius_radiusdAndRadmin.sh @@ -0,0 +1,82 @@ +#!/usr/bin/bash + +# Copyright (c) 2021. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/12/22 +#@Desc : freeradius command parameter automation use case +#################################### + +source ${OET_PATH}/libs/locallibs/common_lib.sh + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + + DNF_INSTALL "freeradius" + echo "show version + quit + " >/tmp/radminfile + radiusd_version=$(rpm -q freeradius | awk -F '-' '{print $2}') + + LOG_INFO "End to prepare the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + + radiusd -v | grep "${radiusd_version}" + CHECK_RESULT $? 0 0 "radiusd -v execution failed." + radiusd -X | grep Loading & + CHECK_RESULT $? 0 0 "radiusd -X execution failed." + kill -9 $(pgrep -f "radiusd -X") + ln -s /etc/raddb/sites-available/control-socket /etc/raddb/sites-enabled/control-socket + systemctl start radiusd + SLEEP_WAIT 2 + radmin -d /etc/raddb /tmp/test & + [ ! -s /tmp/test ] + CHECK_RESULT $? 0 0 "radmin -q execution failed." + kill -9 $(pgrep -f "radmin -q") + systemctl stop radiusd + + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + + DNF_REMOVE + rm -rf /etc/raddb + rm -rf /var/log/radius + rm -rf /tmp/radminfile + rm -rf /tmp/test + + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/cli-test/geos/oe_test_geos_commandAndbaseFun/geos_test.cpp b/testcases/cli-test/geos/oe_test_geos_commandAndbaseFun/geos_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8c27cfcd75a1623b894132ef864e4fef42809736 --- /dev/null +++ b/testcases/cli-test/geos/oe_test_geos_commandAndbaseFun/geos_test.cpp @@ -0,0 +1,9 @@ +#include +#include +#include "geos.h" +using namespace std; +int main(){ +cout <<"geos's version is "<< GEOS_VERSION << endl; +cout <<"geos's jts_port is "<< GEOS_JTS_PORT << endl; +return 0; +} \ No newline at end of file diff --git a/testcases/cli-test/geos/oe_test_geos_commandAndbaseFun/oe_test_geos_commandAndbaseFun.sh b/testcases/cli-test/geos/oe_test_geos_commandAndbaseFun/oe_test_geos_commandAndbaseFun.sh new file mode 100644 index 0000000000000000000000000000000000000000..9665e64e44a86f26cac7e7dce06035614cad426f --- /dev/null +++ b/testcases/cli-test/geos/oe_test_geos_commandAndbaseFun/oe_test_geos_commandAndbaseFun.sh @@ -0,0 +1,72 @@ +#!/usr/bin/bash + +# Copyright (c) 2021. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2021/5/31 +#@Desc : Geos command line and basic function verification +#################################### + +source ${OET_PATH}/libs/locallibs/common_lib.sh + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + + DNF_INSTALL "gcc-c++ libstdc++-devel geos geos-devel" + + LOG_INFO "End to prepare the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + + geos-config --prefix | grep "/usr" + CHECK_RESULT $? 0 0 "geos-config --prefix execution failed." + geos-config --version | grep "$(rpm -q geos | awk -F '-' '{print $2}')" + CHECK_RESULT $? 0 0 "geos-config --version execution failed." + geos-config --libs | grep "\-lgeos" + CHECK_RESULT $? 0 0 "geos-config --libs execution failed." + geos-config --clibs | grep "\-lgeos_c" + CHECK_RESULT $? 0 0 "geos-config --clibs execution failed." + geos-config --cclibs | grep "\-lgeos" + CHECK_RESULT $? 0 0 "geos-config --cclibs execution failed." + geos-config --static-clibs | grep "\-lgeos_c \-lgeos \-lm" + CHECK_RESULT $? 0 0 "geos-config --static-clibs execution failed." + geos-config --static-cclibs | grep "\-lgeos \-lm" + CHECK_RESULT $? 0 0 "geos-config --static-cclibs execution failed." + geos-config --cflags | grep "\-I/usr/include" + CHECK_RESULT $? 0 0 "geos-config --cflags execution failed." + geos-config --ldflags | grep "\-L/usr/lib64" + CHECK_RESULT $? 0 0 "geos-config --ldflags execution failed." + geos-config --includes | grep "/usr/include" + CHECK_RESULT $? 0 0 "geos-config --includes execution failed." + g++ geos_test.cpp -o geos_test + ./geos_test >/tmp/geosfile + grep "$(rpm -q geos | awk -F '-' '{print $2}')" /tmp/geosfile + CHECK_RESULT $? 0 0 "geos-config base func execution failed." + grep "$(geos-config --jtsport)" /tmp/geosfile + CHECK_RESULT $? 0 0 "geos-config --jtsport execution failed." + + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + + DNF_REMOVE + rm -rf ./geos_test + rm -rf /tmp/geosfile + + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/cli-test/iperf3/common/common_lib.sh b/testcases/cli-test/iperf3/common/common_lib.sh new file mode 100644 index 0000000000000000000000000000000000000000..8457ea8fcf7dc600ae46baa79f3bbf0b776fc27d --- /dev/null +++ b/testcases/cli-test/iperf3/common/common_lib.sh @@ -0,0 +1,38 @@ +#!/usr/bin/bash + +# Copyright (c) 2021. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/10/10 +#@Desc : iperf3 command line test public functions +#################################### + +source ${OET_PATH}/libs/locallibs/common_lib.sh + +function pre_env() { + + DNF_INSTALL "iperf3" + DNF_INSTALL "iperf3" 2 + P_SSH_CMD --cmd "systemctl stop firewalld + iperf3 -s >/dev/null 2>&1 & + " + +} + +function clean_env() { + + P_SSH_CMD --cmd "kill -9 \$(ps -ef | grep \\\"iperf3 -s\\\" | grep -v grep | awk '{print \$2}') + systemctl start firewalld + " + DNF_REMOVE + +} diff --git a/testcases/cli-test/iperf3/oe_test_iperf3_command_client/oe_test_iperf3_command_client.sh b/testcases/cli-test/iperf3/oe_test_iperf3_command_client/oe_test_iperf3_command_client.sh new file mode 100644 index 0000000000000000000000000000000000000000..199852a5caeff2c6db7bdbfdb4391c96ebda830f --- /dev/null +++ b/testcases/cli-test/iperf3/oe_test_iperf3_command_client/oe_test_iperf3_command_client.sh @@ -0,0 +1,57 @@ +#!/usr/bin/bash + +# Copyright (c) 2021. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/10/10 +#@Desc : iperf3 command parameter automation use case +#################################### + +source ../common/common_lib.sh + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + + pre_env + + LOG_INFO "End to prepare the test environment." +} +function run_test() { + LOG_INFO "Start to run test." + + iperf3 -c "$NODE2_IPV4" -n 1400 -V | grep "1400 bytes to send" + CHECK_RESULT $? 0 0 "iperf3 -n execution failed." + iperf3 -c "$NODE2_IPV4" -k 1400 -V | grep "1400 blocks to send" + CHECK_RESULT $? 0 0 "iperf3 -k execution failed." + iperf3 -c "$NODE2_IPV4" -P 2 | grep -c connected | grep 2 + CHECK_RESULT $? 0 0 "iperf3 -P execution failed." + iperf3 -c "$NODE2_IPV4" --get-server-output | grep "Server output" + CHECK_RESULT $? 0 0 "iperf3 --get-server-output execution failed." + [ $(expr $(iperf3 -c "$NODE2_IPV4" -w 20240 | grep "sender" | awk '{print $5}') \> $(iperf3 -c "$NODE2_IPV4" -w 102400 | grep "sender" | awk '{print $5}')) -eq 0 ] + CHECK_RESULT $? 0 0 "iperf3 -w execution failed." + iperf3 -c "$NODE2_IPV4" -R | grep "Reverse mode" + CHECK_RESULT $? 0 0 "iperf3 -R execution failed." + iperf3 -c "$NODE2_IPV4" -T test | grep "test:" + CHECK_RESULT $? 0 0 "iperf3 -T execution failed." + + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + + clean_env + + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/cli-test/iperf3/oe_test_iperf3_command_clientAndShared/oe_test_iperf3_command_clientAndShared.sh b/testcases/cli-test/iperf3/oe_test_iperf3_command_clientAndShared/oe_test_iperf3_command_clientAndShared.sh new file mode 100644 index 0000000000000000000000000000000000000000..344a94ed43a03c705c1cf22b135e8b195843333b --- /dev/null +++ b/testcases/cli-test/iperf3/oe_test_iperf3_command_clientAndShared/oe_test_iperf3_command_clientAndShared.sh @@ -0,0 +1,60 @@ +#!/usr/bin/bash + +# Copyright (c) 2021. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/10/10 +#@Desc : iperf3 command parameter automation use case +#################################### + +source ../common/common_lib.sh + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + + pre_env + + LOG_INFO "End to prepare the test environment." +} +function run_test() { + LOG_INFO "Start to run test." + + iperf3 -c "$NODE2_IPV4" -d | grep "sent.*bytes of.*total" + CHECK_RESULT $? 0 0 "iperf3 -d execution failed." + iperf3 -c "$NODE2_IPV4" -f k | grep "Kbits" + CHECK_RESULT $? 0 0 "iperf3 -f execution failed." + iperf3 -c "$NODE2_IPV4" -V | grep "Cookie" + CHECK_RESULT $? 0 0 "iperf3 -V execution failed." + iperf3 -c "$NODE2_IPV4" -J | sed -n '1p' | grep "{" && iperf3 -c "$NODE2_IPV4" -J | sed -n '$p' | grep "}" + CHECK_RESULT $? 0 0 "iperf3 -J execution failed." + iperf3 -c "$NODE2_IPV4" --logfile /tmp/iperf3.log && grep "iperf Done" /tmp/iperf3.log + CHECK_RESULT $? 0 0 "iperf3 --logfile execution failed." + iperf3 -c "$NODE2_IPV4" -u | grep "Datagrams" + CHECK_RESULT $? 0 0 "iperf3 -u execution failed." + time -p (iperf3 -c "$NODE2_IPV4" -t 2 | sed -n '/real/p' >/tmp/tmp) >>/tmp/tmp 2>&1 + [ $(expr $(sed -n '1p' /tmp/tmp | grep "real" | awk '{print $2}') \< 3) -eq 1 ] + CHECK_RESULT $? 0 0 "iperf3 -t 2 execution failed." + + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + + clean_env + rm -rf /tmp/iperf3.log + rm -rf /tmp/tmp + + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/cli-test/iperf3/oe_test_iperf3_command_serverAndBase/oe_test_iperf3_command_serverAndBase.sh b/testcases/cli-test/iperf3/oe_test_iperf3_command_serverAndBase/oe_test_iperf3_command_serverAndBase.sh new file mode 100644 index 0000000000000000000000000000000000000000..6a44711f04f540bc74a3620c9e42ea31d8da814c --- /dev/null +++ b/testcases/cli-test/iperf3/oe_test_iperf3_command_serverAndBase/oe_test_iperf3_command_serverAndBase.sh @@ -0,0 +1,80 @@ +#!/usr/bin/bash + +# Copyright (c) 2021. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/10/10 +#@Desc : iperf3 command parameter automation use case,use server execution +#################################### + +source ${OET_PATH}/libs/locallibs/common_lib.sh + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + + DNF_INSTALL "iperf3 net-tools" + DNF_INSTALL "iperf3" 2 + + LOG_INFO "End to prepare the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + + iperf3 -v | grep $(rpm -q iperf3 | awk -F '-' '{print $2}') + CHECK_RESULT $? 0 0 "iperf3 -v execution failed." + iperf3 --version | grep $(rpm -q iperf3 | awk -F '-' '{print $2}') + CHECK_RESULT $? 0 0 "iperf3 --version execution failed." + iperf3 -h | grep "Usage" + CHECK_RESULT $? 0 0 "iperf3 -h execution failed." + iperf3 --help | grep "Usage" + CHECK_RESULT $? 0 0 "iperf3 --help execution failed." + systemctl stop firewalld + iperf3 -s & + SLEEP_WAIT 2 + netstat -lnp | grep 5201 | grep iperf3 + CHECK_RESULT $? 0 0 "iperf3 -s execution failed." + SSH_CMD "iperf3 -c $NODE1_IPV4" "$NODE2_IPV4" "$NODE2_PASSWORD" "$NODE2_USER" | grep "iperf Done" + CHECK_RESULT $? 0 0 "iperf3 -c serverIP execution failed." + kill -9 $(pgrep -f "iperf3 -s") + rdport=$(GET_FREE_PORT "$NODE1_IPV4") + iperf3 -s -p "${rdport}" & + SLEEP_WAIT 2 + netstat -lnp | grep "${rdport}" | grep iperf3 + CHECK_RESULT $? 0 0 "iperf3 -s -p execution failed." + kill -9 $(pgrep -f "iperf3 -s -p ${rdport}") + iperf3 -s -I /tmp/iperf3_pid & + SLEEP_WAIT 2 + result=$(pgrep -f "iperf3 -s -I") + result1=$(cat /tmp/iperf3_pid) + [ "$result1" -eq "${result}" ] + CHECK_RESULT $? 0 0 "iperf3 -s -I execution failed." + kill -9 "$result1" + iperf3 -s -1 & + SSH_CMD "iperf3 -c $NODE1_IPV4" "$NODE2_IPV4" "$NODE2_PASSWORD" "$NODE2_USER" + [ -z $(pgrep -f "iperf3 -s") ] + CHECK_RESULT $? 0 0 "iperf3 -s -1 execution failed." + + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + + DNF_REMOVE + rm -rf /tmp/iperf3_pid + systemctl start firewalld + + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/cli-test/sqlite-jdbc/oe_test_sqlite-jdbc_connect/Test.java b/testcases/cli-test/sqlite-jdbc/oe_test_sqlite-jdbc_connect/Test.java new file mode 100644 index 0000000000000000000000000000000000000000..dc4d2d6ba95ce6ff2b55daa0b0fe8ac117a6cf87 --- /dev/null +++ b/testcases/cli-test/sqlite-jdbc/oe_test_sqlite-jdbc_connect/Test.java @@ -0,0 +1,41 @@ +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.Statement; +public class Test { + public static void main(String[] args) throws Exception { + Connection conn = null; + ResultSet rs = null; + Statement stat = null; + try { + Class.forName("org.sqlite.JDBC"); + conn = DriverManager.getConnection("jdbc:sqlite:test.db"); + System.out.println("The connection object con is: "+conn); + stat = conn.createStatement(); + rs = stat.executeQuery("select * from t_user;"); + while (rs.next()) { + System.out.print("t_user_name = " + rs.getString("name")+ " "); + System.out.println("t_user_age = " + rs.getInt("age")); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (rs != null) { + try { + rs.close(); + } finally { + if (stat != null) { + try { + stat.close(); + } finally { + if (conn != null) { + conn.close(); + } + } + } + } + } + } + } +} diff --git a/testcases/cli-test/sqlite-jdbc/oe_test_sqlite-jdbc_connect/oe_test_sqlite-jdbc_connect.sh b/testcases/cli-test/sqlite-jdbc/oe_test_sqlite-jdbc_connect/oe_test_sqlite-jdbc_connect.sh new file mode 100644 index 0000000000000000000000000000000000000000..5722c242c73645a4fd02d9ea1471a28b5cf98174 --- /dev/null +++ b/testcases/cli-test/sqlite-jdbc/oe_test_sqlite-jdbc_connect/oe_test_sqlite-jdbc_connect.sh @@ -0,0 +1,57 @@ +#!/usr/bin/bash + +# Copyright (c) 2021. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/11/16 +#@Desc : SQLite jdbc driver test +#################################### + +source ${OET_PATH}/libs/locallibs/common_lib.sh + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + + if ! java -version; then + java_version=$(dnf list | grep "java-1.8.*-openjdk" | awk -F '-' '{print $2}' | sed -n '1p') + DNF_INSTALL "java-${java_version}-openjdk java-${java_version}-openjdk-devel sqlite-jdbc" + else + DNF_INSTALL "sqlite-jdbc" + fi + sqlite_jdbc_jar=$(rpm -ql sqlite-jdbc | grep sqlite-jdbc.jar) + export CLASSPATH=${sqlite_jdbc_jar}:. + + LOG_INFO "End to prepare the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + + javac Test.java + CHECK_RESULT $? 0 0 "java source code compilation failed." + java Test | grep "org.sqlite.SQLiteConnection" && java Test | grep "t_user_name" + CHECK_RESULT $? 0 0 "sqlite-jdbc driver is invalid." + + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + + unset CLASSPATH + rm -rf ./*.class + DNF_REMOVE + + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/cli-test/sqlite-jdbc/oe_test_sqlite-jdbc_connect/test.db b/testcases/cli-test/sqlite-jdbc/oe_test_sqlite-jdbc_connect/test.db new file mode 100644 index 0000000000000000000000000000000000000000..9f85db5aad925cb0f3a753dadce013b6ad1cdafe Binary files /dev/null and b/testcases/cli-test/sqlite-jdbc/oe_test_sqlite-jdbc_connect/test.db differ diff --git a/testcases/package-test/testNG/common/IHookableImp.java b/testcases/package-test/testNG/common/IHookableImp.java new file mode 100644 index 0000000000000000000000000000000000000000..3e465b7d649d5039c6f14d319237eb5402e41606 --- /dev/null +++ b/testcases/package-test/testNG/common/IHookableImp.java @@ -0,0 +1,11 @@ +import org.testng.IHookCallBack; +import org.testng.IHookable; +import org.testng.ITestResult; + +public class IHookableImp implements IHookable { + @Override + public void run(IHookCallBack iHookCallBack, ITestResult iTestResult) { + System.out.println("Listening method IHookableImp has been executed"); + iHookCallBack.runTestMethod(iTestResult); + } +} \ No newline at end of file diff --git a/testcases/package-test/testNG/common/TExpAssert.java b/testcases/package-test/testNG/common/TExpAssert.java new file mode 100644 index 0000000000000000000000000000000000000000..97caf73184658e7e4edf7581c8d6f17b07b7b760 --- /dev/null +++ b/testcases/package-test/testNG/common/TExpAssert.java @@ -0,0 +1,77 @@ +import org.testng.annotations.Test; +import org.testng.Assert; +import org.testng.asserts.SoftAssert; + +public class TExpAssert { + @Test + public void assertTest1() { + Assert.assertEquals(1, 1, "Two parameter values are not the same"); + System.out.println("Print the statement after the assertion11"); + Assert.assertEquals(1, 2, "Two parameter values not the same"); + System.out.println("Print the statement after the assertion12"); + } + + @Test + public void assertTest2() { + boolean a = false; + boolean b = true; + Assert.assertFalse(a, "Condition is not False"); + System.out.println("Print the statement after the assertion21"); + Assert.assertFalse(b, "Condition is not False"); + System.out.println("Print the statement after the assertion22"); + } + + @Test + public void assertTest3() { + SoftAssert assertion = new SoftAssert(); + assertion.assertEquals(1, 1, "Two parameter values are not equal"); + System.out.println("The statement after printing31"); + assertion.assertEquals(1, 2, "Two parameter values are not equal"); + System.out.println("The statement after printing32"); + assertion.assertAll(); + } + + @Test + public void assertTest4() { + Integer[] array1 = new Integer[] { 1, 2, 3 }; + Integer[] array2 = new Integer[] { 2, 3, 1 }; + Assert.assertEqualsNoOrder(array1, array2, "Two parameter values are not the same"); + System.out.println("Print the statement after the assertion41"); + } + + @Test + public void assertTest5() { + Assert.assertNotEquals(1, 2, "Both are the same"); + System.out.println("Print the statement after the assertion51"); + } + + @Test + public void assertTest6() { + int a = 1; + Assert.assertNotNull(a, "Object is NULL"); + System.out.println("Print the statement after the assertion61"); + } + + @Test + public void assertTest7() { + String a = "a"; + String b = "a"; + Assert.assertSame(a, b, "Object id is different"); + System.out.println("Print the statement after the assertion71"); + } + + @Test + public void assertTest8() { + String a = "a"; + String b = "b"; + Assert.assertNotSame(a, b, "Same object id"); + System.out.println("Print the statement after the assertion81"); + } + + @Test + public void assertTest9() { + Boolean a = true; + Assert.assertTrue(a, "Object value is FAlse"); + System.out.println("Print the statement after the assertion91"); + } +} \ No newline at end of file diff --git a/testcases/package-test/testNG/common/TExpBase.java b/testcases/package-test/testNG/common/TExpBase.java new file mode 100644 index 0000000000000000000000000000000000000000..d9c4285c6ae71dbe3b1ef854bcea4bad7b6be5c3 --- /dev/null +++ b/testcases/package-test/testNG/common/TExpBase.java @@ -0,0 +1,61 @@ +import org.testng.annotations.Test; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.AfterTest; +import org.testng.annotations.AfterSuite; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.AfterClass; + +public class TExpBase { + @BeforeClass + public void beforeClass() { + System.out.println("@BeforeClass"); + } + + @BeforeSuite + public void beforeSuite() { + System.out.println("@BeforeSuite"); + } + + @BeforeTest + public void beforeTest() { + System.out.println("@BeforeTest"); + } + + @BeforeMethod + public void beforeMethod() { + System.out.println("@BeforeMethod"); + } + + @AfterMethod + public void afterMethod() { + System.out.println("@AfterMethod"); + } + + @AfterTest + public void afterTest() { + System.out.println("@AfterTest"); + } + + @AfterSuite + public void afterSuite() { + System.out.println("@AfterSuite"); + } + + @AfterClass + public void afterClass() { + System.out.println("@AfterClass"); + } + + @Test + public void testBase1() { + System.out.println("testBase1"); + } + + @Test + public void testBase2() { + System.out.println("testBase2"); + } +} diff --git a/testcases/package-test/testNG/common/TExpBase.xml b/testcases/package-test/testNG/common/TExpBase.xml new file mode 100644 index 0000000000000000000000000000000000000000..2fe0c97fd7b69459ff28960c287da24aa831bef8 --- /dev/null +++ b/testcases/package-test/testNG/common/TExpBase.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/testcases/package-test/testNG/common/TExpGroups.java b/testcases/package-test/testNG/common/TExpGroups.java new file mode 100644 index 0000000000000000000000000000000000000000..44e34ee0b43b1abfacc95b41c715b9f0645d5cd9 --- /dev/null +++ b/testcases/package-test/testNG/common/TExpGroups.java @@ -0,0 +1,44 @@ +import org.testng.annotations.Test; + +@Test(groups = { "classgroup" }) +public class TExpGroups { + @Test(groups = { "methodgroup1", "methodgroup2" }) + public void testGroups1() { + System.out.println("Method testGroups1 has been run"); + } + + @Test(groups = { "linux" }) + public void testGroups2() { + System.out.println("Method testGroups2 has been run"); + } + + @Test(groups = { "windows" }) + public void testGroups3() { + System.out.println("Method testGroups3 has been run"); + } + + @Test(groups = { "methodgroup1", "linux" }) + public void testGroups4() { + System.out.println("Method testGroups4 has been run"); + } + + @Test(groups = { "linux.methodgroup1" }) + public void testGroups5() { + System.out.println("Method testGroups5 has been run"); + } + + @Test(groups = { "linux.methodgroup2" }) + public void testGroups6() { + System.out.println("Method testGroups6 has been run"); + } + + @Test(groups = { "methodgroup1" }) + public void testGroups7() { + System.out.println("Method testGroups7 has been run"); + } + + @Test(groups = { "methodgroup1" }) + private void testGroups8() { + System.out.println("Method testGroups8 has been run"); + } +} \ No newline at end of file diff --git a/testcases/package-test/testNG/common/TExpListern.java b/testcases/package-test/testNG/common/TExpListern.java new file mode 100644 index 0000000000000000000000000000000000000000..437e98635de25ed77b0e9b327599b1781c01e207 --- /dev/null +++ b/testcases/package-test/testNG/common/TExpListern.java @@ -0,0 +1,10 @@ +import org.testng.annotations.Listeners; +import org.testng.annotations.Test; + +@Listeners(IHookableImp.class) +public class TExpListern { + @Test + public void test() { + System.out.println("test method has been executed"); + } +} \ No newline at end of file diff --git a/testcases/package-test/testNG/common/TExpParameters.java b/testcases/package-test/testNG/common/TExpParameters.java new file mode 100644 index 0000000000000000000000000000000000000000..506759e36c06296c11db834ce99953c65ede971a --- /dev/null +++ b/testcases/package-test/testNG/common/TExpParameters.java @@ -0,0 +1,46 @@ +import org.testng.annotations.Test; +import org.testng.annotations.Parameters; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Optional; +import org.testng.annotations.DataProvider; + +public class TExpParameters { + @BeforeMethod + @Parameters("before") + public void beforeParameter(String str) { + System.out.println("Parameters can also be used for before/after and factory comments:" + str); + } + + @Test + @Parameters({ "name", "sex" }) + public void testParameters1(String name, String sex) { + System.out.println("my name is:" + name); + System.out.println("My gender is:" + sex); + } + + @Test + @Parameters("str") + public void testParameters2(String str) { + System.out.println( + "In testng.xml, you can declare parameters under the tag or tag. If the two parameters have the same name, the parameters defined under the tag take precedence:" + + str); + } + + @Test + @Parameters("dbType") + public void testParameters3(@Optional("mysql") String dbType) { + System.out.println( + "In testng.xml, the default value of the Optional annotation is used when there is no dbType parameter:" + + dbType); + } + + @DataProvider(name = "datatest1") + public Object[][] createData1() { + return new Object[][] { { "yi", 2 }, { "er", 1 } }; + } + + @Test(dataProvider = "datatest1") + public void providerTest1(String strname, int intname) { + System.out.println("Digital reading:" + strname + ",The Arabic numerals are:" + intname); + } +} \ No newline at end of file diff --git a/testcases/package-test/testNG/common/applicationContext.xml b/testcases/package-test/testNG/common/applicationContext.xml new file mode 100644 index 0000000000000000000000000000000000000000..9a59a645b624098c48c486835f80d70aaa58e9de --- /dev/null +++ b/testcases/package-test/testNG/common/applicationContext.xml @@ -0,0 +1,18 @@ + + + + + + + + + \ No newline at end of file diff --git a/testcases/package-test/testNG/common/common_lib.sh b/testcases/package-test/testNG/common/common_lib.sh new file mode 100644 index 0000000000000000000000000000000000000000..e104ac77d91de8fc13d5b0c6772826a1a9918eed --- /dev/null +++ b/testcases/package-test/testNG/common/common_lib.sh @@ -0,0 +1,41 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/07/05 +#@Desc : testNG public methods about annotations +#################################### +source ${OET_PATH}/libs/locallibs/common_lib.sh + +function pre_env() { + + if ! java -version; then + java_version=$(dnf list | grep "java-1.8.*-openjdk" | awk -F '-' '{print $2}' | sed -n '1p') + DNF_INSTALL "java-${java_version}-openjdk java-${java_version}-openjdk-devel testng beust-jcommander" + else + DNF_INSTALL "testng beust-jcommander" + fi + testng_jar=$(rpm -ql testng | grep testng.jar) + jcommander_jar=$(rpm -ql beust-jcommander | grep beust-jcommander.jar) + export CLASSPATH=${testng_jar}:${jcommander_jar}:. + +} + +function clean_env() { + + unset CLASSPATH + rm -rf ./*.class + rm -rf ./test-output + DNF_REMOVE + +} diff --git a/testcases/package-test/testNG/oe_test_testNG_annotations_assert/TExpAssert.xml b/testcases/package-test/testNG/oe_test_testNG_annotations_assert/TExpAssert.xml new file mode 100644 index 0000000000000000000000000000000000000000..03b54370f3c123d871878e908dee9649b1c34ee5 --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_annotations_assert/TExpAssert.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/testcases/package-test/testNG/oe_test_testNG_annotations_assert/oe_test_testNG_annotations_assert.sh b/testcases/package-test/testNG/oe_test_testNG_annotations_assert/oe_test_testNG_annotations_assert.sh new file mode 100644 index 0000000000000000000000000000000000000000..ab8801215da50dbda12d6c61d07f7db2d9ce3f06 --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_annotations_assert/oe_test_testNG_annotations_assert.sh @@ -0,0 +1,48 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/4/29 +#@Desc : Assert related notes +#################################### + +source ../common/common_lib.sh + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + + pre_env + + LOG_INFO "End to prepare the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + + javac -d . ../common/TExpAssert.java + CHECK_RESULT $? 0 0 "java source code compilation failed." + java -cp "${CLASSPATH}" org.testng.TestNG TExpAssert.xml | grep "run: 9, Failures: 3, Skips: 0" + CHECK_RESULT $? 0 0 "testng execution use case failed." + + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + + clean_env + + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/package-test/testNG/oe_test_testNG_annotations_before_after/oe_test_testNG_annotations_before_after.sh b/testcases/package-test/testNG/oe_test_testNG_annotations_before_after/oe_test_testNG_annotations_before_after.sh new file mode 100644 index 0000000000000000000000000000000000000000..45d45ac1a82c748df06c8d4fbc592e4dd60405ea --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_annotations_before_after/oe_test_testNG_annotations_before_after.sh @@ -0,0 +1,48 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/4/29 +#@Desc : Before and after related notes +#################################### + +source ../common/common_lib.sh + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + + pre_env + + LOG_INFO "End to prepare the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + + javac -d . ../common/TExpBase.java + CHECK_RESULT $? 0 0 "java source code compilation failed." + java -cp "${CLASSPATH}" org.testng.TestNG ../common/TExpBase.xml | grep "run: 2, Failures: 0, Skips: 0" + CHECK_RESULT $? 0 0 "Use case execution failed." + + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + + clean_env + + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/package-test/testNG/oe_test_testNG_annotations_common/oe_test_testNG_annotations_common.sh b/testcases/package-test/testNG/oe_test_testNG_annotations_common/oe_test_testNG_annotations_common.sh new file mode 100644 index 0000000000000000000000000000000000000000..0240269ca9d690734622647aaf7a657fac7fa783 --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_annotations_common/oe_test_testNG_annotations_common.sh @@ -0,0 +1,48 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/4/29 +#@Desc : Annotation Comprehensive Application +#################################### + +source ../common/common_lib.sh + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + + pre_env + + LOG_INFO "End to prepare the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + + javac -d . ../common/*.java + CHECK_RESULT $? 0 0 "java source code compilation failed." + java -cp "${CLASSPATH}" org.testng.TestNG testngCommon.xml | grep "run: 35, Failures: 3, Skips: 0" + CHECK_RESULT $? 0 0 "testng execution use case failed." + + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + + clean_env + + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/package-test/testNG/oe_test_testNG_annotations_common/testngCommon.xml b/testcases/package-test/testNG/oe_test_testNG_annotations_common/testngCommon.xml new file mode 100644 index 0000000000000000000000000000000000000000..11980e15693240290c6511c491d3e23800e76aa1 --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_annotations_common/testngCommon.xml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/testcases/package-test/testNG/oe_test_testNG_annotations_group/TExpGroups.xml b/testcases/package-test/testNG/oe_test_testNG_annotations_group/TExpGroups.xml new file mode 100644 index 0000000000000000000000000000000000000000..744f17387a164efd44c14227aebaa7ccef5331eb --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_annotations_group/TExpGroups.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/testcases/package-test/testNG/oe_test_testNG_annotations_group/oe_test_testNG_annotations_group.sh b/testcases/package-test/testNG/oe_test_testNG_annotations_group/oe_test_testNG_annotations_group.sh new file mode 100644 index 0000000000000000000000000000000000000000..499525e7d310c8f12013a7bc9e1f95a8666afe6f --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_annotations_group/oe_test_testNG_annotations_group.sh @@ -0,0 +1,48 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/4/29 +#@Desc : Group related notes +#################################### + +source ../common/common_lib.sh + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + + pre_env + + LOG_INFO "End to prepare the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + + javac -d . ../common/TExpGroups.java + CHECK_RESULT $? 0 0 "java source code compilation failed." + java -cp "${CLASSPATH}" org.testng.TestNG TExpGroups.xml | grep "run: 18, Failures: 0, Skips: 0" + CHECK_RESULT $? 0 0 "testng execution use case failed." + + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + + clean_env + + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/package-test/testNG/oe_test_testNG_annotations_listen/TExpListern.xml b/testcases/package-test/testNG/oe_test_testNG_annotations_listen/TExpListern.xml new file mode 100644 index 0000000000000000000000000000000000000000..a13a9f514239350ed02fe21c9881227b8f8f0daa --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_annotations_listen/TExpListern.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/testcases/package-test/testNG/oe_test_testNG_annotations_listen/oe_test_testNG_annotations_listen.sh b/testcases/package-test/testNG/oe_test_testNG_annotations_listen/oe_test_testNG_annotations_listen.sh new file mode 100644 index 0000000000000000000000000000000000000000..d8e8ce8335e6bbf7d256b9b6b2f4158dc21aa683 --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_annotations_listen/oe_test_testNG_annotations_listen.sh @@ -0,0 +1,50 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/4/29 +#@Desc : Listen related notes +#################################### + +source ../common/common_lib.sh + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + + pre_env + + LOG_INFO "End to prepare the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + + javac -d . ../common/IHookableImp.java + CHECK_RESULT $? 0 0 "IHookableImp.java source code compilation failed." + javac -d . ../common/TExpListern.java + CHECK_RESULT $? 0 0 "TExpListern.java source code compilation failed." + java -cp "${CLASSPATH}" org.testng.TestNG TExpListern.xml | grep "run: 1, Failures: 0, Skips: 0" + CHECK_RESULT $? 0 0 "testng execution use case failed." + + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + + clean_env + + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/package-test/testNG/oe_test_testNG_annotations_parameters/TExpParameters.xml b/testcases/package-test/testNG/oe_test_testNG_annotations_parameters/TExpParameters.xml new file mode 100644 index 0000000000000000000000000000000000000000..2980723c4ed41609e3f7db78917694ac4c4de82f --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_annotations_parameters/TExpParameters.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/testcases/package-test/testNG/oe_test_testNG_annotations_parameters/oe_test_testNG_annotations_parameters.sh b/testcases/package-test/testNG/oe_test_testNG_annotations_parameters/oe_test_testNG_annotations_parameters.sh new file mode 100644 index 0000000000000000000000000000000000000000..03799fcd3f0710a9c97754031a721d6338facc36 --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_annotations_parameters/oe_test_testNG_annotations_parameters.sh @@ -0,0 +1,48 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/4/29 +#@Desc : Parameter related notes +#################################### + +source ../common/common_lib.sh + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + + pre_env + + LOG_INFO "End to prepare the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + + javac -d . ../common/TExpParameters.java + CHECK_RESULT $? 0 0 "java source code compilation failed." + java -cp "${CLASSPATH}" org.testng.TestNG TExpParameters.xml | grep "run: 5, Failures: 0, Skips: 0" + CHECK_RESULT $? 0 0 "testng execution use case failed." + + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + + clean_env + + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/package-test/testNG/oe_test_testNG_exception/TExpExc.java b/testcases/package-test/testNG/oe_test_testNG_exception/TExpExc.java new file mode 100644 index 0000000000000000000000000000000000000000..87d812959d4895020f5c64f54603b8e7de85704a --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_exception/TExpExc.java @@ -0,0 +1,8 @@ +import org.testng.annotations.Test; + +public class TExpExc { + @Test() + public void testMethod() { + System.out.println("hahahaha"); + } +} \ No newline at end of file diff --git a/testcases/package-test/testNG/oe_test_testNG_exception/TExpExc.xml b/testcases/package-test/testNG/oe_test_testNG_exception/TExpExc.xml new file mode 100644 index 0000000000000000000000000000000000000000..7b44dabcac7efa013972d8f90f6cf31be71db7f4 --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_exception/TExpExc.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/testcases/package-test/testNG/oe_test_testNG_exception/oe_test_testNG_exception.sh b/testcases/package-test/testNG/oe_test_testNG_exception/oe_test_testNG_exception.sh new file mode 100644 index 0000000000000000000000000000000000000000..41bb09aa3b5b41ce5d066cae3a48fa94bf5f608f --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_exception/oe_test_testNG_exception.sh @@ -0,0 +1,48 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/4/29 +#@Desc : testNG exception handling +#################################### + +source ../common/common_lib.sh + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + + pre_env + + LOG_INFO "End to prepare the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + + javac TExpExc.java + CHECK_RESULT $? 0 0 "java source code compilation failed." + java -cp "${CLASSPATH}" org.testng.TestNG TExpExc.xml | grep "run: 0, Failures: 0, Skips: 0" + CHECK_RESULT $? 0 0 "testng execution use case failed." + + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + + clean_env + + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/package-test/testNG/oe_test_testNG_retry/Retry.java b/testcases/package-test/testNG/oe_test_testNG_retry/Retry.java new file mode 100644 index 0000000000000000000000000000000000000000..1577912f7756e77f6722d45ec5b97310b26b6ba6 --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_retry/Retry.java @@ -0,0 +1,8 @@ +import org.testng.annotations.Test; + +public class Retry { + @Test() + public void testMethod() { + System.out.println(1 / 0); + } +} \ No newline at end of file diff --git a/testcases/package-test/testNG/oe_test_testNG_retry/Retry.xml b/testcases/package-test/testNG/oe_test_testNG_retry/Retry.xml new file mode 100644 index 0000000000000000000000000000000000000000..8ceb8cb20b233d725251035325b2e40e4741d4d1 --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_retry/Retry.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/testcases/package-test/testNG/oe_test_testNG_retry/oe_test_testNG_retry.sh b/testcases/package-test/testNG/oe_test_testNG_retry/oe_test_testNG_retry.sh new file mode 100644 index 0000000000000000000000000000000000000000..0e5a8e30e5cd326511aa9f57bc3c1d8d323227f6 --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_retry/oe_test_testNG_retry.sh @@ -0,0 +1,49 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/4/29 +#@Desc : TestNG error case retry +#################################### + +source ../common/common_lib.sh + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + + pre_env + + LOG_INFO "End to prepare the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + + javac Retry.java + CHECK_RESULT $? 0 0 "java source code compilation failed." + java -cp "${CLASSPATH}" org.testng.TestNG Retry.xml + java -cp "${CLASSPATH}" org.testng.TestNG test-output/testng-failed.xml | grep "run: 1, Failures: 1, Skips: 0" + CHECK_RESULT $? 0 0 "testng execution use case failed" + + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + + clean_env + + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh1.java b/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh1.java new file mode 100644 index 0000000000000000000000000000000000000000..6bae19105c39f766da7937850990fcbd14e3d969 --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh1.java @@ -0,0 +1,25 @@ +import org.testng.annotations.Test; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.AfterSuite; + +public class TExpTh1 { + private double beforetime; + private double aftertime; + + @Test(invocationCount = 500, threadPoolSize = 500) + public void testMethod() { + System.out.println("Thread Id :" + Thread.currentThread().getId()); + } + + @BeforeSuite + public void beforetest() { + this.beforetime = System.currentTimeMillis(); + + } + + @AfterSuite + public void aftertest() { + this.aftertime = System.currentTimeMillis(); + System.out.println("time is :" + (aftertime - beforetime)); + } +} \ No newline at end of file diff --git a/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh1.xml b/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh1.xml new file mode 100644 index 0000000000000000000000000000000000000000..d3b0f92d755f197f8d47b10cf7fd0e595f42e801 --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh1.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh2.java b/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh2.java new file mode 100644 index 0000000000000000000000000000000000000000..9a62f94ee427d3f9ffb8c0dbaa1cf2844db29ce7 --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh2.java @@ -0,0 +1,25 @@ +import org.testng.annotations.Test; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.AfterSuite; + +public class TExpTh2 { + private double beforetime; + private double aftertime; + + @Test(invocationCount = 1000, threadPoolSize = 1000) + public void testMethod() { + System.out.println("Thread Id :" + Thread.currentThread().getId()); + } + + @BeforeSuite + public void beforetest() { + this.beforetime = System.currentTimeMillis(); + + } + + @AfterSuite + public void aftertest() { + this.aftertime = System.currentTimeMillis(); + System.out.println("time is :" + (aftertime - beforetime)); + } +} \ No newline at end of file diff --git a/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh2.xml b/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh2.xml new file mode 100644 index 0000000000000000000000000000000000000000..74b319fabb2f4fbd7c2b7fec2ca61f8ebab8fa94 --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh2.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh3.java b/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh3.java new file mode 100644 index 0000000000000000000000000000000000000000..0bc9d558dad79e2e6198744a2810d4c7b1af961a --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh3.java @@ -0,0 +1,25 @@ +import org.testng.annotations.Test; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.AfterSuite; + +public class TExpTh3 { + private double beforetime; + private double aftertime; + + @Test(invocationCount = 3000, threadPoolSize = 3000) + public void testMethod() { + System.out.println("Thread Id :" + Thread.currentThread().getId()); + } + + @BeforeSuite + public void beforetest() { + this.beforetime = System.currentTimeMillis(); + + } + + @AfterSuite + public void aftertest() { + this.aftertime = System.currentTimeMillis(); + System.out.println("time is :" + (aftertime - beforetime)); + } +} \ No newline at end of file diff --git a/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh3.xml b/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh3.xml new file mode 100644 index 0000000000000000000000000000000000000000..ac61252bd2e783f6857cec585a52ac9e775c91cd --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh3.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh4.java b/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh4.java new file mode 100644 index 0000000000000000000000000000000000000000..548b50377fa92b891559082a1d1679b680eeeea9 --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh4.java @@ -0,0 +1,25 @@ +import org.testng.annotations.Test; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.AfterSuite; + +public class TExpTh4 { + private double beforetime; + private double aftertime; + + @Test(invocationCount = 3800, threadPoolSize = 3800) + public void testMethod() { + System.out.println("Thread Id :" + Thread.currentThread().getId()); + } + + @BeforeSuite + public void beforetest() { + this.beforetime = System.currentTimeMillis(); + + } + + @AfterSuite + public void aftertest() { + this.aftertime = System.currentTimeMillis(); + System.out.println("time is :" + (aftertime - beforetime)); + } +} \ No newline at end of file diff --git a/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh4.xml b/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh4.xml new file mode 100644 index 0000000000000000000000000000000000000000..0c77b359e73e3336a0ad223ccd48cfe45b2700e8 --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh4.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh5.java b/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh5.java new file mode 100644 index 0000000000000000000000000000000000000000..6117ae50d84f16e6e71c2e4436df3b149f6b3278 --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh5.java @@ -0,0 +1,25 @@ +import org.testng.annotations.Test; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.AfterSuite; + +public class TExpTh5 { + private double beforetime; + private double aftertime; + + @Test(invocationCount = 3900, threadPoolSize = 3900) + public void testMethod() { + System.out.println("Thread Id :" + Thread.currentThread().getId()); + } + + @BeforeSuite + public void beforetest() { + this.beforetime = System.currentTimeMillis(); + + } + + @AfterSuite + public void aftertest() { + this.aftertime = System.currentTimeMillis(); + System.out.println("time is :" + (aftertime - beforetime)); + } +} \ No newline at end of file diff --git a/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh5.xml b/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh5.xml new file mode 100644 index 0000000000000000000000000000000000000000..712d0b721248f9aa0caef534e932c70b0cd8815d --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh5.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh6.java b/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh6.java new file mode 100644 index 0000000000000000000000000000000000000000..d0018032ae8c917afd7f8c3b670a42044d190211 --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh6.java @@ -0,0 +1,25 @@ +import org.testng.annotations.Test; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.AfterSuite; + +public class TExpTh6 { + private double beforetime; + private double aftertime; + + @Test(invocationCount = 38000, threadPoolSize = 38000) + public void testMethod() { + System.out.println("Thread Id :" + Thread.currentThread().getId()); + } + + @BeforeSuite + public void beforetest() { + this.beforetime = System.currentTimeMillis(); + + } + + @AfterSuite + public void aftertest() { + this.aftertime = System.currentTimeMillis(); + System.out.println("time is :" + (aftertime - beforetime)); + } +} \ No newline at end of file diff --git a/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh6.xml b/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh6.xml new file mode 100644 index 0000000000000000000000000000000000000000..494033ed0b4ec3bac4b3138ca2709d15a1511727 --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh6.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh7.java b/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh7.java new file mode 100644 index 0000000000000000000000000000000000000000..387edd3f19be6581c0d8f643feb17699c3d1fa85 --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh7.java @@ -0,0 +1,25 @@ +import org.testng.annotations.Test; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.AfterSuite; + +public class TExpTh7 { + private double beforetime; + private double aftertime; + + @Test(invocationCount = 39000, threadPoolSize = 39000) + public void testMethod() { + System.out.println("Thread Id :" + Thread.currentThread().getId()); + } + + @BeforeSuite + public void beforetest() { + this.beforetime = System.currentTimeMillis(); + + } + + @AfterSuite + public void aftertest() { + this.aftertime = System.currentTimeMillis(); + System.out.println("time is :" + (aftertime - beforetime)); + } +} \ No newline at end of file diff --git a/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh7.xml b/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh7.xml new file mode 100644 index 0000000000000000000000000000000000000000..6096042a8e70553010c8957e2f0dcf1a6fc21260 --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_thread/TExpTh7.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/testcases/package-test/testNG/oe_test_testNG_thread/oe_test_testNG_thread.sh b/testcases/package-test/testNG/oe_test_testNG_thread/oe_test_testNG_thread.sh new file mode 100644 index 0000000000000000000000000000000000000000..3c244ea9b8e2926832c9509b59dd56cfaa701644 --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_thread/oe_test_testNG_thread.sh @@ -0,0 +1,67 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/4/29 +#@Desc : testNG multi-threaded processing +#################################### + +source ../common/common_lib.sh + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + + pre_env + + LOG_INFO "End to prepare the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + + javac TExpTh*.java + CHECK_RESULT $? 0 0 "java source code compilation failed." + java -cp "${CLASSPATH}" org.testng.TestNG TExpTh1.xml | grep "Thread Id" + CHECK_RESULT $? 0 0 "testng execution use case failed,The xml file is TExpTh1.xml" + java -cp "${CLASSPATH}" org.testng.TestNG TExpTh2.xml | grep "Thread Id" + CHECK_RESULT $? 0 0 "testng execution use case failed,The xml is TExpTh2.xml" + java -cp "${CLASSPATH}" org.testng.TestNG TExpTh3.xml | grep "Thread Id" + CHECK_RESULT $? 0 0 "testng execution use case failed,The xml is TExpTh3.xml" + if hostnamectl | grep "Virtualization"; then + java -cp "${CLASSPATH}" org.testng.TestNG TExpTh4.xml | grep "Thread Id" + CHECK_RESULT $? 0 0 "testng execution use case failed,The xml is TExpTh4.xml" + else + java -cp "${CLASSPATH}" org.testng.TestNG TExpTh6.xml | grep "Thread Id" + CHECK_RESULT $? 0 0 "testng execution use case failed,The xml is TExpTh6.xml" + fi + + if hostnamectl | grep "Virtualization"; then + java -cp "${CLASSPATH}" org.testng.TestNG TExpTh5.xml | grep "Thread Id" + CHECK_RESULT $? 0 0 "testng execution use case failed,The xml is TExpTh5.xml" + else + java -cp "${CLASSPATH}" org.testng.TestNG TExpTh7.xml | grep "Thread Id" + CHECK_RESULT $? 0 0 "testng execution use case failed,The xml is TExpTh7.xml" + fi + + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + + clean_env + + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/package-test/testNG/oe_test_testNG_with_Junit/JunitTestNG.java b/testcases/package-test/testNG/oe_test_testNG_with_Junit/JunitTestNG.java new file mode 100644 index 0000000000000000000000000000000000000000..417095e8c78ecff01600e480a740a1d316ffcfd8 --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_with_Junit/JunitTestNG.java @@ -0,0 +1,15 @@ +import org.junit.Before; +import org.junit.Test; + +public class JunitTestNG { + @Before + public void setUp() { + System.out.println("begin test"); + } + + @Test + public void testAdd() { + System.out.println("its ok"); + } + +} \ No newline at end of file diff --git a/testcases/package-test/testNG/oe_test_testNG_with_Junit/oe_test_testNG_with_Junit.sh b/testcases/package-test/testNG/oe_test_testNG_with_Junit/oe_test_testNG_with_Junit.sh new file mode 100644 index 0000000000000000000000000000000000000000..ec4f730716368badd157b8b03519285091664476 --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_with_Junit/oe_test_testNG_with_Junit.sh @@ -0,0 +1,52 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/4/29 +#@Desc : testNG integration Junit +#################################### + +source ../common/common_lib.sh + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + + pre_env + DNF_INSTALL "junit hamcrest" + junit_jar=$(rpm -ql junit | grep junit.jar) + hamcrestcore_jar=$(rpm -ql hamcrest | grep core.jar) + export CLASSPATH=${CLASSPATH}:${junit_jar}:${hamcrestcore_jar} + + LOG_INFO "End to prepare the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + + javac JunitTestNG.java + CHECK_RESULT $? 0 0 "java source code compilation failed." + java -cp "${CLASSPATH}" org.testng.TestNG testng_junit.xml | grep "run: 1, Failures: 0, Skips: 0" + CHECK_RESULT $? 0 0 "testng execution use case failed." + + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + + clean_env + + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/package-test/testNG/oe_test_testNG_with_Junit/testng_junit.xml b/testcases/package-test/testNG/oe_test_testNG_with_Junit/testng_junit.xml new file mode 100644 index 0000000000000000000000000000000000000000..c142c2ed10b3d7e681bc587ff03878c213f743c6 --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_with_Junit/testng_junit.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/testcases/package-test/testNG/oe_test_testNG_with_ant/build.xml b/testcases/package-test/testNG/oe_test_testNG_with_ant/build.xml new file mode 100644 index 0000000000000000000000000000000000000000..281b6e1f27b9d96d6e0125ce16414ee67da6d183 --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_with_ant/build.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/testcases/package-test/testNG/oe_test_testNG_with_ant/oe_test_testNG_with_ant.sh b/testcases/package-test/testNG/oe_test_testNG_with_ant/oe_test_testNG_with_ant.sh new file mode 100644 index 0000000000000000000000000000000000000000..b2ac4bb194683682db1803605b5ba3806fe22254 --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_with_ant/oe_test_testNG_with_ant.sh @@ -0,0 +1,72 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/4/29 +#@Desc : testNG integration ant +#################################### + +source ${OET_PATH}/libs/locallibs/common_lib.sh + +function config_params() { + LOG_INFO "Start to config params of the case." + + ant_path="/tmp/test/ant" + mkdir -p "${ant_path}" + antlib_path="${ant_path}/lib" + mkdir -p "${antlib_path}" + antsrc_path="${ant_path}/src" + mkdir -p "${antsrc_path}" + cp ../common/TExpBase.java "${antsrc_path}" + cp build.xml "${ant_path}" + cp ../common/TExpBase.xml "${ant_path}" + + LOG_INFO "End to config params of the case." +} + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + + if ! java -version; then + java_version=$(dnf list | grep "java-1.8.*-openjdk" | awk -F '-' '{print $2}' | sed -n '1p') + DNF_INSTALL "java-${java_version}-openjdk java-${java_version}-openjdk-devel testng beust-jcommander ant" + else + DNF_INSTALL "testng beust-jcommander ant" + fi + testng_jar=$(rpm -ql testng | grep testng.jar) + jcommander_jar=$(rpm -ql beust-jcommander | grep beust-jcommander.jar) + cp "${testng_jar}" "${antlib_path}" + cp "${jcommander_jar}" "${antlib_path}" + + LOG_INFO "End to prepare the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + + ant -f "${ant_path}/build.xml" | grep "run: 2, Failures: 0, Skips: 0" + CHECK_RESULT $? 0 0 "testng execution use case failed." + + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + + rm -rf /tmp/test + DNF_REMOVE + + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/package-test/testNG/oe_test_testNG_with_maven/oe_test_testNG_with_maven.sh b/testcases/package-test/testNG/oe_test_testNG_with_maven/oe_test_testNG_with_maven.sh new file mode 100644 index 0000000000000000000000000000000000000000..84c1af36d718005df36718e365b58f48bf68e5bd --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_with_maven/oe_test_testNG_with_maven.sh @@ -0,0 +1,72 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/4/29 +#@Desc : testNG integration maven +#################################### + +source ${OET_PATH}/libs/locallibs/common_lib.sh + +function config_params() { + LOG_INFO "Start to config params of the case." + + mvn_path="/tmp/test/mvn" + mkdir -p "${mvn_path}" + mvnsrc_path="${mvn_path}/src/main/java" + mkdir -p "${mvnsrc_path}" + cp ../common/TExpBase.java "${mvnsrc_path}" + cp ../common/TExpBase.xml "${mvn_path}" + cp pom.xml "${mvn_path}" + mvnlib_path=${mvn_path}/libs + mkdir -p "${mvnlib_path}" + + LOG_INFO "End to config params of the case." +} + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + + if ! java -version; then + java_version=$(dnf list | grep "java-1.8.*-openjdk" | awk -F '-' '{print $2}' | sed -n '1p') + DNF_INSTALL "java-${java_version}-openjdk java-${java_version}-openjdk-devel testng beust-jcommander maven" + else + DNF_INSTALL "testng beust-jcommander maven" + fi + testng_jar=$(rpm -ql testng | grep testng.jar) + jcommander_jar=$(rpm -ql beust-jcommander | grep beust-jcommander.jar) + cp "${testng_jar}" "${mvnlib_path}" + cp "${jcommander_jar}" "${mvnlib_path}" + + LOG_INFO "End to prepare the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + + mvn -f "${mvn_path}/pom.xml" test | grep "run: 2, Failures: 0, Errors: 0, Skipped: 0" + CHECK_RESULT $? 0 0 "testng execution use case failed." + + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + + rm -rf /tmp/test + DNF_REMOVE + + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/package-test/testNG/oe_test_testNG_with_maven/pom.xml b/testcases/package-test/testNG/oe_test_testNG_with_maven/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..b9b43794259736b6bdfad67c2dfb385496711d53 --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_with_maven/pom.xml @@ -0,0 +1,48 @@ + + 4.0.0 + com.hoperun.mvn + mvn + 1.0 + jar + + + + org.jcommander + jcommander + 1.71 + system + ${basedir}/libs/beust-jcommander.jar + + + org.testng + testng + 6.14 + system + ${basedir}/libs/testng.jar + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.5 + + 1.8 + 1.8 + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.20 + + UTF-8 + + TExpBase.xml + + + + + + \ No newline at end of file diff --git a/testcases/package-test/testNG/oe_test_testNG_with_spring/TExpSpring.xml b/testcases/package-test/testNG/oe_test_testNG_with_spring/TExpSpring.xml new file mode 100644 index 0000000000000000000000000000000000000000..10acf0deb46185108a91d8098092f3a89a3dbdbd --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_with_spring/TExpSpring.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/testcases/package-test/testNG/oe_test_testNG_with_spring/User.java b/testcases/package-test/testNG/oe_test_testNG_with_spring/User.java new file mode 100644 index 0000000000000000000000000000000000000000..0716717146ae3480672ae302ae158c25e46807ac --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_with_spring/User.java @@ -0,0 +1,15 @@ +public class User { + private String name; + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public void printName() { + System.out.println("name is:" + name); + } +} \ No newline at end of file diff --git a/testcases/package-test/testNG/oe_test_testNG_with_spring/UserTest1.java b/testcases/package-test/testNG/oe_test_testNG_with_spring/UserTest1.java new file mode 100644 index 0000000000000000000000000000000000000000..5810b8d3fe6b1130fc6380610ae3f87faeeaa78b --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_with_spring/UserTest1.java @@ -0,0 +1,15 @@ +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; +import org.testng.annotations.Test; + +@ContextConfiguration(locations = { "classpath:applicationContext.xml" }) +public class UserTest1 extends AbstractTestNGSpringContextTests { + @Autowired + private User user; + + @Test + public void oString() { + user.printName(); + } +} \ No newline at end of file diff --git a/testcases/package-test/testNG/oe_test_testNG_with_spring/oe_test_testNG_with_spring.sh b/testcases/package-test/testNG/oe_test_testNG_with_spring/oe_test_testNG_with_spring.sh new file mode 100644 index 0000000000000000000000000000000000000000..ad560efb072b48fc9dd80e420679c8b22498de86 --- /dev/null +++ b/testcases/package-test/testNG/oe_test_testNG_with_spring/oe_test_testNG_with_spring.sh @@ -0,0 +1,58 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. 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 : wangjingfeng +#@Contact : 1136232498@qq.com +#@Date : 2020/4/29 +#@Desc : testNG integration spring +#################################### + +source ../common/common_lib.sh + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + + pre_env + DNF_INSTALL "springframework springframework-beans springframework-context springframework-expression springframework-test apache-commons-logging" + springcore_jar=$(rpm -ql springframework | grep spring-core.jar) + springbeans_jar=$(rpm -ql springframework-beans | grep spring-beans.jar) + springcontext_jar=$(rpm -ql springframework-context | grep spring-context.jar) + springexpression_jar=$(rpm -ql springframework-expression | grep spring-expression.jar) + springtest_jar=$(rpm -ql springframework-test | grep spring-test.jar) + commonslogging_jar=$(rpm -ql apache-commons-logging | grep commons-logging.jar) + export CLASSPATH=${CLASSPATH}:${springcore_jar}:${springbeans_jar}:${springcontext_jar}:${springexpression_jar}:${springtest_jar}:${commonslogging_jar} + + LOG_INFO "End to prepare the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + + javac User.java + CHECK_RESULT $? 0 0 "User.java source code compilation failed." + javac UserTest1.java + CHECK_RESULT $? 0 0 "UserTest1.java source code compilation failed." + java -cp "${CLASSPATH}" org.testng.TestNG TExpSpring.xml | grep "run: 1, Failures: 0, Skips: 0" + CHECK_RESULT $? 0 0 "testng execution use case failed." + + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + + clean_env + + LOG_INFO "End to restore the test environment." +} + +main "$@"