diff --git a/libs/locallibs/__pycache__/mugen_log.cpython-37.pyc b/libs/locallibs/__pycache__/mugen_log.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..11f9cef3801d0291b392a88998020e2216af601c Binary files /dev/null and b/libs/locallibs/__pycache__/mugen_log.cpython-37.pyc differ diff --git a/libs/locallibs/__pycache__/ssh_cmd.cpython-37.pyc b/libs/locallibs/__pycache__/ssh_cmd.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..09eff7fa07d72c4e614f3a4f11a246f972ec820f Binary files /dev/null and b/libs/locallibs/__pycache__/ssh_cmd.cpython-37.pyc differ diff --git a/results/trafficserver/succeed/oe_test_trafficserver_tsxs b/results/trafficserver/succeed/oe_test_trafficserver_tsxs new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/suite2cases/trafficserver.json b/suite2cases/trafficserver.json index 4d63d5a3de3574bf08a8156dc11c8b61124f69b5..115bf49f42520fe38f3b4fdd1f4b7b7ee5817d93 100644 --- a/suite2cases/trafficserver.json +++ b/suite2cases/trafficserver.json @@ -2,7 +2,34 @@ "path": "$OET_PATH/testcases/cli-test/trafficserver", "cases": [ { - "name": "oe_test_service_trafficserver" + "name": "oe_test_trafficserver_traffic_layout" + }, + { + "name": "oe_test_trafficserver_traffic_cache_tool" + }, + { + "name": "oe_test_trafficserver_traffic_ctl" + }, + { + "name": "oe_test_trafficserver_traffic_logstats" + }, + { + "name": "oe_test_trafficserver_traffic_manager" + }, + { + "name": "oe_test_trafficserver_traffic_server" + }, + { + "name": "oe_test_trafficserver_traffic_top" + }, + { + "name": "oe_test_trafficserver_traffic_via" + }, + { + "name": "oe_test_trafficserver_tspush" + }, + { + "name": "oe_test_trafficserver_tsxs" } ] -} +} \ No newline at end of file diff --git a/testcases/cli-test/trafficserver/oe_test_trafficserver_traffic_cache_tool.sh b/testcases/cli-test/trafficserver/oe_test_trafficserver_traffic_cache_tool.sh new file mode 100644 index 0000000000000000000000000000000000000000..5f931069d99c7336b2c58c07fb58de4884ce1312 --- /dev/null +++ b/testcases/cli-test/trafficserver/oe_test_trafficserver_traffic_cache_tool.sh @@ -0,0 +1,83 @@ +#!/usr/bin/bash +# Copyright (c) 2022. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more detaitest -f. + +# ############################################# +# @Author : wangsongsong +# @Contact : ss_wang@foxmail.com +# @Date : 2022/03/25 +# @License : Mulan PSL v2 +# @Desc : Test traffic_ctl +# ############################################# +source ${OET_PATH}/libs/locallibs/common_lib.sh +function pre_test() { + LOG_INFO "Start to prepare the test environment." + DNF_INSTALL "trafficserver" + pkill traffic_m + pkill [TS_MAIN] + pkill traffic_s + rm -rf /usr/local/var/trafficserver/*.lock + mkdir -p /usr/local/etc/trafficserver/ + touch /usr/local/etc/trafficserver/storage.config + touch /usr/local/etc/trafficserver/volume.config + LOG_INFO "End to prepare the test environment." +} +function run_test() { + LOG_INFO "Start to run test." + #Print usage information + traffic_cache_tool -h |grep "Usage: traffic_cache_tool" + CHECK_RESULT $? 0 0 "failed to print usage infomation" + #Allocate unused storage space + traffic_cache_tool --spans=/usr/local/etc/trafficserver/storage.config --volumes=/usr/local/etc/trafficserver/volume.config alloc free + CHECK_RESULT $? 0 0 "failed to allocate unused storage space" + #clear an specific span + traffic_cache_tool --spans=/usr/local/etc/trafficserver/storage.config --volumes=/usr/local/etc/trafficserver/volume.config clear span + CHECK_RESULT $? 0 0 "failed to clear an specific span" + #clear specific span + traffic_cache_tool --spans=/usr/local/etc/trafficserver/storage.config --volumes=/usr/local/etc/trafficserver/volume.config clearspan span + CHECK_RESULT $? 0 0 "failed to clear specific span" + #walk bucket chains for loops + traffic_cache_tool --spans=/usr/local/etc/trafficserver/storage.config --volumes=/usr/local/etc/trafficserver/volume.config dir_check bucket_chain + CHECK_RESULT $? 0 0 "failed to walk bucket chains for loops" + #check the freelist for loop + traffic_cache_tool --spans=/usr/local/etc/trafficserver/storage.config --volumes=/usr/local/etc/trafficserver/volume.config dir_check freelist + CHECK_RESULT $? 0 0 "failed to check the freelist for loop" + #Full report of the cache storage + traffic_cache_tool --spans=/usr/local/etc/trafficserver/storage.config --volumes=/usr/local/etc/trafficserver/volume.config dir_check full |grep "succeeded" + CHECK_RESULT $? 0 0 "failed to check the freelist for loop" + #List the stripes + traffic_cache_tool --spans=/usr/local/etc/trafficserver/storage.config --volumes=/usr/local/etc/trafficserver/volume.config list stripes + CHECK_RESULT $? 0 0 "failed to list the stripes" + #Scans the whole cache and lists the urls of the cached contents + traffic_cache_tool --spans=/usr/local/etc/trafficserver/storage.config --volumes=/usr/local/etc/trafficserver/volume.config scan + CHECK_RESULT $? 0 0 "failed to scan the whole cache" + #Clear all spans + traffic_cache_tool --spans=/usr/local/etc/trafficserver/storage.config --volumes=/usr/local/etc/trafficserver/volume.config --write clear |grep "Writing" + CHECK_RESULT $? 0 0 "failed to clear all spans" + #Clear a single span + traffic_cache_tool --spans=/usr/local/etc/trafficserver/storage.config --volumes=/usr/local/etc/trafficserver/volume.config clear span --device "/dev/" --write |grep "Writing" + CHECK_RESULT $? 0 0 "failed to clear a single span" + #Initialize a new span + traffic_cache_tool --spans=/usr/local/etc/trafficserver/storage.config --volumes=/usr/local/etc/trafficserver/volume.config init --input "/dev/sda3" --write |grep "Writing" + CHECK_RESULT $? 0 0 "failed to initialize a new span" + #Find Stripe Assignment + traffic_cache_tool --spans=/usr/local/etc/trafficserver/storage.config --volumes=/usr/local/etc/trafficserver/volume.config init --write --input "urls.txt" |grep "Writing" + CHECK_RESULT $? 0 0 "failed to find stripe assignment" + LOG_INFO "End to run test." +} +function post_test() { + LOG_INFO "Start to restore the test environment." + DNF_REMOVE + pkill traffic_m + test -f /usr/local/var/trafficserver/server.lock && rm -rf /usr/local/var/trafficserver/server.lock + test -f /usr/local/var/trafficserver/manager.lock && rm -rf /usr/local/var/trafficserver/manager.lock + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/cli-test/trafficserver/oe_test_trafficserver_traffic_ctl.sh b/testcases/cli-test/trafficserver/oe_test_trafficserver_traffic_ctl.sh new file mode 100644 index 0000000000000000000000000000000000000000..3d5cd24e12491722e3b55eea34e9a364404cc29b --- /dev/null +++ b/testcases/cli-test/trafficserver/oe_test_trafficserver_traffic_ctl.sh @@ -0,0 +1,128 @@ +#!/usr/bin/bash +# Copyright (c) 2022. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more detaitest -f. + +# ############################################# +# @Author : wangsongsong +# @Contact : ss_wang@foxmail.com +# @Date : 2022/03/05 +# @License : Mulan PSL v2 +# @Desc : Test traffic_ctl +# ############################################# +source ${OET_PATH}/libs/locallibs/common_lib.sh + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + DNF_INSTALL "trafficserver" + LOG_INFO "To use traffic_ctl, traffic_manager needs to be running" + pkill traffic_m + pkill [TS_MAIN] + pkill traffic_s + rm -rf /usr/local/var/trafficserver/server.lock + rm -rf /usr/local/var/trafficserver/manager.lock + nohup traffic_manager -B text >/tmp/manager.log 2>&1 & + LOG_INFO "End to prepare the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + #Print usage information + traffic_ctl -h |grep "Commands" + CHECK_RESULT $? 0 0 "failed to print usage infomation" + #Print version string + traffic_ctl -V |grep "traffic_ctl" + CHECK_RESULT $? 0 0 "failed to print version string" + #Clear all current alarms + traffic_ctl alarm clear + CHECK_RESULT $? 0 0 "failed to clear current alarms" + #List all current alarms + traffic_ctl alarm list + CHECK_RESULT $? 0 0 "failed to list current alarms" + #Resolve alarms(number 1) + traffic_ctl alarm resolve 1 + CHECK_RESULT $? 0 0 "failed to resolve the alarms" + #Show default information configuration values + traffic_ctl config defaults |grep "exec_thread.autoconfig" + CHECK_RESULT $? 0 0 "failed to show default information configuration values" + #Show detailed information about configuration values + traffic_ctl config describe proxy.config.exec_thread.autoconfig |grep "Name" + CHECK_RESULT $? 0 0 "failed to show detailed information about proxy.config.exec_thread.autoconfig" + #Get one or more configuration values + traffic_ctl config get proxy.config.http.insert_response_via_str |grep "proxy.config.http.insert_response_via_str" + CHECK_RESULT $? 0 0 "failed to get proxy.config.http.insert_response_via_str configuration value" + #Get configuration matching a regular expression + traffic_ctl config match proxy.config.http.insert_response_via_str|grep "proxy.config" + CHECK_RESULT $? 0 0 "failed to get configuration matching a regular expression" + #Request a configuration reload + traffic_ctl config reload + CHECK_RESULT $? 0 0 "failed to request a configuration reload" + #Configure Traffic Server to insert header in the response to the client:Via + traffic_ctl config set proxy.config.http.insert_response_via_str 1 |grep "set" + CHECK_RESULT $? 0 0 "failed to configure Traffic Server to insert header in the response to the client" + #Check the configuration status + traffic_ctl config status |grep "Apache Traffic Server" + CHECK_RESULT $? 0 0 "failed to check the configuration status" + #Set down HOST + traffic_ctl host down HOST --reason active + CHECK_RESULT $? 0 0 "failed to set down HOST" + #Get one or more host statuses + traffic_ctl host status HOST |grep "proxy.process.host_status" + CHECK_RESULT $? 0 0 "failed to get host statuses" + #Set up HOST + traffic_ctl host up HOST --reason active + CHECK_RESULT $? 0 0 "failed to set up HOST " + + #Clear all metric values + traffic_ctl metric clear + CHECK_RESULT $? 0 0 "failed to clear metric values" + #Get metrics matching a regular expression + traffic_ctl metric match + CHECK_RESULT $? 0 0 "failed to get metrics matching a regular expression" + #Clear one metric values + traffic_ctl metric zero 1 + CHECK_RESULT $? 0 0 "failed to clear one metric values" + #Send message to plugins + traffic_ctl plugin msg 1 + CHECK_RESULT $? 0 0 "failed to send message to plugins " + #Show a full stack trace of the traffic_server process + traffic_ctl server backtrace |grep "Thread " + CHECK_RESULT $? 0 0 "failed to show a full stack trace of the traffic_server process" + #Drain the requests + traffic_ctl server drain + CHECK_RESULT $? 0 0 "failed to drain the requests" + #Restart Traffic Server + traffic_ctl server restart + CHECK_RESULT $? 0 0 "failed to restart Traffic Server" + #Stop the proxy + traffic_ctl server stop + CHECK_RESULT $? 0 0 "failed to stop the proxy" + #Start the proxy + traffic_ctl server start + CHECK_RESULT $? 0 0 "failed to start the proxy" + #Show the proxy status + traffic_ctl server status | grep "Proxy" + CHECK_RESULT $? 0 0 "failed to show the proxy status" + traffic_ctl server stop + #Take one storage volumes offline + traffic_ctl storage offline 1 + CHECK_RESULT $? 0 0 "failed to offline" + LOG_INFO "End to run test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + pkill traffic_m + rm -rf /usr/local/var/trafficserver/server.lock + rm -rf /usr/local/var/trafficserver/manager.lock + rm -rf /tmp/manager.log + DNF_REMOVE + LOG_INFO "End to restore the test environment." +} + +main "$@" diff --git a/testcases/cli-test/trafficserver/oe_test_trafficserver_traffic_layout.sh b/testcases/cli-test/trafficserver/oe_test_trafficserver_traffic_layout.sh new file mode 100644 index 0000000000000000000000000000000000000000..f6a737c0ccb19e855cd45c263b8be707722998ce --- /dev/null +++ b/testcases/cli-test/trafficserver/oe_test_trafficserver_traffic_layout.sh @@ -0,0 +1,61 @@ +#!/usr/bin/bash +# Copyright (c) 2022. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more detaitest -f. + +# ############################################# +# @Author : Yihao Lin;Songsong Wang +# @Contact : 1165507637@qq.com +# @Date : 2022/03/05 +# @License : Mulan PSL v2 +# @Desc : Test traffic_layout +# ############################################# + +source "../common/common_lib.sh" + +function pre_test() { + LOG_INFO "Start environmental preparation." + DNF_INSTALL "trafficserver" + pkill [TS_MAIN] + pkill traffic_m + mkdir -p myats + rm -rf /usr/local/var/trafficserver/server.lock + rm -rf /usr/local/var/trafficserver/manager.lock + LOG_INFO "End of environmental preparation!" +} + +function run_test() { + LOG_INFO "Start testing..." + #Display Traffic Server's Layout + traffic_layout | grep "PREFIX" + CHECK_RESULT $? 0 0 "failed to display trafficserver's layout" + #Create a Apache Traffic Server Runboot + traffic_layout init --path myats |grep "runroot" + CHECK_RESULT $? 0 0 "failed to create a apache traffic server runboot" + + #Veriry the runboot + traffic_layout verify | grep "PASSED" + CHECK_RESULT $? 0 0 "failed to veriry the runboot" + + #Remove the runboot + traffic_layout remove --path myats + CHECK_RESULT $? 0 0 "failed to remove the runboot" + LOG_INFO "Finish test!" +} + +function post_test() { + LOG_INFO "start environment cleanup." + pkill [TS_MAIN] + pkill traffic_m + test -f /usr/local/var/trafficserver/server.lock && rm -rf /usr/local/var/trafficserver/server.lock + test -f /usr/local/var/trafficserver/manager.lock && rm -rf /usr/local/var/trafficserver/manager.lock + test -f myats && rm -rf myats + DNF_REMOVE + LOG_INFO "Finish environment cleanup!" +} +main "$@" diff --git a/testcases/cli-test/trafficserver/oe_test_trafficserver_traffic_logstats.sh b/testcases/cli-test/trafficserver/oe_test_trafficserver_traffic_logstats.sh new file mode 100644 index 0000000000000000000000000000000000000000..099f11a51aa75f3a025c5ffbadf962bf43f39168 --- /dev/null +++ b/testcases/cli-test/trafficserver/oe_test_trafficserver_traffic_logstats.sh @@ -0,0 +1,69 @@ +#!/usr/bin/bash +# Copyright (c) 2022. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more detaitest -f. +# ############################################# +# @Author : wangsongsong +# @Contact : ss_wang@foxmail.com +# @Date : 2022/03/05 +# @License : Mulan PSL v2 +# @Desc : Test trafficserver.service restart +# ############################################# +source "../common/common_lib.sh" +function pre_test() { + LOG_INFO "Start environmental preparation." + DNF_INSTALL "trafficserver" + pkill [TS_MAIN] + pkill traffic_m + test -f /usr/local/var/trafficserver/server.lock && rm -rf /usr/local/var/trafficserver/server.lock + test -f /usr/local/var/trafficserver/manager.lock && rm -rf /usr/local/var/trafficserver/manager.lock + LOG_INFO "End of environmental preparation!" +} +function run_test() { + LOG_INFO "Start testing..." + #Produce JSON formatted output + traffic_logstats -j|grep "total" + CHECK_RESULT $? 0 0 "failed to produce json formatted output" + #Only produce the summary + traffic_logstats -s |grep "Cache" + CHECK_RESULT $? 0 0 "failed to produce the summary" + #Print version string + traffic_logstats -V |grep "Apache" + CHECK_RESULT $? 0 0 "failed to print version string" + #Produce URL stats as a JSON object instead of array + traffic_logstats -A |grep "Cache" + CHECK_RESULT $? 0 0 "failed to produce url stats as a json object instead of array" + #Incremental log parsing + traffic_logstats -i |grep "HTTP" + CHECK_RESULT $? 0 0 "failed to incremental log parsing" + #Eliminate metrics that can be inferred from other values + traffic_logstats -C |grep "Cache" + CHECK_RESULT $? 0 0 "failed to eliminate metrics that can be inferred from other values" + #Produce HTTP headers suitable as a CGI + traffic_logstats -c |grep "content" + CHECK_RESULT $? 0 0 "failed to produce HTTP headers suitable as a CGI" + #Report stats per user instead of host + traffic_logstats -r |grep "IPv6" + CHECK_RESULT $? 0 0 "failed to report stats per user instead of host" + #Don't validate the log format field names + traffic_logstats -n |grep "Origin" + CHECK_RESULT $? 0 0 "validate the log farmat field names" + + LOG_INFO "Finish test!" +} + +function post_test() { + LOG_INFO "start environment cleanup." + pkill [TS_MAIN] + pkill traffic_m + test -f /usr/local/var/trafficserver/server.lock && rm -rf /usr/local/var/trafficserver/server.lock + test -f /usr/local/var/trafficserver/manager.lock && rm -rf /usr/local/var/trafficserver/manager.lock + DNF_REMOVE + LOG_INFO "Finish environment cleanup!" +} +main "$@" diff --git a/testcases/cli-test/trafficserver/oe_test_trafficserver_traffic_manager.sh b/testcases/cli-test/trafficserver/oe_test_trafficserver_traffic_manager.sh new file mode 100644 index 0000000000000000000000000000000000000000..b27c8f8ef57d854296d2659d268db14680b77978 --- /dev/null +++ b/testcases/cli-test/trafficserver/oe_test_trafficserver_traffic_manager.sh @@ -0,0 +1,59 @@ +#!/usr/bin/bash +# Copyright (c) 2022. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more detaitest -f. + +# ############################################# +# @Author : Songsong Wang +# @Contact : sswang@hit.edu.cn +# @Date : 2022/03/05 +# @License : Mulan PSL v2 +# @Desc : Test traffic_manager +# ############################################# +source "../common/common_lib.sh" +function pre_test() { + LOG_INFO "Start environmental preparation." + DNF_INSTALL "trafficserver" + test -f /usr/local/var/trafficserver/server.lock && rm -rf /usr/local/var/trafficserver/server.lock + test -f /usr/local/var/trafficserver/manager.lock && rm -rf /usr/local/var/trafficserver/manager.lock + pkill [TS_MAIN] + pkill traffic_m + LOG_INFO "End of environmental preparation!" +} +function run_test() { + LOG_INFO "Start testing..." + #Show Traffic Server Version + traffic_manager --version | grep "Apache Traffic Server" + CHECK_RESULT $? 0 0 "failed to show traffic server version" + #Set max number of librecords metrics and configurations + nohup traffic_manager -m 2500 >/tmp/metrics.log 2>&1& + SLEEP_WAIT 15 + CHECK_RESULT $? 0 0 "failed to set max number of librecords metrics and configurations" + #Vertical-bar-separated Debug Tags + nohup traffic_manager -T text >/tmp/debug.log 2>&1& + SLEEP_WAIT 15 + grep "Traffic" /tmp/debug.log + CHECK_RESULT $? 0 0 "failed to vertical-bar-separated debug tags" + #Vertical-bar-separated Behavior Tags + nohup traffic_manager -B text >/tmp/behavior.log 2>&1& + SLEEP_WAIT 15 + grep "Traffic" /tmp/behavior.log + CHECK_RESULT $? 0 0 "failed to vertical-bar-separated debug tags" + LOG_INFO "Finish test!" +} +function post_test() { + LOG_INFO "start environment cleanup." + rm -rf /tmp/* + test -f /usr/local/var/trafficserver/server.lock && rm -rf /usr/local/var/trafficserver/server.lock + test -f /usr/local/var/trafficserver/manager.lock && rm -rf /usr/local/var/trafficserver/manager.lock + pkill [TS_MAIN] + pkill traffic_m + DNF_REMOVE + LOG_INFO "Finish environment cleanup!" +} +main "$@" \ No newline at end of file diff --git a/testcases/cli-test/trafficserver/oe_test_trafficserver_traffic_server.sh b/testcases/cli-test/trafficserver/oe_test_trafficserver_traffic_server.sh new file mode 100644 index 0000000000000000000000000000000000000000..a8a2d945ca8bc400d49ee2c5d84b49296771505d --- /dev/null +++ b/testcases/cli-test/trafficserver/oe_test_trafficserver_traffic_server.sh @@ -0,0 +1,81 @@ +#!/usr/bin/bash +# Copyright (c) 2022. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more detaitest -f. + +# ############################################# +# @Author : wangsongsong +# @Contact : ss_wang@foxmail.com +# @Date : 2022/03/05 +# @License : Mulan PSL v2 +# @Desc : Test traffic_server +# ############################################# +source "../common/common_lib.sh" +function pre_test() { + LOG_INFO "Start environmental preparation." + DNF_INSTALL "trafficserver" + pkill [TS_MAIN] + pkill traffic_m + test -f /usr/local/var/trafficserver/server.lock && rm -rf /usr/local/var/trafficserver/server.lock + test -f /usr/local/var/trafficserver/manager.lock && rm -rf /usr/local/var/trafficserver/manager.lock + LOG_INFO "End of environmental preparation!" +} +function run_test() { + LOG_INFO "Start testing..." + #run the regression test suite + traffic_server -R 1 + CHECK_RESULT $? 0 0 "failed to regression" + #Print version string + traffic_server -V |grep "Apache Traffic Server" + CHECK_RESULT $? 0 0 "failed to print version string" + #List Regression Tests + traffic_server -l |grep SDK_API + CHECK_RESULT $? 0 0 "failed to list regression tests" + #Port descriptor for HTTP Accept + nohup traffic_server -p www.gitee.com > /tmp/HTTP.log 2>&1& + SLEEP_WAIT 15 + grep "traffic_server" /tmp/HTTP.log + CHECK_RESULT $? 0 0 "failed to port descriptor for HTTP Accept" + #Set Number of UDP Threads + nohup traffic_server -U 1 > /tmp/UDP.log 2>&1& + SLEEP_WAIT 15 + grep "traffic_server" /tmp/UDP.log + CHECK_RESULT $? 0 0 "failed to set number of UDP" + #Run Specific Regression Test + nohup traffic_server -r list >/tmp/Specific.log 2>&1& + SLEEP_WAIT 15 + CHECK_RESULT $? 0 0 "failed to run specific regression test" + #Clear Cache on Startup + nohup traffic_server -K >/tmp/Cache.log 2>&1& + SLEEP_WAIT 15 + CHECK_RESULT $? 0 0 "failed to clear cache on startup" + #Clear HostDB on Startup + nohup traffic_server -k >/tmp/HostDB.log 2>&1& + SLEEP_WAIT 15 + grep "traffic_server" /tmp/HostDB.log + CHECK_RESULT $? 0 0 "failed to clear HostDB" + #Maintenance Command to Execute + traffic_server -C check|grep CHECK + CHECK_RESULT $? 0 0 "failed to maintenance command to execute" + #Max number of librecords metrics and configurations + nohup traffic_server -m 2500 >/tmp/metrics.log 2>&1& + SLEEP_WAIT 15 + CHECK_RESULT $? 0 0 "failed to set max number of librecords metrics and configurations" + LOG_INFO "Finish test!" +} +function post_test() { + LOG_INFO "start environment cleanup." + pkill [TS_MAIN] + pkill traffic_m + test -f /usr/local/var/trafficserver/server.lock && rm -rf /usr/local/var/trafficserver/server.lock + test -f /usr/local/var/trafficserver/manager.lock && rm -rf /usr/local/var/trafficserver/manager.lock + rm -rf /tmp/* + DNF_REMOVE + LOG_INFO "Finish environment cleanup!" +} +main "$@" \ No newline at end of file diff --git a/testcases/cli-test/trafficserver/oe_test_trafficserver_traffic_top.sh b/testcases/cli-test/trafficserver/oe_test_trafficserver_traffic_top.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8727cd8c21aefad5a4c22f15cb182e09e18db44 --- /dev/null +++ b/testcases/cli-test/trafficserver/oe_test_trafficserver_traffic_top.sh @@ -0,0 +1,57 @@ +#!/usr/bin/bash +# Copyright (c) 2022. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more detaitest -f. + +# ############################################# +# @Author : wangsongsong +# @Contact : ss_wang@foxmail.com +# @Date : 2022/03/05 +# @License : Mulan PSL v2 +# @Desc : Test traffic_top +# ############################################# + +source "../common/common_lib.sh" + +function pre_test() { + LOG_INFO "Start environmental preparation." + DNF_INSTALL "nginx trafficserver" + sed -i "s/listen 80/listen 8080/" /etc/nginx/nginx.conf + sed -i "s/listen \[/\#listen \[/" /etc/nginx/nginx.conf + LOG_INFO "trafficserver has been installed" + echo "map http://localhost:8080/ http://${NODE1_IPV4}:81/" > /etc/trafficserver/remap.config + pkill [TS_MAIN] + pkill traffic_m + rm -rf /usr/local/var/trafficserver/server.lock + rm -rf /usr/local/var/trafficserver/manager.lock + LOG_INFO "End of environmental preparation!" +} + +function run_test() { + LOG_INFO "Start testing..." + traffic_top -V|grep "Apache Traffic Server" + CHECK_RESULT $? 0 0 "failed to show version" + #Display traffic_server infomation + nohup traffic_top www.gitee.com >/tmp/show.log 2>&1 & + SLEEP_WAIT 15 + grep "CACHE" /tmp/show.log + CHECK_RESULT $? 0 0 "failed to display traffic_server infomation" + +} + +function post_test() { + LOG_INFO "start environment cleanup." + pkill [TS_MAIN] + pkill traffic_m + rm -rf /tmp/show.log + rm -rf /usr/local/var/trafficserver/server.lock + rm -rf /usr/local/var/trafficserver/manager.lock + DNF_REMOVE + LOG_INFO "Finish environment cleanup!" +} +main "$@" diff --git a/testcases/cli-test/trafficserver/oe_test_trafficserver_traffic_via.sh b/testcases/cli-test/trafficserver/oe_test_trafficserver_traffic_via.sh new file mode 100644 index 0000000000000000000000000000000000000000..55fbe075c0f95336675dc65f1cce50ecba80e6ec --- /dev/null +++ b/testcases/cli-test/trafficserver/oe_test_trafficserver_traffic_via.sh @@ -0,0 +1,44 @@ +#!/usr/bin/bash +# Copyright (c) 2022. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more detaitest -f. + +# ############################################# +# @Author : Yihao Lin +# @Contact : 1165507637@qq.com +# @Date : 2022/03/05 +# @License : Mulan PSL v2 +# @Desc : Test traffic_via +# ############################################# + +source "../common/common_lib.sh" + +function pre_test() { + LOG_INFO "Start environmental preparation." + DNF_INSTALL "trafficserver" + LOG_INFO "End of environmental preparation!" +} + +function run_test() { + LOG_INFO "Start testing..." + traffic_via --version|grep "traffic_via" + CHECK_RESULT $? 0 0 "failed to show version" + #Decode Traffic Server Via header code + traffic_via "[uScMsEf p eC:t cCMp sF]" | grep "Via Header Details:" + CHECK_RESULT $? 0 0 "failed to decode traffic server via header code" + LOG_INFO "Finish test!" +} + +function post_test() { + LOG_INFO "start environment cleanup." + pkill [TS_MAIN] + pkill traffic_m + DNF_REMOVE + LOG_INFO "Finish environment cleanup!" +} +main "$@" diff --git a/testcases/cli-test/trafficserver/oe_test_service_trafficserver.sh b/testcases/cli-test/trafficserver/oe_test_trafficserver_tspush.sh similarity index 41% rename from testcases/cli-test/trafficserver/oe_test_service_trafficserver.sh rename to testcases/cli-test/trafficserver/oe_test_trafficserver_tspush.sh index e90fb6e9343114ef758cd5cd761c7d10753fa127..06b1c5600c42ee186a1d4bc8c517b97bd2706f5a 100644 --- a/testcases/cli-test/trafficserver/oe_test_service_trafficserver.sh +++ b/testcases/cli-test/trafficserver/oe_test_trafficserver_tspush.sh @@ -1,6 +1,5 @@ #!/usr/bin/bash - -# Copyright (c) 2021. Huawei Technologies Co.,Ltd.ALL rights reserved. +# Copyright (c) 2022. Huawei Technologies Co.,Ltd.ALL rights reserved. # This program is licensed under Mulan PSL v2. # You can use it according to the terms and conditions of the Mulan PSL v2. # http://license.coscl.org.cn/MulanPSL2 @@ -10,55 +9,45 @@ # See the Mulan PSL v2 for more detaitest -f. # ############################################# -# @Author : wenjun -# @Contact : 1009065695@qq.com -# @Date : 2021/11/11 +# @Author : wangsongsong +# @Contact : ss_wang@foxmail.com +# @Date : 2022/03/05 # @License : Mulan PSL v2 -# @Desc : Test trafficserver.service restart +# @Desc : Test tspush # ############################################# source "../common/common_lib.sh" function pre_test() { LOG_INFO "Start environmental preparation." - DNF_INSTALL trafficserver - service=trafficserver.service + DNF_INSTALL "nginx,trafficserver" + sed -i "s/listen 80/listen 8080/" /etc/nginx/nginx.conf + sed -i "s/listen \[/\#listen \[/" /etc/nginx/nginx.conf + LOG_INFO "trafficserver has been installed" + echo "map http://localhost:8080/ http://${NODE1_IPV4}:81/" > /etc/trafficserver/remap.config log_time=$(date '+%Y-%m-%d %T') LOG_INFO "End of environmental preparation!" } function run_test() { LOG_INFO "Start testing..." - systemctl restart "${service}" - CHECK_RESULT $? 0 0 "${service} restart failed" - SLEEP_WAIT 15 - systemctl status "${service}" | grep "Active: active" - CHECK_RESULT $? 0 0 "${service} restart failed" - systemctl stop "${service}" - CHECK_RESULT $? 0 0 "${service} stop failed" - SLEEP_WAIT 15 - systemctl status "${service}" | grep "Active: inactive" - CHECK_RESULT $? 0 0 "${service} stop failed" - systemctl start "${service}" - CHECK_RESULT $? 0 0 "${service} start failed" - SLEEP_WAIT 15 - systemctl status "${service}" | grep "Active: active" - CHECK_RESULT $? 0 0 "${service} start failed" - test_enabled "${service}" - journalctl --since "${log_time}" -u "${service}" | grep -i "fail\|error" | grep -v -i "DEBUG\|INFO\|WARNING" - CHECK_RESULT $? 0 1 "There is an error message for the log of ${service}" - systemctl reload "${service}" - CHECK_RESULT $? 0 0 "${service} reload failed" - systemctl status "${service}" | grep "Active: active" - CHECK_RESULT $? 0 0 "${service} reload causes the service status to change" + #push file and url Print the PUSHed content to stdout + touch /tmp/foo.txt + nginx + tspush -f /tmp/foo.txt -u http://localhost:8080/tmp/foo.txt -v|grep "PUSH" + CHECK_RESULT $? 0 0 "failed to push file and url print the PUSEed content to stdout" + #Print Usage of tspush + tspush -h |grep "OPTIONS" + CHECK_RESULT $? 0 0 "show help information" LOG_INFO "Finish test!" } function post_test() { LOG_INFO "start environment cleanup." - systemctl stop "${service}" + rm -rf /tmp/* + pkill [TS_MAIN] + pkill traffic_m DNF_REMOVE LOG_INFO "Finish environment cleanup!" } - main "$@" diff --git a/testcases/cli-test/trafficserver/oe_test_trafficserver_tsxs.sh b/testcases/cli-test/trafficserver/oe_test_trafficserver_tsxs.sh new file mode 100644 index 0000000000000000000000000000000000000000..b8d2eca3ea8d2040aacb423aa9382dbb9a5ea1a3 --- /dev/null +++ b/testcases/cli-test/trafficserver/oe_test_trafficserver_tsxs.sh @@ -0,0 +1,49 @@ +#!/usr/bin/bash +# Copyright (c) 2022. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more detaitest -f. + +# ############################################# +# @Author : wangsongsong +# @Contact : ss_wang@foxmail.com +# @Date : 2022/03/05 +# @License : Mulan PSL v2 +# @Desc : Test tsxs +# ############################################# +source "../common/common_lib.sh" +function config_params() { + LOG_INFO "Start to config params of the case." + DNF_INSTALL "trafficserver trafficserver-devel" + traffic_server start + LOG_INFO "End to config params of the case." +} +function pre_test() { + LOG_INFO "Start environmental preparation." + cat>1.c< + int main(){ + printf("hello world\n"); + } +END + LOG_INFO "End of environmental preparation!" +} + +function run_test() { + LOG_INFO "Start testing..." + tsxs -I/foo/include -L/foo/lib -o 1.so -i 1.c + CHECK_RESULT $? 0 0 "failed to install a trafficserver plugins" + LOG_INFO "Finish test!" +} + +function post_test() { + LOG_INFO "start environment cleanup." + rm -rf 1.* + DNF_REMOVE + LOG_INFO "Finish environment cleanup!" +} +main "$@"