| /////////////////////////////////////////////////////////////////////////////// |
| // // |
| // Copyright (c) 2000-2019 Ericsson Telecom AB // |
| // // |
| // All rights reserved. This program and the accompanying materials // |
| // are made available under the terms of the Eclipse Public License v2.0 // |
| // which accompanies this distribution, and is available at // |
| // https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html // |
| /////////////////////////////////////////////////////////////////////////////// |
| |
| /////////////////////////////////////////////////////////// |
| // Module: EPTF_PTCD_Test_Testcases |
| // |
| // Purpose: |
| // This module contains the testcases of generic EPTF PTCDeployment. |
| // |
| // Module depends on: |
| // <EPTF_CLL_PTCDeployment_Definitions> |
| // <EPTF_CLL_PTCDeployment_Functions> |
| // |
| // |
| // Current Owner: |
| // Balazs Barcsik (EBALBAR) |
| // |
| // Last Review Date: |
| // 2009-01-06 |
| // |
| // Detailed Comments: |
| // - |
| // |
| /////////////////////////////////////////////////////////////// |
| module EPTF_PTCD_Test_Testcases |
| { |
| //========================================================================= |
| // Import part |
| //========================================================================= |
| import from EPTF_CLL_PTCDeployment_Definitions all; |
| import from EPTF_CLL_PTCDeployment_Functions all; |
| import from EPTF_CLL_Base_Functions all; |
| |
| //========================================================================= |
| // Testcases |
| //========================================================================= |
| testcase tc() runs on EPTF_PTCD_CT{ |
| f_EPTF_PTCD_init_CT("myPTCD"); |
| |
| var charstring host; |
| log("Start testing PTC Deployment") |
| |
| log(v_roledatabase); |
| f_EPTF_PTCD_AddHosts("roleB",{{"hostB",10},{"hostC",1}}); |
| log(v_roledatabase); |
| f_EPTF_PTCD_AddHosts("roleA",{{"hostC",534}}); |
| log(v_roledatabase); |
| f_EPTF_PTCD_AddHosts("roleA",{{"hostA",10},{"hostB",42}}); |
| log(v_roledatabase); |
| f_EPTF_PTCD_RemoveHosts("roleA",{"hostB","hostA"}); |
| log(v_roledatabase); |
| f_EPTF_PTCD_AddHosts("roleA",{{"hostA",10},{"hostB",42}, {"hostB",34}}); |
| log(v_roledatabase); |
| |
| host := f_EPTF_PTCD_GetHost("role"); |
| if (host!="") { |
| setverdict(fail); |
| f_EPTF_Base_stop(); |
| } else { |
| log("1. Success of f_EPTF_PTCD_GetHost: ",host); // We have no rule like this in the database |
| } |
| |
| for(var integer i:=0;i<10;i:=i+1){ |
| host := f_EPTF_PTCD_GetHost("roleB"); |
| if (host!="hostB" and host!="hostC") { |
| setverdict(fail); |
| f_EPTF_Base_stop(); |
| } else { |
| log("2.",i,". Success of f_EPTF_PTCD_GetHost: ",host); |
| } |
| } |
| f_EPTF_PTCD_AddHosts("roleC",{{"hostA", 0}, {"", 420},{"hostC",1},{"hostD",-450}}); |
| host := f_EPTF_PTCD_GetHost("roleC"); |
| if (host!="hostC") { |
| setverdict(fail); |
| f_EPTF_Base_stop(); |
| } else { |
| log("3. Success of f_EPTF_PTCD_GetHost: ",host); |
| } |
| |
| v_roledatabase := {}; |
| host := f_EPTF_PTCD_GetHost("roleA"); |
| if (host!="") { |
| setverdict(fail); |
| f_EPTF_Base_stop(); |
| } else { |
| log("4. Success of f_EPTF_PTCD_GetHost: ",host); //empty database |
| } |
| |
| f_EPTF_PTCD_AddHosts("roleC",{ {"hostA", -10}, {"hostB", -42}}); |
| host := f_EPTF_PTCD_GetHost("roleC"); |
| if (host!="") { |
| setverdict(fail); |
| f_EPTF_Base_stop(); |
| } else { |
| log("5. Success of f_EPTF_PTCD_GetHost: ",host); |
| } |
| |
| f_EPTF_PTCD_RemoveHosts("roleC",{"hostB","hostA"}); |
| log(v_roledatabase); |
| host := f_EPTF_PTCD_GetHost("roleA"); |
| if (host!="") { |
| setverdict(fail); |
| f_EPTF_Base_stop(); |
| } else { |
| log("6. Success of f_EPTF_PTCD_GetHost: ",host); |
| } |
| setverdict(pass); |
| f_EPTF_Base_cleanup_CT(); |
| } |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_PTCD_Test_init_CT |
| // |
| // Purpose: |
| // to test f_EPTF_PTCD_init_CT() function |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // - calls f_EPTF_PTCD_init_CT() function |
| // - checks that tsp_PTCD_database is stored |
| // |
| // Expected Result: |
| // init function stores tsp_PTCD_database |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_PTCD_Test_init_CT() runs on EPTF_PTCD_CT |
| { |
| var EPTF_PtcDeploymentEntryList vl_PTCDlist := tsp_PTCD_database; |
| |
| f_EPTF_PTCD_init_CT("myPTCD"); |
| |
| if (f_EPTF_PTCD_GetHost(vl_PTCDlist[0].role, 1) == vl_PTCDlist[0].deployment[0].host) { |
| setverdict(pass); |
| } else { |
| log("Error: returned value is incorrent: ", f_EPTF_PTCD_GetHost(vl_PTCDlist[0].role, 1), ", expected: ", vl_PTCDlist[0].deployment[0].host); |
| setverdict(fail); |
| } |
| f_EPTF_Base_cleanup_CT(); |
| } |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_PTCD_Test_AddHosts |
| // |
| // Purpose: |
| // to test f_EPTF_PTCD_AddHosts() function |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // - calls f_EPTF_PTCD_init_CT() function |
| // - calls f_EPTF_PTCD_AddHosts() function |
| // - checks that added role is stored |
| // |
| // Expected Result: |
| // added role is stored |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_PTCD_Test_AddHosts() runs on EPTF_PTCD_CT |
| { |
| var EPTF_PtcDeploymentEntryList vl_PTCDlist := tsp_PTCD_database; |
| |
| f_EPTF_PTCD_init_CT("myPTCD"); |
| f_EPTF_PTCD_AddHosts("role2",{ {"hostA", 1}, {"hostB", 9}}); |
| |
| if (f_EPTF_PTCD_GetHost("role2") != "") { |
| setverdict(pass); |
| } else { |
| log("Error: returned value is incorrent because it is an empty string"); |
| setverdict(fail); |
| } |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_PTCD_Test_RemoveHosts |
| // |
| // Purpose: |
| // to test f_EPTF_PTCD_RemoveHosts() function |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // - calls f_EPTF_PTCD_init_CT() function |
| // - calls f_EPTF_PTCD_RemoveHosts function |
| // - calls f_EPTF_PTCD_AddHosts() function with a new role |
| // - calls f_EPTF_PTCD_RemoveHosts function with the added role |
| // - checks that added role is removed |
| // |
| // Expected Result: |
| // added role is removed |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_PTCD_Test_RemoveHosts() runs on EPTF_PTCD_CT |
| { |
| var EPTF_PtcDeploymentEntryList vl_PTCDlist := tsp_PTCD_database; |
| |
| f_EPTF_PTCD_init_CT("myPTCD"); |
| |
| f_EPTF_PTCD_RemoveHosts("role2",{"hostB","hostA"}); |
| f_EPTF_PTCD_AddHosts("role2",{ {"hostA", 1}, {"hostB", 9}}); |
| f_EPTF_PTCD_RemoveHosts("role2",{"hostB","hostA"}); |
| |
| if (f_EPTF_PTCD_GetHost("role2") == "") { |
| setverdict(pass); |
| } else { |
| log("Error: returned value is incorrent because it is not an empty string"); |
| setverdict(fail); |
| } |
| f_EPTF_Base_cleanup_CT(); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Testcase: tc_EPTF_PTCD_Test_GetHosts |
| // |
| // Purpose: |
| // to test f_EPTF_PTCD_GetHost() function |
| // |
| // Requirement: |
| // - |
| // |
| // Action: |
| // - calls f_EPTF_PTCD_init_CT() function |
| // - calls f_EPTF_PTCD_AddHosts() function with a new role |
| // - calls f_EPTF_PTCD_GetHost() function with method 1 several times |
| // - checks that returned host name is wether correct or not |
| // |
| // Expected Result: |
| // returned value is the same as we ordered |
| /////////////////////////////////////////////////////////// |
| testcase tc_EPTF_PTCD_Test_GetHosts() runs on EPTF_PTCD_CT |
| { |
| var EPTF_PtcDeploymentEntryList vl_PTCDlist := tsp_PTCD_database; |
| var charstring vl_result; |
| |
| f_EPTF_PTCD_init_CT("myPTCD"); |
| |
| f_EPTF_PTCD_AddHosts("role2",{ {"hostA", 5}, {"hostB", 5}}); |
| vl_result := f_EPTF_PTCD_GetHost("role2", 1); |
| |
| if (vl_result == "hostA") { |
| setverdict(pass); |
| } else { |
| log("Error: returned value is incorrent: ", vl_result, ", expected: hostA"); |
| setverdict(fail); |
| } |
| |
| vl_result := f_EPTF_PTCD_GetHost("role2", 1); |
| |
| if (vl_result == "hostB") { |
| setverdict(pass); |
| } else { |
| log("Error: returned value is incorrent: ", vl_result, ", expected: hostB"); |
| setverdict(fail); |
| } |
| |
| vl_result := f_EPTF_PTCD_GetHost("role2", 1); |
| |
| if (vl_result == "hostA") { |
| setverdict(pass); |
| } else { |
| log("Error: returned value is incorrent: ", vl_result, ", expected: hostA"); |
| setverdict(fail); |
| } |
| |
| f_EPTF_PTCD_RemoveHosts("role2",{"hostB","hostA"}); |
| log(v_roledatabase); |
| |
| if (f_EPTF_PTCD_GetHost("role2") == "") { |
| setverdict(pass); |
| } else { |
| log("Error: returned value is incorrent because it is not an empty string"); |
| setverdict(fail); |
| } |
| f_EPTF_Base_cleanup_CT(); |
| } |
| control { |
| execute(tc()); |
| execute(tc_EPTF_PTCD_Test_init_CT()); |
| execute(tc_EPTF_PTCD_Test_AddHosts()); |
| execute(tc_EPTF_PTCD_Test_RemoveHosts()); |
| execute(tc_EPTF_PTCD_Test_GetHosts()); |
| } |
| } |