diff --git a/test/testcases/kmesh.json b/test/testcases/kmesh.json index 2dda4b09558028e79298bcd86689bcc844dd2fb8..1fa926a92604d68e74b42f4981e4c17b71af9b55 100644 --- a/test/testcases/kmesh.json +++ b/test/testcases/kmesh.json @@ -6,6 +6,9 @@ }, { "name": "oe_test_lb_policy_function" + }, + { + "name": "oe_test_dark_launch_function" } ] } diff --git a/test/testcases/kmesh/oe_test_dark_launch_function/conf/test_conf.json b/test/testcases/kmesh/oe_test_dark_launch_function/conf/test_conf.json new file mode 100644 index 0000000000000000000000000000000000000000..97c7f134c89061ae832c2c326ef255882b50c8d0 --- /dev/null +++ b/test/testcases/kmesh/oe_test_dark_launch_function/conf/test_conf.json @@ -0,0 +1,122 @@ +{ + "staticResources":{ + "versionInfo":"v2", + "listenerConfigs":[ + { + "apiStatus":"UPDATE", + "name":"127.0.0.1_9081", + "address":{ + "port":31011, + "ipv4":16777343 + }, + "filterChains":[ + { + "filterChainMatch":{ + "transportProtocol":"raw_buffer", + "applicationProtocols":[ + "http/1.0", + "http/1.1", + "h2c" + ] + }, + "filters":[ + { + "name":"envoy.filters.network.http_connection_manager", + "httpConnectionManager":{ + "routeConfigName":"9080" + } + } + ] + } + ] + } + ], + "routeConfigs":[ + { + "apiStatus":"UPDATE", + "name":"9080", + "virtualHosts":[ + { + "name":"details.default.svc.cluster.local:9080", + "domains":[ + "*" + ], + "routes":[ + { + "name":"default", + "match":{ + "prefix":"/" + }, + "route": { + "weighted_clusters": { + "clusters": [ + { + "name": "outbound|9080|v1|details.default.svc.cluster.local", + "weight": 80 + }, + { + "name": "outbound|9080|v2|details.default.svc.cluster.local", + "weight": 20 + } + ] + }, + "retryPolicy": { + "numRetries": 2 + } + } + } + ] + } + ] + } + ], + "clusterConfigs":[ + { + "apiStatus":"UPDATE", + "name":"outbound|9080|v1|details.default.svc.cluster.local", + "connectTimeout":10, + "lb_policy":"ROUND_ROBIN", + "loadAssignment":{ + "clusterName":"outbound|9080|v1|details.default.svc.cluster.local", + "endpoints":[ + { + "lbEndpoints":[ + { + "address":{ + "port":32035, + "ipv4":16777343 + } + } + ], + "loadBalancingWeight":1 + } + ] + } + }, + { + "apiStatus":"UPDATE", + "name":"outbound|9080|v2|details.default.svc.cluster.local", + "connectTimeout":10, + "lb_policy":"ROUND_ROBIN", + "loadAssignment":{ + "clusterName":"outbound|9080|v2|details.default.svc.cluster.local", + "endpoints":[ + { + "lbEndpoints":[ + { + "address":{ + "port":32291, + "ipv4":16777343 + } + } + ], + "loadBalancingWeight":1 + } + ] + } + } + ] + } + } + + diff --git a/test/testcases/kmesh/oe_test_dark_launch_function/oe_test_dark_launch_function.sh b/test/testcases/kmesh/oe_test_dark_launch_function/oe_test_dark_launch_function.sh new file mode 100644 index 0000000000000000000000000000000000000000..b227a8b88d45712ae3aaa83d7d65a32e7e25f1d8 --- /dev/null +++ b/test/testcases/kmesh/oe_test_dark_launch_function/oe_test_dark_launch_function.sh @@ -0,0 +1,62 @@ +#!/usr/bin/bash + +source ${OET_PATH}/libs/locallibs/common_lib.sh +source ../libs/common.sh + +CURRENT_PATH=$(pwd) + +function pre_test() { + LOG_INFO "Start environmental preparation." + + env_init + + LOG_INFO "End of environmental preparation!" +} + +function run_test() { + LOG_INFO "Start testing..." + + # exits the shell when $? is not 0 + set -e + + # start fortio server 9085 + # start fortio server 9086 + start_fortio_server -http-port 127.0.0.1:9085 -echo-server-default-params="header=server:1" + start_fortio_server -http-port 127.0.0.1:9086 -echo-server-default-params="header=server:2" + + # start kmesh-daemon + start_kmesh + + # use kmesh-cmd load conf and check conf load ok + load_kmesh_config + + # curl 100 times, Server: 1 and Server: 2 should be 8:2 + curl -v http://127.0.0.1:9081 > tmp_trace.log 2>&1 + for ((i=0;i<99;i++)) + do + curl -v http://127.0.0.1:9081 >> tmp_trace.log 2>&1 + done + a=`grep -c 'Server: 1' tmp_trace.log` + b=`grep -c 'Server: 2' tmp_trace.log` + if [ $a -gt 70 ]&&[ $a -lt 90 ]&&[ $b -lt 30 ]&&[ $b -gt 10 ];then + result=0 + else + result=1 + fi + + CHECK_RESULT $result 0 0 "bad dark launch" + + LOG_INFO "Finish test!" +} + +function post_test() { + LOG_INFO "start environment cleanup." + + cleanup + + LOG_INFO "Finish environment cleanup!" +} + +main "$@" + +