From b044a655e5949468f62bf9d196f77f0cb8d3abe2 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 15 Apr 2021 11:09:25 +0800 Subject: [PATCH 1/3] add testNG --- suite2cases/testNG | 13 ++++ .../testNG/common/IHookableImp.java | 11 +++ .../testNG/common/TExpAssert.java | 77 +++++++++++++++++++ .../package-test/testNG/common/TExpBase.java | 61 +++++++++++++++ .../package-test/testNG/common/TExpBase.xml | 9 +++ .../testNG/common/TExpGroups.java | 44 +++++++++++ .../testNG/common/TExpListern.java | 10 +++ .../testNG/common/TExpParameters.java | 46 +++++++++++ .../testNG/common/applicationContext.xml | 18 +++++ .../package-test/testNG/common/common_lib.sh | 41 ++++++++++ .../TExpAssert.xml | 9 +++ .../oe_test_testNG_annotations_assert.sh | 48 ++++++++++++ ...oe_test_testNG_annotations_before_after.sh | 48 ++++++++++++ .../oe_test_testNG_annotations_common.sh | 48 ++++++++++++ .../testngCommon.xml | 77 +++++++++++++++++++ .../TExpGroups.xml | 52 +++++++++++++ .../oe_test_testNG_annotations_group.sh | 48 ++++++++++++ .../TExpListern.xml | 12 +++ .../oe_test_testNG_annotations_listen.sh | 50 ++++++++++++ .../TExpParameters.xml | 14 ++++ .../oe_test_testNG_annotations_parameters.sh | 48 ++++++++++++ .../oe_test_testNG_exception/TExpExc.java | 8 ++ .../oe_test_testNG_exception/TExpExc.xml | 9 +++ .../oe_test_testNG_exception.sh | 48 ++++++++++++ .../testNG/oe_test_testNG_retry/Retry.java | 8 ++ .../testNG/oe_test_testNG_retry/Retry.xml | 9 +++ .../oe_test_testNG_retry.sh | 49 ++++++++++++ .../testNG/oe_test_testNG_thread/TExpTh1.java | 25 ++++++ .../testNG/oe_test_testNG_thread/TExpTh1.xml | 9 +++ .../testNG/oe_test_testNG_thread/TExpTh2.java | 25 ++++++ .../testNG/oe_test_testNG_thread/TExpTh2.xml | 9 +++ .../testNG/oe_test_testNG_thread/TExpTh3.java | 25 ++++++ .../testNG/oe_test_testNG_thread/TExpTh3.xml | 9 +++ .../testNG/oe_test_testNG_thread/TExpTh4.java | 25 ++++++ .../testNG/oe_test_testNG_thread/TExpTh4.xml | 9 +++ .../testNG/oe_test_testNG_thread/TExpTh5.java | 25 ++++++ .../testNG/oe_test_testNG_thread/TExpTh5.xml | 9 +++ .../testNG/oe_test_testNG_thread/TExpTh6.java | 25 ++++++ .../testNG/oe_test_testNG_thread/TExpTh6.xml | 9 +++ .../testNG/oe_test_testNG_thread/TExpTh7.java | 25 ++++++ .../testNG/oe_test_testNG_thread/TExpTh7.xml | 9 +++ .../oe_test_testNG_thread.sh | 67 ++++++++++++++++ .../JunitTestNG.java | 15 ++++ .../oe_test_testNG_with_Junit.sh | 52 +++++++++++++ .../testng_junit.xml | 9 +++ .../testNG/oe_test_testNG_with_ant/build.xml | 29 +++++++ .../oe_test_testNG_with_ant.sh | 72 +++++++++++++++++ .../oe_test_testNG_with_maven.sh | 72 +++++++++++++++++ .../testNG/oe_test_testNG_with_maven/pom.xml | 48 ++++++++++++ .../oe_test_testNG_with_spring/TExpSpring.xml | 9 +++ .../oe_test_testNG_with_spring/User.java | 15 ++++ .../oe_test_testNG_with_spring/UserTest1.java | 15 ++++ .../oe_test_testNG_with_spring.sh | 58 ++++++++++++++ 53 files changed, 1614 insertions(+) create mode 100644 suite2cases/testNG create mode 100644 testcases/package-test/testNG/common/IHookableImp.java create mode 100644 testcases/package-test/testNG/common/TExpAssert.java create mode 100644 testcases/package-test/testNG/common/TExpBase.java create mode 100644 testcases/package-test/testNG/common/TExpBase.xml create mode 100644 testcases/package-test/testNG/common/TExpGroups.java create mode 100644 testcases/package-test/testNG/common/TExpListern.java create mode 100644 testcases/package-test/testNG/common/TExpParameters.java create mode 100644 testcases/package-test/testNG/common/applicationContext.xml create mode 100644 testcases/package-test/testNG/common/common_lib.sh create mode 100644 testcases/package-test/testNG/oe_test_testNG_annotations_assert/TExpAssert.xml create mode 100644 testcases/package-test/testNG/oe_test_testNG_annotations_assert/oe_test_testNG_annotations_assert.sh create mode 100644 testcases/package-test/testNG/oe_test_testNG_annotations_before_after/oe_test_testNG_annotations_before_after.sh create mode 100644 testcases/package-test/testNG/oe_test_testNG_annotations_common/oe_test_testNG_annotations_common.sh create mode 100644 testcases/package-test/testNG/oe_test_testNG_annotations_common/testngCommon.xml create mode 100644 testcases/package-test/testNG/oe_test_testNG_annotations_group/TExpGroups.xml create mode 100644 testcases/package-test/testNG/oe_test_testNG_annotations_group/oe_test_testNG_annotations_group.sh create mode 100644 testcases/package-test/testNG/oe_test_testNG_annotations_listen/TExpListern.xml create mode 100644 testcases/package-test/testNG/oe_test_testNG_annotations_listen/oe_test_testNG_annotations_listen.sh create mode 100644 testcases/package-test/testNG/oe_test_testNG_annotations_parameters/TExpParameters.xml create mode 100644 testcases/package-test/testNG/oe_test_testNG_annotations_parameters/oe_test_testNG_annotations_parameters.sh create mode 100644 testcases/package-test/testNG/oe_test_testNG_exception/TExpExc.java create mode 100644 testcases/package-test/testNG/oe_test_testNG_exception/TExpExc.xml create mode 100644 testcases/package-test/testNG/oe_test_testNG_exception/oe_test_testNG_exception.sh create mode 100644 testcases/package-test/testNG/oe_test_testNG_retry/Retry.java create mode 100644 testcases/package-test/testNG/oe_test_testNG_retry/Retry.xml create mode 100644 testcases/package-test/testNG/oe_test_testNG_retry/oe_test_testNG_retry.sh create mode 100644 testcases/package-test/testNG/oe_test_testNG_thread/TExpTh1.java create mode 100644 testcases/package-test/testNG/oe_test_testNG_thread/TExpTh1.xml create mode 100644 testcases/package-test/testNG/oe_test_testNG_thread/TExpTh2.java create mode 100644 testcases/package-test/testNG/oe_test_testNG_thread/TExpTh2.xml create mode 100644 testcases/package-test/testNG/oe_test_testNG_thread/TExpTh3.java create mode 100644 testcases/package-test/testNG/oe_test_testNG_thread/TExpTh3.xml create mode 100644 testcases/package-test/testNG/oe_test_testNG_thread/TExpTh4.java create mode 100644 testcases/package-test/testNG/oe_test_testNG_thread/TExpTh4.xml create mode 100644 testcases/package-test/testNG/oe_test_testNG_thread/TExpTh5.java create mode 100644 testcases/package-test/testNG/oe_test_testNG_thread/TExpTh5.xml create mode 100644 testcases/package-test/testNG/oe_test_testNG_thread/TExpTh6.java create mode 100644 testcases/package-test/testNG/oe_test_testNG_thread/TExpTh6.xml create mode 100644 testcases/package-test/testNG/oe_test_testNG_thread/TExpTh7.java create mode 100644 testcases/package-test/testNG/oe_test_testNG_thread/TExpTh7.xml create mode 100644 testcases/package-test/testNG/oe_test_testNG_thread/oe_test_testNG_thread.sh create mode 100644 testcases/package-test/testNG/oe_test_testNG_with_Junit/JunitTestNG.java create mode 100644 testcases/package-test/testNG/oe_test_testNG_with_Junit/oe_test_testNG_with_Junit.sh create mode 100644 testcases/package-test/testNG/oe_test_testNG_with_Junit/testng_junit.xml create mode 100644 testcases/package-test/testNG/oe_test_testNG_with_ant/build.xml create mode 100644 testcases/package-test/testNG/oe_test_testNG_with_ant/oe_test_testNG_with_ant.sh create mode 100644 testcases/package-test/testNG/oe_test_testNG_with_maven/oe_test_testNG_with_maven.sh create mode 100644 testcases/package-test/testNG/oe_test_testNG_with_maven/pom.xml create mode 100644 testcases/package-test/testNG/oe_test_testNG_with_spring/TExpSpring.xml create mode 100644 testcases/package-test/testNG/oe_test_testNG_with_spring/User.java create mode 100644 testcases/package-test/testNG/oe_test_testNG_with_spring/UserTest1.java create mode 100644 testcases/package-test/testNG/oe_test_testNG_with_spring/oe_test_testNG_with_spring.sh diff --git a/suite2cases/testNG b/suite2cases/testNG new file mode 100644 index 0000000..f05b673 --- /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/package-test/testNG/common/IHookableImp.java b/testcases/package-test/testNG/common/IHookableImp.java new file mode 100644 index 0000000..3e465b7 --- /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 0000000..97caf73 --- /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 0000000..d9c4285 --- /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 0000000..2fe0c97 --- /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 0000000..44e34ee --- /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 0000000..437e986 --- /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 0000000..506759e --- /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 0000000..9a59a64 --- /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 0000000..e104ac7 --- /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 0000000..03b5437 --- /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 0000000..ab88012 --- /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 0000000..45d45ac --- /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 0000000..0240269 --- /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 0000000..11980e1 --- /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 0000000..744f173 --- /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 0000000..499525e --- /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 0000000..a13a9f5 --- /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 0000000..d8e8ce8 --- /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 0000000..2980723 --- /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 0000000..03799fc --- /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 0000000..87d8129 --- /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 0000000..7b44dab --- /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 0000000..41bb09a --- /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 0000000..1577912 --- /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 0000000..8ceb8cb --- /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 0000000..0e5a8e3 --- /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 0000000..6bae191 --- /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 0000000..d3b0f92 --- /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 0000000..9a62f94 --- /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 0000000..74b319f --- /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 0000000..0bc9d55 --- /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 0000000..ac61252 --- /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 0000000..548b503 --- /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 0000000..0c77b35 --- /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 0000000..6117ae5 --- /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 0000000..712d0b7 --- /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 0000000..d001803 --- /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 0000000..494033e --- /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 0000000..387edd3 --- /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 0000000..6096042 --- /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 0000000..3c244ea --- /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 0000000..417095e --- /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 0000000..ec4f730 --- /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 0000000..c142c2e --- /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 0000000..281b6e1 --- /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 0000000..b2ac4bb --- /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 0000000..84c1af3 --- /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 0000000..b9b4379 --- /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 0000000..10acf0d --- /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 0000000..0716717 --- /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 0000000..5810b8d --- /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 0000000..ad560ef --- /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 "$@" -- Gitee From 4242db89388edf3928e5827d72cad79603b151f4 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 19 Jul 2021 14:38:54 +0800 Subject: [PATCH 2/3] add cli-test about freeradius --- suite2cases/freeradius.json | 124 ++++++++++++++++++ .../cli-test/freeradius/common/test.pcap | Bin 0 -> 198 bytes ...freeradius_freeradius-utils_rad_counter.sh | 64 +++++++++ ...t_freeradius_freeradius-utils_radclient.sh | 69 ++++++++++ ..._freeradius_freeradius-utils_radclient2.sh | 72 ++++++++++ ...reeradius-utils_radcryptAndRadeapclient.sh | 69 ++++++++++ ...reeradius_freeradius-utils_radeapclient.sh | 70 ++++++++++ ...est_freeradius_freeradius-utils_radlast.sh | 70 ++++++++++ ...ius_freeradius-utils_radlastAndRadsniff.sh | 70 ++++++++++ ...st_freeradius_freeradius-utils_radsniff.sh | 71 ++++++++++ ...eeradius_freeradius_raddebugAndCheckrad.sh | 120 +++++++++++++++++ .../oe_test_freeradius_freeradius_radiusd.sh | 86 ++++++++++++ ..._freeradius_freeradius_radiusdAndRadmin.sh | 82 ++++++++++++ 13 files changed, 967 insertions(+) create mode 100644 suite2cases/freeradius.json create mode 100644 testcases/cli-test/freeradius/common/test.pcap create mode 100644 testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_rad_counter/oe_test_freeradius_freeradius-utils_rad_counter.sh create mode 100644 testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radclient/oe_test_freeradius_freeradius-utils_radclient.sh create mode 100644 testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radclient2/oe_test_freeradius_freeradius-utils_radclient2.sh create mode 100644 testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radcryptAndRadeapclient/oe_test_freeradius_freeradius-utils_radcryptAndRadeapclient.sh create mode 100644 testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radeapclient/oe_test_freeradius_freeradius-utils_radeapclient.sh create mode 100644 testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radlast/oe_test_freeradius_freeradius-utils_radlast.sh create mode 100644 testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radlastAndRadsniff/oe_test_freeradius_freeradius-utils_radlastAndRadsniff.sh create mode 100644 testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radsniff/oe_test_freeradius_freeradius-utils_radsniff.sh create mode 100644 testcases/cli-test/freeradius/oe_test_freeradius_freeradius_raddebugAndCheckrad/oe_test_freeradius_freeradius_raddebugAndCheckrad.sh create mode 100644 testcases/cli-test/freeradius/oe_test_freeradius_freeradius_radiusd/oe_test_freeradius_freeradius_radiusd.sh create mode 100644 testcases/cli-test/freeradius/oe_test_freeradius_freeradius_radiusdAndRadmin/oe_test_freeradius_freeradius_radiusdAndRadmin.sh diff --git a/suite2cases/freeradius.json b/suite2cases/freeradius.json new file mode 100644 index 0000000..b8ba30e --- /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/testcases/cli-test/freeradius/common/test.pcap b/testcases/cli-test/freeradius/common/test.pcap new file mode 100644 index 0000000000000000000000000000000000000000..987c17de6261b879b78f9d13762a5195a541182a GIT binary patch literal 198 zcmca|c+)~A1{MYwh!S96U<7i?PJ1RC`oO{v0AzzOGT>lvWngepj$~kP5R43{2WkM} z$#2+281()*@=Rt>+sr2a/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 0000000..656c122 --- /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 0000000..77f827d --- /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 0000000..bd27407 --- /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 0000000..db73413 --- /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 0000000..450d898 --- /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 0000000..1b72d17 --- /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_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 0000000..92109dd --- /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 0000000..90ff0bb --- /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 0000000..e1e7c22 --- /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 "$@" -- Gitee From fced2c227688b4eba16c98953a494e1894aa11db Mon Sep 17 00:00:00 2001 From: root Date: Tue, 20 Jul 2021 14:34:17 +0800 Subject: [PATCH 3/3] add cli-test about iperf3 freeradius sqlite-jdbc --- suite2cases/geos.json | 12 +++ suite2cases/iperf3.json | 26 +++++ suite2cases/sqlite-jdbc.json | 12 +++ ...t_freeradius_freeradius-utils_radsniff2.sh | 71 +++++++++++++ ...freeradius_freeradius-utils_radsqlrelay.sh | 97 ++++++++++++++++++ ...adius_freeradius-utils_radtestAndRadwho.sh | 78 ++++++++++++++ ...test_freeradius_freeradius-utils_radwho.sh | 69 +++++++++++++ ...test_freeradius_freeradius-utils_radzap.sh | 64 ++++++++++++ ...dius-utils_rlm_ippool_toolAndSmbencrypt.sh | 69 +++++++++++++ .../geos_test.cpp | 9 ++ .../oe_test_geos_commandAndbaseFun.sh | 72 +++++++++++++ .../cli-test/iperf3/common/common_lib.sh | 38 +++++++ .../oe_test_iperf3_command_client.sh | 57 ++++++++++ .../oe_test_iperf3_command_clientAndShared.sh | 60 +++++++++++ .../oe_test_iperf3_command_serverAndBase.sh | 80 +++++++++++++++ .../oe_test_sqlite-jdbc_connect/Test.java | 41 ++++++++ .../oe_test_sqlite-jdbc_connect.sh | 57 ++++++++++ .../oe_test_sqlite-jdbc_connect/test.db | Bin 0 -> 8192 bytes 18 files changed, 912 insertions(+) create mode 100644 suite2cases/geos.json create mode 100644 suite2cases/iperf3.json create mode 100644 suite2cases/sqlite-jdbc.json create mode 100644 testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radsniff2/oe_test_freeradius_freeradius-utils_radsniff2.sh create mode 100644 testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radsqlrelay/oe_test_freeradius_freeradius-utils_radsqlrelay.sh create mode 100644 testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radtestAndRadwho/oe_test_freeradius_freeradius-utils_radtestAndRadwho.sh create mode 100644 testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radwho/oe_test_freeradius_freeradius-utils_radwho.sh create mode 100644 testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_radzap/oe_test_freeradius_freeradius-utils_radzap.sh create mode 100644 testcases/cli-test/freeradius/oe_test_freeradius_freeradius-utils_rlm_ippool_toolAndSmbencrypt/oe_test_freeradius_freeradius-utils_rlm_ippool_toolAndSmbencrypt.sh create mode 100644 testcases/cli-test/geos/oe_test_geos_commandAndbaseFun/geos_test.cpp create mode 100644 testcases/cli-test/geos/oe_test_geos_commandAndbaseFun/oe_test_geos_commandAndbaseFun.sh create mode 100644 testcases/cli-test/iperf3/common/common_lib.sh create mode 100644 testcases/cli-test/iperf3/oe_test_iperf3_command_client/oe_test_iperf3_command_client.sh create mode 100644 testcases/cli-test/iperf3/oe_test_iperf3_command_clientAndShared/oe_test_iperf3_command_clientAndShared.sh create mode 100644 testcases/cli-test/iperf3/oe_test_iperf3_command_serverAndBase/oe_test_iperf3_command_serverAndBase.sh create mode 100644 testcases/cli-test/sqlite-jdbc/oe_test_sqlite-jdbc_connect/Test.java create mode 100644 testcases/cli-test/sqlite-jdbc/oe_test_sqlite-jdbc_connect/oe_test_sqlite-jdbc_connect.sh create mode 100644 testcases/cli-test/sqlite-jdbc/oe_test_sqlite-jdbc_connect/test.db diff --git a/suite2cases/geos.json b/suite2cases/geos.json new file mode 100644 index 0000000..c762220 --- /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 0000000..a63de7a --- /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 0000000..1e88dc5 --- /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/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 0000000..57b87b7 --- /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 0000000..380bc7c --- /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 0000000..0614a93 --- /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 0000000..c2c32eb --- /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 0000000..f72ed76 --- /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 0000000..e3bf731 --- /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/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 0000000..8c27cfc --- /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 0000000..9665e64 --- /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 0000000..8457ea8 --- /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 0000000..199852a --- /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 0000000..344a94e --- /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 0000000..6a44711 --- /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 0000000..dc4d2d6 --- /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 0000000..5722c24 --- /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 GIT binary patch literal 8192 zcmeI#y-or_5C`ztLnD_+&cwpdO$iCH@dZ3D8*eav z=7QALg#Tn`c4jlxuiJjFJ;^h($ literal 0 HcmV?d00001 -- Gitee