Merge "Shared resources tests for gbpfunc"
This commit is contained in:
@@ -32,7 +32,9 @@ class Gbp_Config(object):
|
||||
self.err_strings = ['Unable', 'Conflict', 'Bad Request',
|
||||
'Error', 'Unknown', 'Exception', 'Invalid',
|
||||
'read-only', 'not supported',
|
||||
'prefix greater than subnet mask']
|
||||
'prefix greater than subnet mask',
|
||||
'reference the non shared resource',
|
||||
'cannot be shared by driver']
|
||||
|
||||
def keystone_creds(self):
|
||||
creds = {}
|
||||
|
||||
@@ -39,7 +39,7 @@ def report_table(suite_name):
|
||||
'/tmp/%s.log' % (suite_name)],
|
||||
stdout=subprocess.PIPE)
|
||||
output = ps.communicate()[0]
|
||||
# print output
|
||||
#print 'Output inside report_table: ', output
|
||||
output = output.splitlines()
|
||||
line = 0
|
||||
tc_dict = {}
|
||||
@@ -54,7 +54,7 @@ def report_table(suite_name):
|
||||
if find2 is not None:
|
||||
tc_dict[find1.group(1)] = find2.group(1), find1.group(2)
|
||||
line += 1
|
||||
# print tc_dict
|
||||
#print 'Table Dict == ', tc_dict
|
||||
table = prettytable.PrettyTable(["TESTCASE_ID", "RESULTS",
|
||||
"TESTCASE_HEADER"])
|
||||
table.padding_width = 1
|
||||
|
||||
48
gbpservice/tests/contrib/gbpfunctests/testcases/suite_admin_run.py
Executable file
48
gbpservice/tests/contrib/gbpfunctests/testcases/suite_admin_run.py
Executable file
@@ -0,0 +1,48 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import commands
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
"""
|
||||
Main: Wrapper for shared_func tests
|
||||
"""
|
||||
# Usage: python suite_admin_run.py
|
||||
print ("Functional Test Script to execute Shared Resource Testcases")
|
||||
cmd_list = ["sudo sh -c 'cat /dev/null > test_results_admin.txt'",
|
||||
"sudo chmod 777 test_results_admin.txt "]
|
||||
for cmd in cmd_list:
|
||||
commands.getoutput(cmd)
|
||||
test_list = ['tc_gbp_pr_pc_pa_shared_func.py',
|
||||
'tc_gbp_prs_pr_shared_func.py']
|
||||
for test in test_list:
|
||||
cmd = 'python %s' % (test)
|
||||
print (cmd)
|
||||
subprocess.call(cmd, shell=True)
|
||||
results_file = open("test_results_admin.txt")
|
||||
contents = results_file.read()
|
||||
results_file.close()
|
||||
print (contents)
|
||||
print ("\n\nTotal Number of Shared Resource TestCases Executed= %s" % (
|
||||
contents.count("_SHARED_")))
|
||||
print ("\n\nNumber of TestCases Passed= %s" % (contents.count("PASSED")))
|
||||
print ("\n\nNumber of TestCases Failed= %s" % (contents.count("FAILED")))
|
||||
if contents.count("FAILED") > 0:
|
||||
sys.exit(1)
|
||||
else:
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
75
gbpservice/tests/contrib/gbpfunctests/testcases/suite_non_admin_run.py
Executable file
75
gbpservice/tests/contrib/gbpfunctests/testcases/suite_non_admin_run.py
Executable file
@@ -0,0 +1,75 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import commands
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def run_func_neg():
|
||||
"""
|
||||
Method to manipulate needed files
|
||||
"""
|
||||
# Assumption is all files are in current directory
|
||||
# if 'Ubuntu' in platform.linux_distribution():
|
||||
# directory = "/usr/local/lib/python2.7/dist-packages/gbpfunctests/"
|
||||
# else:
|
||||
# directory = "/usr/lib/python2.7/site-packages/gbpfunctests/" # in RHEL
|
||||
cmd_list = ["sudo sh -c 'cat /dev/null > test_results.txt'",
|
||||
"sudo sh -c 'cat /dev/null > func_neg.txt'",
|
||||
"sudo sh -c 'ls *_func*.py | grep -v shared > func_neg.txt'",
|
||||
"sudo sh -c 'ls *_neg.py >> func_neg.txt'",
|
||||
"sudo chmod 777 *"]
|
||||
for cmd in cmd_list:
|
||||
commands.getoutput(cmd)
|
||||
return "func_neg.txt"
|
||||
|
||||
|
||||
def main():
|
||||
"""
|
||||
Test Execution
|
||||
Generating Results
|
||||
"""
|
||||
usage = "Usage: python suite_run.py <'aci' or 'upstream'>"
|
||||
try:
|
||||
flag = sys.argv[1]
|
||||
except Exception:
|
||||
print ('%s' % (usage))
|
||||
sys.exit(1)
|
||||
fname = run_func_neg()
|
||||
num_lines = sum(1 for line in open(fname))
|
||||
print ("\nNumber of Functional Test Scripts to execute = %s" % (num_lines))
|
||||
with open(fname) as f:
|
||||
for i, l in enumerate(f, 1):
|
||||
print ("Functional Test Script to execute now == %s" % l)
|
||||
# Assumption: test-scripts are executable from any location
|
||||
# Reading the line from text file, also reads trailing \n, hence we
|
||||
# need to strip
|
||||
cmd = 'python %s %s' % (l.strip(), flag)
|
||||
print (cmd)
|
||||
# out=getoutput(cmd)
|
||||
subprocess.call(cmd, shell=True)
|
||||
f = open("test_results.txt")
|
||||
contents = f.read()
|
||||
f.close()
|
||||
print (contents)
|
||||
print ("\n\nTotal Number of TestCases Executed= %s" % (
|
||||
contents.count("TESTCASE_GBP_")))
|
||||
print ("\n\nNumber of TestCases Passed= %s" % (contents.count("PASSED")))
|
||||
print ("\n\nNumber of TestCases Failed= %s" % (contents.count("FAILED")))
|
||||
if contents.count("FAILED") > 0:
|
||||
sys.exit(1)
|
||||
else:
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -54,7 +54,7 @@ def main():
|
||||
f = open("test_results.txt")
|
||||
contents = f.read()
|
||||
f.close()
|
||||
print(contents)
|
||||
print (contents)
|
||||
print("\n\nTotal Number of TestCases Executed= %s" % (
|
||||
contents.count("TESTCASE_GBP_")))
|
||||
print("\n\nNumber of TestCases Passed= %s" % (contents.count("PASSED")))
|
||||
|
||||
@@ -1,645 +0,0 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import commands
|
||||
import logging
|
||||
import sys
|
||||
|
||||
from libs import config_libs
|
||||
from libs import utils_libs
|
||||
from libs import verify_libs
|
||||
|
||||
|
||||
def main():
|
||||
print('For now skipping this entire suite ..')
|
||||
sys.exit(1)
|
||||
# Run the Testcases:
|
||||
test = test_gbp_prs_func()
|
||||
if test.test_gbp_prs_func_1() == 0:
|
||||
test.cleanup(tc_name='TESTCASE_GBP_PRS_FUNC_1')
|
||||
if test.test_gbp_prs_func_2() == 0:
|
||||
test.cleanup(tc_name='TESTCASE_GBP_PRS_FUNC_2')
|
||||
if test.test_gbp_prs_func_3() == 0:
|
||||
test.cleanup(tc_name='TESTCASE_GBP_PRS_FUNC_3')
|
||||
if test.test_gbp_prs_func_4() == 0:
|
||||
test.cleanup(tc_name='TESTCASE_GBP_PRS_FUNC_4')
|
||||
if sys.argv[1] == 'aci':
|
||||
test._log.info(
|
||||
"\nTESTCASE_GBP_PRS_FUNC_5: TO CREATE/VERIFY/DELETE/VERIFY a "
|
||||
"PARENT and CHILD POLICY RULESET\n")
|
||||
test._log.info("\nTESTCASE_GBP_PRS_FUNC_5: NOT SUPPORTED in ACI")
|
||||
test._log.info(
|
||||
"\nTESTCASE_GBP_PRS_FUNC_6: TO CHANGE/UPDATE/DELETE/VERIFY PARENT "
|
||||
"and CHILD POLICY RULESET\n")
|
||||
test._log.info("\nTESTCASE_GBP_PRS_FUNC_6: NOT SUPPORTED in ACI")
|
||||
else:
|
||||
if test.test_gbp_prs_func_5() == 0:
|
||||
test.cleanup(tc_name='TESTCASE_GBP_PRS_FUNC_5')
|
||||
if test.test_gbp_prs_func_6() == 0:
|
||||
test.cleanup(tc_name='TESTCASE_GBP_PRS_FUNC_6')
|
||||
test.cleanup()
|
||||
utils_libs.report_results('test_gbp_prs_func', 'test_results.txt')
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
class test_gbp_prs_func(object):
|
||||
|
||||
# Initialize logging
|
||||
logging.basicConfig(
|
||||
format='%(asctime)s [%(levelname)s] %(name)s - %(message)s',
|
||||
level=logging.WARNING)
|
||||
_log = logging.getLogger(__name__)
|
||||
cmd = 'rm /tmp/test_gbp_prs_func.log'
|
||||
commands.getoutput(cmd)
|
||||
hdlr = logging.FileHandler('/tmp/test_gbp_prs_func.log')
|
||||
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
|
||||
hdlr.setFormatter(formatter)
|
||||
_log.addHandler(hdlr)
|
||||
_log.setLevel(logging.INFO)
|
||||
_log.setLevel(logging.DEBUG)
|
||||
|
||||
def __init__(self):
|
||||
"""
|
||||
Init def
|
||||
"""
|
||||
self._log.info(
|
||||
"\n## START OF GBP POLICY_RULE_SET FUNCTIONALITY TESTSUITE\n")
|
||||
self.gbpcfg = config_libs.Gbp_Config()
|
||||
self.gbpverify = verify_libs.Gbp_Verify()
|
||||
self.act_name = 'demo_pa'
|
||||
self.cls_name = 'demo_pc'
|
||||
self.rule_name = 'demo_pr'
|
||||
self.ruleset_name = 'demo_prs'
|
||||
self._log.info('\n## Step 1: Create a PC needed for PRS Testing ##')
|
||||
self.cls_uuid = self.gbpcfg.gbp_policy_cfg_all(
|
||||
1, 'classifier', self.cls_name)
|
||||
if self.cls_uuid == 0:
|
||||
self._log.info(
|
||||
"\nReqd Policy Classifier Create Failed, hence GBP Policy "
|
||||
"Rule-Set Functional Test Suite Run ABORTED\n")
|
||||
return 0
|
||||
self._log.info('\n## Step 1: Create a PA needed for PRS Testing ##')
|
||||
self.act_uuid = self.gbpcfg.gbp_policy_cfg_all(
|
||||
1, 'action', self.act_name)
|
||||
if self.act_uuid == 0:
|
||||
self._log.info(
|
||||
"\nReqd Policy Action Create Failed, hence GBP Policy "
|
||||
"Rule-Set Functional Test Suite Run ABORTED\n")
|
||||
return 0
|
||||
self._log.info('\n## Step 1: Create a PR needed for PRS Testing ##')
|
||||
self.rule_uuid = self.gbpcfg.gbp_policy_cfg_all(
|
||||
1, 'rule', self.rule_name, classifier=self.cls_name,
|
||||
action=self.act_name)
|
||||
if self.rule_uuid == 0:
|
||||
self._log.info(
|
||||
"\nReqd Policy Rule Create Failed, hence GBP Policy Rule-Set "
|
||||
"Functional Test Suite Run ABORTED\n ")
|
||||
return 0
|
||||
|
||||
def cleanup(self, tc_name=''):
|
||||
if tc_name != '':
|
||||
self._log.info('Testcase %s: FAILED' % (tc_name))
|
||||
for obj in ['ruleset', 'rule', 'classifier', 'action']:
|
||||
self.gbpcfg.gbp_del_all_anyobj(obj)
|
||||
|
||||
def test_gbp_prs_func_1(
|
||||
self,
|
||||
name_uuid='',
|
||||
ruleset_uuid='',
|
||||
rep_cr=0,
|
||||
rep_del=0):
|
||||
|
||||
if rep_cr == 0 and rep_del == 0:
|
||||
self._log.info(
|
||||
"\n########################################################\n"
|
||||
"TESTCASE_GBP_PRS_FUNC_1: TO CREATE/VERIFY/DELETE/VERIFY a "
|
||||
"POLICY RULESET with DEFAULT ATTRIB VALUE\n"
|
||||
"TEST_STEP::\n"
|
||||
"Create a Neutron External Network and associate a subnet\n"
|
||||
"Create a GBP External Segment using the Subnet,GW & CIDR\n"
|
||||
"Verify the attributes & value, show & list cmds\n"
|
||||
"Delete Policy RuleSet using Name\n"
|
||||
"Verify that PR has got deleted, show & list cmds\n"
|
||||
"##########################################################\n")
|
||||
|
||||
if name_uuid == '':
|
||||
name_uuid = self.ruleset_name
|
||||
# Testcase work-flow starts
|
||||
if rep_cr == 0 or rep_cr == 1:
|
||||
self._log.info(
|
||||
'\n## Step 1: Create RuleSet with default attrib vals##\n')
|
||||
ruleset_uuid = self.gbpcfg.gbp_policy_cfg_all(
|
||||
1, 'ruleset', name_uuid)
|
||||
if ruleset_uuid == 0:
|
||||
self._log.info("# Step 1: Create RuleSet == Failed")
|
||||
return 0
|
||||
self._log.info('# Step 2A: Verify RuleSet using -list cmd')
|
||||
if self.gbpverify.gbp_policy_verify_all(
|
||||
0, 'ruleset', name_uuid, ruleset_uuid) == 0:
|
||||
self._log.info(
|
||||
"# Step 2A: Verify RuleSet using -list option == Failed")
|
||||
return 0
|
||||
self._log.info('# Step 2B: Verify RuleSet using -show cmd')
|
||||
if self.gbpverify.gbp_policy_verify_all(
|
||||
1, 'ruleset', name_uuid, id=ruleset_uuid,
|
||||
shared='False') == 0:
|
||||
self._log.info(
|
||||
"# Step 2B: Verify RuleSet using -show option == Failed")
|
||||
return 0
|
||||
#######
|
||||
if rep_del == 0 or rep_del == 1:
|
||||
self._log.info('\n## Step 3: Delete RuleSet using name ##\n')
|
||||
if self.gbpcfg.gbp_policy_cfg_all(0, 'ruleset', name_uuid) == 0:
|
||||
self._log.info("# Step 3: Delete RuleSet == Failed")
|
||||
return 0
|
||||
if self.gbpverify.gbp_policy_verify_all(
|
||||
0, 'ruleset', name_uuid, ruleset_uuid) != 0:
|
||||
self._log.info(
|
||||
"# Step 3A: Verify RuleSet is Deleted using -list "
|
||||
"option == Failed")
|
||||
return 0
|
||||
if self.gbpverify.gbp_policy_verify_all(
|
||||
1, 'ruleset', name_uuid, id=ruleset_uuid,
|
||||
shared='False') != 0:
|
||||
self._log.info(
|
||||
"# Step 3B: Verify RuleSet is Deleted using -show option "
|
||||
"== Failed")
|
||||
return 0
|
||||
if rep_cr == 0 and rep_del == 0:
|
||||
self._log.info("\nTESTCASE_GBP_PRS_FUNC_1: PASSED")
|
||||
return 1
|
||||
|
||||
def test_gbp_prs_func_2(self):
|
||||
|
||||
self._log.info(
|
||||
"\n############################################################\n"
|
||||
"TESTCASE_GBP_PRS_FUNC_2: TO CREATE/VERIFY/DELETE/VERIFY a "
|
||||
"POLICY RULESET with POLICY RULE\n"
|
||||
"TEST_STEP::\n"
|
||||
"Create Policy RuleSet Object with GBP PR\n"
|
||||
"Verify the attributes & value, show & list cmds\n"
|
||||
"Delete Policy RuleSet using Name\n"
|
||||
"Verify that PR has got deleted, show & list cmds\n"
|
||||
"##############################################################\n")
|
||||
|
||||
# Testcase work-flow starts
|
||||
self._log.info("\n## Step 1: Create Policy RuleSet with PR ##")
|
||||
ruleset_uuid = self.gbpcfg.gbp_policy_cfg_all(
|
||||
1, 'ruleset', self.ruleset_name, policy_rules=self.rule_name)
|
||||
if ruleset_uuid == 0:
|
||||
self._log.info("# Step 1: Create RuleSet == Failed")
|
||||
return 0
|
||||
self._log.info('# Step 2A: Verify RuleSet using -list cmd')
|
||||
if self.gbpverify.gbp_policy_verify_all(
|
||||
0, 'ruleset', self.ruleset_name, ruleset_uuid) == 0:
|
||||
self._log.info(
|
||||
"# Step 2A: Verify RuleSet using -list option == Failed")
|
||||
return 0
|
||||
self._log.info('# Step 2B: Verify RuleSet using -show cmd')
|
||||
if self.gbpverify.gbp_policy_verify_all(
|
||||
1,
|
||||
'ruleset',
|
||||
self.ruleset_name,
|
||||
id=ruleset_uuid,
|
||||
policy_rules=self.rule_uuid,
|
||||
shared='False') == 0:
|
||||
self._log.info(
|
||||
"# Step 2B: Verify RuleSet using -show option == Failed")
|
||||
return 0
|
||||
self.test_gbp_prs_func_1(ruleset_uuid=ruleset_uuid, rep_cr=2)
|
||||
self._log.info("\nTESTCASE_GBP_PRS_FUNC_2: PASSED")
|
||||
return 1
|
||||
|
||||
def test_gbp_prs_func_3(self):
|
||||
|
||||
self._log.info(
|
||||
"\n#############################################################\n"
|
||||
"TESTCASE_GBP_PRS_FUNC_3: TO UPDATE/VERIFY/DELETE/VERIFY EACH "
|
||||
"ATTRIB of a POLICY RULESET\n"
|
||||
"TEST_STEP::\n"
|
||||
"Create Policy RuleSet using Default param values\n"
|
||||
"Update Each the Policy Rule's editable params\n"
|
||||
"Verify the Policy Rule's attributes & values, show & list cmds\n"
|
||||
"Delete the Policy Rule\n"
|
||||
"Verify Policy RuleSet successfully deleted\n"
|
||||
"##############################################################\n")
|
||||
|
||||
# Testcase work-flow starts
|
||||
self._log.info('\n## Step 1: Create Policy RuleSet with PR ##\n')
|
||||
ruleset_uuid = self.gbpcfg.gbp_policy_cfg_all(
|
||||
1, 'ruleset', self.ruleset_name, policy_rules=self.rule_name)
|
||||
if ruleset_uuid != 0:
|
||||
self._log.info(
|
||||
"Step 1: Create RuleSet Passed, UUID == %s\n" %
|
||||
(ruleset_uuid))
|
||||
else:
|
||||
self._log.info("# Step 1: Create RuleSet == Failed")
|
||||
return 0
|
||||
self._log.info('\n## Step 1A: Create new PA ,new PC, new PR##\n')
|
||||
new_cls_uuid = self.gbpcfg.gbp_policy_cfg_all(
|
||||
1, 'classifier', 'grppol_pc1')
|
||||
if new_cls_uuid == 0:
|
||||
self._log.info(
|
||||
"\nNew Classifier Create Failed, hence "
|
||||
"TESTCASE_GBP_PRS_FUNC_3 ABORTED\n")
|
||||
return 0
|
||||
new_act_uuid = self.gbpcfg.gbp_policy_cfg_all(1, 'action',
|
||||
'grppol_pa1')
|
||||
if new_act_uuid == 0:
|
||||
self._log.info(
|
||||
"\nNew Action Create Failed, hence TESTCASE_GBP_PRS_FUNC_3 "
|
||||
"ABORTED\n")
|
||||
return 0
|
||||
new_rule_uuid = self.gbpcfg.gbp_policy_cfg_all(
|
||||
1,
|
||||
'rule',
|
||||
'grppol_pr',
|
||||
classifier=new_cls_uuid,
|
||||
action=new_act_uuid,
|
||||
description="'For devstack demo'")
|
||||
if new_rule_uuid == 0:
|
||||
self._log.info(
|
||||
"\nNew Rule Create Failed, hence TESTCASE_GBP_PRS_FUNC_3 "
|
||||
"ABORTED\n")
|
||||
return 0
|
||||
if self.gbpcfg.gbp_policy_cfg_all(
|
||||
2,
|
||||
'ruleset',
|
||||
ruleset_uuid,
|
||||
name='grppol_prs',
|
||||
policy_rule=new_rule_uuid,
|
||||
description="'For devstack demo'") == 0:
|
||||
self._log.info(
|
||||
"\nStep 2: Updating Policy RuleSet's Attributes , Failed")
|
||||
return 0
|
||||
# Verify starts
|
||||
if self.gbpverify.gbp_policy_verify_all(
|
||||
0, 'ruleset', 'grppol_prs', ruleset_uuid) == 0:
|
||||
self._log.info(
|
||||
"# Step 2A: Verify Policy RuleSet Updated Attributes using "
|
||||
"-list option == Failed")
|
||||
return 0
|
||||
if self.gbpverify.gbp_policy_verify_all(
|
||||
1,
|
||||
'ruleset',
|
||||
ruleset_uuid,
|
||||
name='grppol_prs',
|
||||
policy_rules=new_rule_uuid,
|
||||
description='For devstack demo') == 0:
|
||||
self._log.info(
|
||||
"# Step 2B: Verify Policy RuleSet Updated Attributes using "
|
||||
"-show option == Failed")
|
||||
return 0
|
||||
self._log.info("\nTESTCASE_GBP_PRS_FUNC_3: PASSED")
|
||||
return 1
|
||||
|
||||
def test_gbp_prs_func_4(self):
|
||||
|
||||
self._log.info(
|
||||
"\n############################################################\n"
|
||||
"TESTCASE_GBP_PRS_FUNC_4: TO CREATE/UPDATE/VERIFY/DELETE/ "
|
||||
"ASSOCIATING MULTIPLE PRs to 1 POLICY RULESET \n"
|
||||
"TEST_STEP::\n"
|
||||
"Create Multiple Policy Rules\n"
|
||||
"Create Policy RuleSet by associating all the Policy Rules\n"
|
||||
"Verify that multiple Policy Rules are associated to the Policy "
|
||||
"RuleSet\n"
|
||||
"Update the Policy RuleSet such that few Policy Rules are "
|
||||
"unmapped\n"
|
||||
"Verify the Policy Rule's attributes & values, show & list cmds\n"
|
||||
"Update the Policy RuleSet such that all Policy Rules association "
|
||||
"removed\n"
|
||||
"Verify the Policy Rule's attributes & values, show & list cmds\n"
|
||||
"##############################################################\n")
|
||||
|
||||
# Testcase work-flow starts
|
||||
self._log.info(
|
||||
'\n## Step 1A: Create new PA ,new PC, 4 PRs using the same PA & '
|
||||
'PC##\n')
|
||||
new_cls_uuid = self.gbpcfg.gbp_policy_cfg_all(
|
||||
1, 'classifier', 'grppol_pc1')
|
||||
if new_cls_uuid == 0:
|
||||
self._log.info(
|
||||
"\nNew Classifier Create Failed, hence "
|
||||
"TESTCASE_GBP_PRS_FUNC_4 ABORTED\n")
|
||||
return 0
|
||||
new_act_uuid = self.gbpcfg.gbp_policy_cfg_all(1, 'action',
|
||||
'grppol_pa1')
|
||||
if new_act_uuid == 0:
|
||||
self._log.info(
|
||||
"\nNew Action Create Failed, hence "
|
||||
"TESTCASE_GBP_PRS_FUNC_4 ABORTED\n")
|
||||
return 0
|
||||
rule_uuid_list = []
|
||||
for i in range(4):
|
||||
new_rule_uuid = self.gbpcfg.gbp_policy_cfg_all(
|
||||
1,
|
||||
'rule',
|
||||
'grppol_pr_%s' %
|
||||
(i),
|
||||
classifier=new_cls_uuid,
|
||||
action=new_act_uuid,
|
||||
description="'For devstack demo'")
|
||||
if new_rule_uuid == 0:
|
||||
self._log.info(
|
||||
"\nNew Rule Create Failed, hence "
|
||||
"TESTCASE_GBP_PRS_FUNC_4 ABORTED\n")
|
||||
return 0
|
||||
rule_uuid_list.append(new_rule_uuid)
|
||||
ruleset_uuid = self.gbpcfg.gbp_policy_cfg_all(
|
||||
1,
|
||||
'ruleset',
|
||||
'grppol_prs_many',
|
||||
policy_rule='"%s %s %s %s"' %
|
||||
(rule_uuid_list[0],
|
||||
rule_uuid_list[1],
|
||||
rule_uuid_list[2],
|
||||
rule_uuid_list[3]),
|
||||
description="'For devstack demo'")
|
||||
if ruleset_uuid == 0:
|
||||
self._log.info(
|
||||
"\nStep 2: Updating Policy RuleSet's Attributes , Failed")
|
||||
return 0
|
||||
# Verify starts
|
||||
if self.gbpverify.gbp_policy_verify_all(
|
||||
0, 'ruleset', 'grppol_prs_many', ruleset_uuid) == 0:
|
||||
self._log.info(
|
||||
"# Step 2A: Verify Policy RuleSet Updated Attributes using "
|
||||
"-list option == Failed")
|
||||
return 0
|
||||
if self.gbpverify.gbp_policy_verify_all(
|
||||
1,
|
||||
'ruleset',
|
||||
ruleset_uuid,
|
||||
name='grppol_prs_many',
|
||||
description='For devstack demo') == 0:
|
||||
self._log.info(
|
||||
"# Step 2B: Verify Policy RuleSet Updated Attributes using "
|
||||
"-show option == Failed")
|
||||
return 0
|
||||
if self.gbpverify.gbp_obj_ver_attr_all_values(
|
||||
'ruleset', 'grppol_prs_many', 'policy_rules',
|
||||
rule_uuid_list) == 0:
|
||||
self._log.info(
|
||||
"# Step 2C: Verify Policy RuleSet and its Multiple PRs using "
|
||||
"-show option == Failed")
|
||||
return 0
|
||||
# Update and Verify the PRS by updating the PRs(removing few existing
|
||||
# ones)
|
||||
if self.gbpcfg.gbp_policy_cfg_all(
|
||||
2, 'ruleset', 'grppol_prs_many', policy_rule='"%s %s"' %
|
||||
(rule_uuid_list[0], rule_uuid_list[2])) == 0:
|
||||
self._log.info(
|
||||
"# Step 3: Updating Policy RuleSet's Attributes , Failed")
|
||||
return 0
|
||||
if self.gbpverify.gbp_obj_ver_attr_all_values(
|
||||
'ruleset', 'grppol_prs_many', 'policy_rules',
|
||||
rule_uuid_list) != 0:
|
||||
self._log.info(
|
||||
"# Step 3A: Verify Policy RuleSet and its Multiple PRs using "
|
||||
"-show option == Failed")
|
||||
return 0
|
||||
# Update and Verify the PRS by updating the PRs=NULL(unmapping all PRs)
|
||||
if self.gbpcfg.gbp_policy_cfg_all(2, 'ruleset', 'grppol_prs_many',
|
||||
policy_rule='""') == 0:
|
||||
self._log.info(
|
||||
"# Step 4: Upmapping All Policy Rule from Policy RuleSet , "
|
||||
"Failed")
|
||||
return 0
|
||||
if self.gbpverify.gbp_obj_ver_attr_all_values(
|
||||
'ruleset', 'grppol_prs_many', 'policy_rules',
|
||||
rule_uuid_list) != 0:
|
||||
self._log.info(
|
||||
"# Step 4A: Verify All Policy Rules have been Removed from "
|
||||
"Policy RuleSet using --show option == Failed")
|
||||
return 0
|
||||
self._log.info("\nTESTCASE_GBP_PRS_FUNC_4: PASSED")
|
||||
return 1
|
||||
|
||||
def test_gbp_prs_func_5(self):
|
||||
self._log.info(
|
||||
"\n############################################################\n"
|
||||
"TESTCASE_GBP_PRS_FUNC_5: TO CREATE/VERIFY/DELETE/VERIFY a PARENT "
|
||||
"and CHILD POLICY RULESET\n"
|
||||
"TEST_STEP::\n"
|
||||
"Create 1 Policy RuleSet using the same PA & PC\n"
|
||||
"Create the 2nd Policy RuleSet using the same PA, PC and "
|
||||
"associate PRS-1 as CHILD\n"
|
||||
"Verify the Child PRS reflect the Parent PRS and viceversa\n"
|
||||
"Delete the Child PRS\n"
|
||||
"Verify the Parent PRS has no CHILD\n"
|
||||
"Create the CHild PRS, associate to the Parent PRS\n"
|
||||
"Verify the association is established b/e Child and Parent\n"
|
||||
"Delete the Parent PRS\n"
|
||||
"Verify the Parent PRS association removed the Child PRS\n"
|
||||
"##############################################################\n")
|
||||
|
||||
# Testcase work-flow starts
|
||||
self._log.info("\n## Step 1: Create Policy RuleSet with PR ##")
|
||||
child_uuid = self.gbpcfg.gbp_policy_cfg_all(
|
||||
1, 'ruleset', 'demo_child_prs', policy_rules=self.rule_name)
|
||||
if child_uuid == 0:
|
||||
self._log.info("\n## Step 1: Create Child Policy RuleSet == "
|
||||
"Failed")
|
||||
return 0
|
||||
parent_uuid = self.gbpcfg.gbp_policy_cfg_all(
|
||||
1,
|
||||
'ruleset',
|
||||
'demo_par_prs',
|
||||
policy_rules=self.rule_name,
|
||||
child_policy_rule_sets=child_uuid)
|
||||
if parent_uuid == 0:
|
||||
self._log.info(
|
||||
"\n## Step 2: Create Parent Policy RuleSet == Failed")
|
||||
return 0
|
||||
self._log.info(
|
||||
'# Step 2A: Verify Parent and Child Policy RuleSet using -show '
|
||||
'cmd')
|
||||
if self.gbpverify.gbp_policy_verify_all(
|
||||
1,
|
||||
'ruleset',
|
||||
'demo_par_prs',
|
||||
id=parent_uuid,
|
||||
policy_rules=self.rule_uuid,
|
||||
shared='False',
|
||||
child_policy_rule_sets=child_uuid) == 0:
|
||||
self._log.info(
|
||||
"\n## Step 2A: Verify Parent RuleSet using -show option == "
|
||||
"Failed")
|
||||
return 0
|
||||
if self.gbpverify.gbp_policy_verify_all(
|
||||
1,
|
||||
'ruleset',
|
||||
'demo_child_prs',
|
||||
id=child_uuid,
|
||||
policy_rules=self.rule_uuid,
|
||||
shared='False',
|
||||
parent_id=parent_uuid) == 0:
|
||||
self._log.info(
|
||||
"\n## Step 2B: Verify Parent RuleSet using -show option == "
|
||||
"Failed")
|
||||
return 0
|
||||
# Delete Child PRS
|
||||
if self.gbpcfg.gbp_policy_cfg_all(0, 'ruleset', 'demo_child_prs') == 0:
|
||||
self._log.info("# Step 3: Delete Child Policy RuleSet == Failed")
|
||||
return 0
|
||||
if self.gbpverify.gbp_policy_verify_all(
|
||||
1,
|
||||
'ruleset',
|
||||
'demo_par_prs',
|
||||
id=parent_uuid,
|
||||
policy_rules=self.rule_uuid,
|
||||
shared='False',
|
||||
child_policy_rule_sets=child_uuid) != 0:
|
||||
self._log.info(
|
||||
"# Step 3A: Verify Parent PRS after Delete of Child PRS "
|
||||
"using -show option == Failed")
|
||||
return 0
|
||||
# Create Child PRS,Associate to Parent and Verify
|
||||
child_uuid = self.gbpcfg.gbp_policy_cfg_all(
|
||||
1, 'ruleset', 'demo_child_prs', policy_rules=self.rule_name)
|
||||
if child_uuid == 0:
|
||||
self._log.info("# Step 4: Create Child Policy RuleSet == Failed")
|
||||
return 0
|
||||
if self.gbpcfg.gbp_policy_cfg_all(
|
||||
2,
|
||||
'ruleset',
|
||||
'demo_par_prs',
|
||||
child_policy_rule_sets=child_uuid) == 0:
|
||||
self._log.info(
|
||||
"# Step 5: Associating Child PRS by Updating Parent "
|
||||
"PRS == Failed")
|
||||
return 0
|
||||
self._log.info(
|
||||
'# Step 5A: Verify Parent and Child Policy RuleSet '
|
||||
'using -show cmd')
|
||||
if self.gbpverify.gbp_policy_verify_all(
|
||||
1,
|
||||
'ruleset',
|
||||
'demo_par_prs',
|
||||
id=parent_uuid,
|
||||
policy_rules=self.rule_uuid,
|
||||
shared='False',
|
||||
child_policy_rule_sets=child_uuid) == 0:
|
||||
self._log.info(
|
||||
"# Step 5A: Verify Parent RuleSet using -show option == "
|
||||
"Failed")
|
||||
return 0
|
||||
if self.gbpverify.gbp_policy_verify_all(
|
||||
1,
|
||||
'ruleset',
|
||||
'demo_child_prs',
|
||||
id=child_uuid,
|
||||
policy_rules=self.rule_uuid,
|
||||
shared='False',
|
||||
parent_id=parent_uuid) == 0:
|
||||
self._log.info(
|
||||
"# Step 5B: Verify Parent RuleSet using -show option == "
|
||||
"Failed")
|
||||
return 0
|
||||
# Delete Parent PRS and Verify
|
||||
if self.gbpcfg.gbp_policy_cfg_all(0, 'ruleset', 'demo_par_prs') == 0:
|
||||
self._log.info("# Step 6: Delete Parent Policy RuleSet == Failed")
|
||||
return 0
|
||||
if self.gbpverify.gbp_policy_verify_all(
|
||||
1,
|
||||
'ruleset',
|
||||
'demo_child_prs',
|
||||
id=child_uuid,
|
||||
policy_rules=self.rule_uuid,
|
||||
shared='False',
|
||||
parent_id=parent_uuid) != 0:
|
||||
self._log.info(
|
||||
"# Step 6A: Verify Child PRS after Delete of Parent PRS using "
|
||||
"-show option == Failed")
|
||||
return 0
|
||||
self._log.info("\nTESTCASE_GBP_PRS_FUNC_5: PASSED")
|
||||
return 1
|
||||
|
||||
def test_gbp_prs_func_6(self):
|
||||
"""
|
||||
Changing parent-child prs mapping
|
||||
Create 4 PRS, two are parent and two are child
|
||||
Update the one of the parent such that both childs are mapped
|
||||
Verify
|
||||
Delete both child PRS
|
||||
Verify the parent PRS
|
||||
"""
|
||||
self._log.info(
|
||||
"\n############################################################\n"
|
||||
"TESTCASE_GBP_PRS_FUNC_6: TO CHANGE/UPDATE/DELETE/VERIFY PARENT "
|
||||
"and CHILD POLICY RULESET\n"
|
||||
"TEST_STEP::\n"
|
||||
"Changing parent-child prs mapping\n"
|
||||
"Create 4 PRS, two are parent and two are child\n"
|
||||
"Update the one of the parent such that both childs are mapped\n"
|
||||
"Verify\n"
|
||||
"Delete both child PRS\n"
|
||||
"Verify the parent PRS\n"
|
||||
"##############################################################\n")
|
||||
|
||||
# Testcase work-flow starts
|
||||
self._log.info(
|
||||
"\n## Step 1: Create 4 Policy RuleSets, 2 Parent & 2 Child "
|
||||
"with PR ##")
|
||||
ch_uuids, par_uuids = [], []
|
||||
for i in range(1, 3):
|
||||
child_name, par_name = 'child_%s_prs' % (i), 'par_%s_prs' % (i)
|
||||
child_uuid = self.gbpcfg.gbp_policy_cfg_all(
|
||||
1, 'ruleset', child_name, policy_rules=self.rule_name)
|
||||
if child_uuid == 0:
|
||||
self._log.info(
|
||||
"\n## Step 1: Create Child Policy RuleSet == Failed")
|
||||
return 0
|
||||
parent_uuid = self.gbpcfg.gbp_policy_cfg_all(
|
||||
1,
|
||||
'ruleset',
|
||||
par_name,
|
||||
policy_rules=self.rule_name,
|
||||
child_policy_rule_sets=child_uuid)
|
||||
if parent_uuid == 0:
|
||||
self._log.info(
|
||||
"\n## Step 2: Create Parent Policy RuleSet == Failed")
|
||||
return 0
|
||||
ch_uuids.append(child_uuid)
|
||||
par_uuids.append(parent_uuid)
|
||||
# Update One of the Parent with two Child PRSs
|
||||
if self.gbpcfg.gbp_policy_cfg_all(
|
||||
2, 'ruleset', 'par_1_prs', child_policy_rule_sets='"%s %s"' %
|
||||
(ch_uuids[0], ch_uuids[1])) == 0:
|
||||
self._log.info(
|
||||
"\n## Step 3: Update Parent Policy RuleSet == Failed")
|
||||
return 0
|
||||
if self.gbpverify.gbp_obj_ver_attr_all_values(
|
||||
'ruleset', 'par_1_prs', 'child_policy_rule_sets', [
|
||||
ch_uuids[0], ch_uuids[1]]) == 0:
|
||||
self._log.info("\n## Step 3A: Child PRS NOT Found in Parent PRS")
|
||||
return 0
|
||||
# Delete Child PRSs
|
||||
for i in range(2):
|
||||
if self.gbpcfg.gbp_policy_cfg_all(0, 'ruleset', ch_uuids[i]) == 0:
|
||||
self._log.info(
|
||||
"\n## Step 5: Delete of Child PRS child_%s_prs" %
|
||||
(i))
|
||||
return 0
|
||||
if self.gbpverify.gbp_obj_ver_attr_all_values(
|
||||
'ruleset', 'par_1_prs', 'child_policy_rule_sets', [
|
||||
ch_uuids[0], ch_uuids[1]]) != 0:
|
||||
self._log.info(
|
||||
"\n## Step 5A: Stale Child PRS Mapping still persists "
|
||||
"in Parent PRS")
|
||||
return 0
|
||||
self._log.info("\nTESTCASE_GBP_PRS_FUNC_6: PASSED")
|
||||
return 1
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -60,7 +60,7 @@ class test_gbp_l2p_func(object):
|
||||
|
||||
def cleanup(self, tc_name=''):
|
||||
if tc_name != '':
|
||||
self._log.info('Testcase %s: FAILED' % (tc_name))
|
||||
self._log.info('%s: FAILED' % (tc_name))
|
||||
for obj in ['group', 'l2p', 'l3p']:
|
||||
self.gbpcfg.gbp_del_all_anyobj(obj)
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ class test_gbp_l3p_func(object):
|
||||
|
||||
def cleanup(self, tc_name=''):
|
||||
if tc_name != '':
|
||||
self._log.info('Testcase %s: FAILED' % (tc_name))
|
||||
self._log.info('## %s: FAILED' % (tc_name))
|
||||
for obj in ['group', 'l2p', 'l3p']:
|
||||
self.gbpcfg.gbp_del_all_anyobj(obj)
|
||||
|
||||
@@ -287,7 +287,8 @@ class test_gbp_l3p_func(object):
|
||||
"values ##")
|
||||
l3p_uuid = self.gbpcfg.gbp_policy_cfg_all(
|
||||
1, 'l3p', self.l3p_name, ip_pool='20.20.0.0/24',
|
||||
subnet_prefix_length='28')
|
||||
subnet_prefix_length='28',
|
||||
proxy_ip_pool='192.167.0.0/16')
|
||||
if l3p_uuid == 0:
|
||||
self._log.info("\n## Step 1: Create L3Policy == Failed")
|
||||
return 0
|
||||
@@ -297,7 +298,7 @@ class test_gbp_l3p_func(object):
|
||||
if l2p == 0:
|
||||
self._log.info(
|
||||
"\n## New L2Policy Create Failed, hence "
|
||||
"TESTCASE_GBP_L3P_FUNC_3 ABORTED\n")
|
||||
"Testcase_gbp_l3p_func_3 ABORTED\n")
|
||||
return 0
|
||||
elif len(l2p) < 2:
|
||||
self._log.info(
|
||||
@@ -407,7 +408,7 @@ class test_gbp_l3p_func(object):
|
||||
if l2p == 0:
|
||||
self._log.info(
|
||||
"\n## Step 2B:New L2Policy Create Failed, hence "
|
||||
"TESTCASE_GBP_L3P_FUNC_3 ABORTED\n")
|
||||
"Testcase_gbp_l3p_func_4 ABORTED\n")
|
||||
return 0
|
||||
elif len(l2p) < 2:
|
||||
self._log.info(
|
||||
|
||||
@@ -65,7 +65,7 @@ class test_gbp_l3p_neg(object):
|
||||
|
||||
def cleanup(self, tc_name=''):
|
||||
if tc_name != '':
|
||||
self._log.info('Testcase %s: FAILED' % (tc_name))
|
||||
self._log.info('%s: FAILED' % (tc_name))
|
||||
for obj in ['group', 'l2p', 'l3p']:
|
||||
self.gbpcfg.gbp_del_all_anyobj(obj)
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ class test_gbp_nsp_func(object):
|
||||
|
||||
def cleanup(self, tc_name=''):
|
||||
if tc_name != '':
|
||||
self._log.info('Testcase %s: FAILED' % (tc_name))
|
||||
self._log.info('%s: FAILED' % (tc_name))
|
||||
for obj in ['group', 'nsp']:
|
||||
self.gbpcfg.gbp_del_all_anyobj(obj)
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ class test_gbp_pa_func(object):
|
||||
|
||||
def cleanup(self, cfgobj, uuid_name, tc_name=''):
|
||||
if tc_name != '':
|
||||
self._log.info('Testcase %s FAILED' % (tc_name))
|
||||
self._log.info('%s FAILED' % (tc_name))
|
||||
if isinstance(cfgobj, str):
|
||||
cfgobj = [cfgobj]
|
||||
if isinstance(uuid_name, str):
|
||||
@@ -82,7 +82,7 @@ class test_gbp_pa_func(object):
|
||||
"\n###################################################\n"
|
||||
"TESTCASE_GBP_PA_FUNC_1: CREATE/VERIFY/DELETE/VERIFY a "
|
||||
"POLICY ACTION with DEFAULT ATTR VALUE\n"
|
||||
"TEST_STEPS::\n"
|
||||
"TEST_STEPS:\n"
|
||||
"Create Policy Action Object,default params\n"
|
||||
"Verify the attributes & value, show & list cmds\n"
|
||||
"Delete Policy Action using Name\n"
|
||||
|
||||
@@ -67,7 +67,7 @@ class test_gbp_pa_neg(object):
|
||||
|
||||
def cleanup(self, tc_name=''):
|
||||
if tc_name != '':
|
||||
self._log.info('Testcase %s: FAILED' % (tc_name))
|
||||
self._log.info('%s: FAILED' % (tc_name))
|
||||
for obj in ['ruleset', 'rule', 'classifier', 'action']:
|
||||
self.gbpcfg.gbp_del_all_anyobj(obj)
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ class test_gbp_pc_func(object):
|
||||
|
||||
def cleanup(self, tc_name=''):
|
||||
if tc_name != '':
|
||||
self._log.info('Testcase %s: FAILED' % (tc_name))
|
||||
self._log.info('%s: FAILED' % (tc_name))
|
||||
for obj in ['rule', 'classifier', 'action']:
|
||||
self.gbpcfg.gbp_del_all_anyobj(obj)
|
||||
|
||||
@@ -354,7 +354,7 @@ class test_gbp_pc_func(object):
|
||||
"\n## Step 0: Creating a Policy Action needed for this test\n")
|
||||
act_uuid = self.gbpcfg.gbp_policy_cfg_all(1, 'action', self.act_name)
|
||||
if act_uuid == 0:
|
||||
self._log.info("\n## TESTCASE_GBP_PC_FUNC_4: ABORTED\n")
|
||||
self._log.info("\n## Testcase_gbp_pc_func_4: ABORTED\n")
|
||||
os._exit(1)
|
||||
self._log.info(
|
||||
"\n## Step 1: Create and Verify Classifier with valued "
|
||||
|
||||
@@ -68,7 +68,7 @@ class test_gbp_pc_neg(object):
|
||||
|
||||
def cleanup(self, tc_name=''):
|
||||
if tc_name != '':
|
||||
self._log.info('Testcase %s FAILED' % (tc_name))
|
||||
self._log.info('%s FAILED' % (tc_name))
|
||||
for obj in ['classifier']:
|
||||
self.gbpcfg.gbp_del_all_anyobj(obj)
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ class test_gbp_pr_func(object):
|
||||
|
||||
def cleanup(self, tc_name=''):
|
||||
if tc_name != '':
|
||||
self._log.info('Testcase %s: FAILED' % (tc_name))
|
||||
self._log.info('%s: FAILED' % (tc_name))
|
||||
for obj in ['rule', 'classifier', 'action']:
|
||||
self.gbpcfg.gbp_del_all_anyobj(obj)
|
||||
|
||||
@@ -237,14 +237,14 @@ class test_gbp_pr_func(object):
|
||||
if new_cls_uuid == 0:
|
||||
self._log.info(
|
||||
"\nNew Classifier Create Failed, hence "
|
||||
"TESTCASE_GBP_PR_FUNC_3 ABORTED\n")
|
||||
"Testcase_gbp_pr_func_3 ABORTED\n")
|
||||
return 0
|
||||
new_act_uuid = self.gbpcfg.gbp_policy_cfg_all(
|
||||
1, 'action', 'grppol_pa1')
|
||||
if new_act_uuid == 0:
|
||||
self._log.info(
|
||||
"\nNew Action Create Failed, hence "
|
||||
"TESTCASE_GBP_PR_FUNC_3 ABORTED\n")
|
||||
"Testcase_gbp_pr_func_3 ABORTED\n")
|
||||
return 0
|
||||
|
||||
attrib_list = [{'name': 'grppol_pr'}, {'classifier': 'grppol_pc1'}, {
|
||||
@@ -310,14 +310,14 @@ class test_gbp_pr_func(object):
|
||||
if new_cls_uuid == 0:
|
||||
self._log.info(
|
||||
"\nNew Classifier Create Failed, hence "
|
||||
"TESTCASE_GBP_PR_FUNC_3 ABORTED\n")
|
||||
"Testcase_gbp_pr_func_4 ABORTED\n")
|
||||
os._exit(1)
|
||||
new_act_uuid = self.gbpcfg.gbp_policy_cfg_all(
|
||||
1, 'action', 'grppol_pa2')
|
||||
if new_act_uuid == 0:
|
||||
self._log.info(
|
||||
"\nNew Action Create Failed, hence "
|
||||
"TESTCASE_GBP_PR_FUNC_3 ABORTED\n")
|
||||
"Testcase_gbp_pr_func_4 ABORTED\n")
|
||||
os._exit(1)
|
||||
self._log.info(
|
||||
'\n###########################################\n'
|
||||
@@ -389,14 +389,14 @@ class test_gbp_pr_func(object):
|
||||
if new_cls_uuid == 0:
|
||||
self._log.info(
|
||||
"\nNew Classifier Create Failed, hence "
|
||||
"TESTCASE_GBP_PS_FUNC_4 ABORTED\n")
|
||||
"Testcase_gbp_pr_func_5 ABORTED\n")
|
||||
return 0
|
||||
new_act_uuid = self.gbpcfg.gbp_policy_cfg_all(
|
||||
1, 'action', 'grppol_pa1')
|
||||
if new_act_uuid == 0:
|
||||
self._log.info(
|
||||
"\nNew Action Create Failed, hence "
|
||||
"TESTCASE_GBP_PR_FUNC_4 ABORTED\n")
|
||||
"Testcase_gbp_pr_func_5 ABORTED\n")
|
||||
return 0
|
||||
rule_uuid = self.gbpcfg.gbp_policy_cfg_all(
|
||||
1,
|
||||
@@ -486,14 +486,14 @@ class test_gbp_pr_func(object):
|
||||
if new_cls_uuid == 0:
|
||||
self._log.info(
|
||||
"\nNew Classifier Create Failed, hence "
|
||||
"TESTCASE_GBP_PR_FUNC_3 ABORTED\n")
|
||||
"Testcase_gbp_pr_func_6 ABORTED\n")
|
||||
os._exit(1)
|
||||
new_act_uuid = self.gbpcfg.gbp_policy_cfg_all(
|
||||
1, 'action', 'grppol_pa2')
|
||||
if new_act_uuid == 0:
|
||||
self._log.info(
|
||||
"\nNew Action Create Failed, hence "
|
||||
"TESTCASE_GBP_PR_FUNC_3 ABORTED\n")
|
||||
"Testcase_gbp_pr_func_6 ABORTED\n")
|
||||
os._exit(1)
|
||||
rule_uuid = self.gbpcfg.gbp_policy_cfg_all(
|
||||
1, 'rule', self.rule_name, classifier=new_cls_uuid,
|
||||
|
||||
@@ -20,9 +20,6 @@ from libs import verify_libs
|
||||
|
||||
|
||||
def main():
|
||||
print ('For now skipping this entire suite '
|
||||
'TESTCASE_GBP_PR_PC_PA_SHARED_INTEG* ...')
|
||||
sys.exit(1)
|
||||
# Run the Testcases:
|
||||
test = test_gbp_pr_pc_pa_shared_func()
|
||||
if test.test_gbp_pr_pc_pa_shared_func_1() == 0:
|
||||
@@ -35,7 +32,7 @@ def main():
|
||||
test.cleanup(tc_name='TESTCASE_GBP_PR_PC_PA_SHARED_INTEG_4')
|
||||
test.cleanup()
|
||||
utils_libs.report_results('test_gbp_pr_pc_pa_shared_func',
|
||||
'test_results.txt')
|
||||
'test_results_admin.txt')
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
@@ -70,7 +67,7 @@ class test_gbp_pr_pc_pa_shared_func(object):
|
||||
|
||||
def cleanup(self, tc_name=''):
|
||||
if tc_name != '':
|
||||
self._log.info('Testcase %s: FAILED' % (tc_name))
|
||||
self._log.info('%s: FAILED' % (tc_name))
|
||||
for obj in ['rule', 'classifier', 'action']:
|
||||
self.gbpcfg.gbp_del_all_anyobj(obj)
|
||||
|
||||
@@ -160,6 +157,7 @@ class test_gbp_pr_pc_pa_shared_func(object):
|
||||
"# Step 4: Verify Policy Rule with shared=False, Failed")
|
||||
return 0
|
||||
self._log.info("\n## TESTCASE_GBP_PR_PC_PA_SHARED_INTEG_1: PASSED")
|
||||
self.cleanup()
|
||||
return 1
|
||||
|
||||
def test_gbp_pr_pc_pa_shared_func_2(self):
|
||||
@@ -242,7 +240,7 @@ class test_gbp_pr_pc_pa_shared_func(object):
|
||||
"\n## Step 4A: Update the Policy Rule with PC & PA which "
|
||||
"are with shared=False ##")
|
||||
if self.gbpcfg.gbp_policy_cfg_all(
|
||||
1,
|
||||
2,
|
||||
'rule',
|
||||
rule_uuid,
|
||||
classifier=obj_uuid_false['classifier'],
|
||||
@@ -250,7 +248,7 @@ class test_gbp_pr_pc_pa_shared_func(object):
|
||||
self._log.info(
|
||||
"# Step 4A: Updating Policy Rule(shared=True) by attributes "
|
||||
"PA+PC(shared=False) DID NOT Fail")
|
||||
# return 0 ##<< we have a bug for this
|
||||
return 0
|
||||
self._log.info(
|
||||
"\n## Step 4B: Verify the Policy Rule initial attributes "
|
||||
"PA,PC,shared=True ##")
|
||||
@@ -271,7 +269,7 @@ class test_gbp_pr_pc_pa_shared_func(object):
|
||||
"\n## Step 5A: Update the Policy Rule's shared=False along "
|
||||
"with PC+PA(shared=False) ##")
|
||||
if self.gbpcfg.gbp_policy_cfg_all(
|
||||
1,
|
||||
2,
|
||||
'rule',
|
||||
rule_uuid,
|
||||
classifier=obj_uuid_false['classifier'],
|
||||
@@ -297,6 +295,7 @@ class test_gbp_pr_pc_pa_shared_func(object):
|
||||
"# Step 5B: Verify Policy Rule with shared=False, Failed")
|
||||
return 0
|
||||
self._log.info("\n## TESTCASE_GBP_PR_PC_PA_SHARED_INTEG_2: PASSED")
|
||||
self.cleanup()
|
||||
return 1
|
||||
|
||||
def test_gbp_pr_pc_pa_shared_func_3(self):
|
||||
@@ -415,6 +414,7 @@ class test_gbp_pr_pc_pa_shared_func(object):
|
||||
"# Step 4B: Verify Policy Rule with shared=True, Failed")
|
||||
return 0
|
||||
self._log.info("\n## TESTCASE_GBP_PR_PC_PA_SHARED_INTEG_3: PASSED")
|
||||
self.cleanup()
|
||||
return 1
|
||||
|
||||
def test_gbp_pr_pc_pa_shared_func_4(self):
|
||||
@@ -519,17 +519,17 @@ class test_gbp_pr_pc_pa_shared_func(object):
|
||||
# Update Policy Action and Classifier with shared=False and verify it
|
||||
# failed to upudate
|
||||
self._log.info(
|
||||
"\n## Step 5A: Update the Policy Action with shared=True\n")
|
||||
"\n## Step 5A: Update the Policy Action with shared=False\n")
|
||||
if self.gbpcfg.gbp_policy_cfg_all(
|
||||
2, 'action', self.act_uuid, shared=False) != 0:
|
||||
self._log.info(
|
||||
"# Step 5A: Update of Policy Action shared=Failed "
|
||||
"# Step 5A: Update of Policy Action shared=False "
|
||||
"DID NOT Fail")
|
||||
return 0
|
||||
self._log.info(
|
||||
"\n## Step 5B: Update the Policy Classifer with shared=True\n")
|
||||
"\n## Step 5B: Update the Policy Classifer with shared=False\n")
|
||||
if self.gbpcfg.gbp_policy_cfg_all(
|
||||
2, 'classifier', self.cls_uuid, shared=False) == 0:
|
||||
2, 'classifier', self.cls_uuid, shared=False) != 0:
|
||||
self._log.info(
|
||||
"# Step 5B: Update of Policy Classifier shared=False "
|
||||
"DID NOT Fail")
|
||||
@@ -539,15 +539,16 @@ class test_gbp_pr_pc_pa_shared_func(object):
|
||||
1, 'action', self.act_uuid, shared='True') == 0:
|
||||
self._log.info(
|
||||
"# Step 6: Policy Action verify shows that shared "
|
||||
"attribute has become False")
|
||||
"attribute changed to False")
|
||||
return 0
|
||||
if self.gbpverify.gbp_policy_verify_all(
|
||||
1, 'classifier', self.cls_uuid, shared='True') == 0:
|
||||
self._log.info(
|
||||
"# Step 6: Policy Classifier verify shows that shared "
|
||||
"attribute become False")
|
||||
"attribute changed to False")
|
||||
return 0
|
||||
self._log.info("\n## TESTCASE_GBP_PR_PC_PA_SHARED_INTEG_4: PASSED")
|
||||
self.cleanup()
|
||||
return 1
|
||||
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ class test_gbp_prs_func(object):
|
||||
|
||||
def cleanup(self, tc_name=''):
|
||||
if tc_name != '':
|
||||
self._log.info('Testcase %s: FAILED' % (tc_name))
|
||||
self._log.info('%s: FAILED' % (tc_name))
|
||||
for obj in ['ruleset', 'rule', 'classifier', 'action']:
|
||||
self.gbpcfg.gbp_del_all_anyobj(obj)
|
||||
|
||||
@@ -247,14 +247,14 @@ class test_gbp_prs_func(object):
|
||||
if new_cls_uuid == 0:
|
||||
self._log.info(
|
||||
"\nNew Classifier Create Failed, hence "
|
||||
"TESTCASE_GBP_PRS_FUNC_3 ABORTED\n")
|
||||
"testcase_gbp_prs_func_3 ABORTED\n")
|
||||
return 0
|
||||
new_act_uuid = self.gbpcfg.gbp_policy_cfg_all(
|
||||
1, 'action', 'grppol_pa1')
|
||||
if new_act_uuid == 0:
|
||||
self._log.info(
|
||||
"\nNew Action Create Failed, hence "
|
||||
"TESTCASE_GBP_PRS_FUNC_3 ABORTED\n")
|
||||
"testcase_gbp_prs_func_3 ABORTED\n")
|
||||
return 0
|
||||
new_rule_uuid = self.gbpcfg.gbp_policy_cfg_all(
|
||||
1,
|
||||
@@ -266,7 +266,7 @@ class test_gbp_prs_func(object):
|
||||
if new_rule_uuid == 0:
|
||||
self._log.info(
|
||||
"\nNew Rule Create Failed, hence "
|
||||
"TESTCASE_GBP_PRS_FUNC_3 ABORTED\n")
|
||||
"testcase_gbp_prs_func_3 ABORTED\n")
|
||||
return 0
|
||||
if self.gbpcfg.gbp_policy_cfg_all(
|
||||
2,
|
||||
@@ -327,14 +327,14 @@ class test_gbp_prs_func(object):
|
||||
if new_cls_uuid == 0:
|
||||
self._log.info(
|
||||
"\nNew Classifier Create Failed, hence "
|
||||
"TESTCASE_GBP_PRS_FUNC_4 ABORTED\n")
|
||||
"testcase_gbp_prs_func_4 ABORTED\n")
|
||||
return 0
|
||||
new_act_uuid = self.gbpcfg.gbp_policy_cfg_all(
|
||||
1, 'action', 'grppol_pa1')
|
||||
if new_act_uuid == 0:
|
||||
self._log.info(
|
||||
"\nNew Action Create Failed, hence "
|
||||
"TESTCASE_GBP_PRS_FUNC_4 ABORTED\n")
|
||||
"testcase_gbp_prs_func_4 ABORTED\n")
|
||||
return 0
|
||||
rule_uuid_list = []
|
||||
for i in range(4):
|
||||
@@ -349,7 +349,7 @@ class test_gbp_prs_func(object):
|
||||
if new_rule_uuid == 0:
|
||||
self._log.info(
|
||||
"\nNew Rule Create Failed, hence "
|
||||
"TESTCASE_GBP_PRS_FUNC_4 ABORTED\n")
|
||||
"testcase_gbp_prs_func_4 ABORTED\n")
|
||||
return 0
|
||||
rule_uuid_list.append(new_rule_uuid)
|
||||
ruleset_uuid = self.gbpcfg.gbp_policy_cfg_all(
|
||||
|
||||
@@ -90,7 +90,7 @@ class test_gbp_prs_neg(object):
|
||||
|
||||
def cleanup(self, tc_name=''):
|
||||
if tc_name != '':
|
||||
self._log.info('Testcase %s: FAILED' % (tc_name))
|
||||
self._log.info('%s: FAILED' % (tc_name))
|
||||
for obj in ['ruleset', 'rule', 'classifier', 'action']:
|
||||
self.gbpcfg.gbp_del_all_anyobj(obj)
|
||||
|
||||
|
||||
@@ -20,8 +20,6 @@ from libs import verify_libs
|
||||
|
||||
|
||||
def main():
|
||||
print('For now skipping this entire suite ..')
|
||||
sys.exit(1)
|
||||
# Run the Testcases:
|
||||
test = test_gbp_prs_pr_shared_func()
|
||||
if test.test_gbp_prs_pr_shared_func_1() == 0:
|
||||
@@ -30,7 +28,7 @@ def main():
|
||||
test.cleanup(tc_name='TESTCASE_GBP_PRS_PR_SHARED_INTEG_2')
|
||||
test.cleanup()
|
||||
utils_libs.report_results('test_gbp_prs_pr_shared_func',
|
||||
'test_results.txt')
|
||||
'test_results_admin.txt')
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
@@ -65,7 +63,7 @@ class test_gbp_prs_pr_shared_func(object):
|
||||
|
||||
def cleanup(self, tc_name=''):
|
||||
if tc_name != '':
|
||||
self._log.info('Testcase %s: FAILED' % (tc_name))
|
||||
self._log.info('%s: FAILED' % (tc_name))
|
||||
for obj in ['ruleset', 'rule', 'classifier', 'action']:
|
||||
self.gbpcfg.gbp_del_all_anyobj(obj)
|
||||
|
||||
@@ -95,14 +93,14 @@ class test_gbp_prs_pr_shared_func(object):
|
||||
if new_cls_uuid == 0:
|
||||
self._log.info(
|
||||
"\nNew Classifier Create Failed, hence "
|
||||
"TESTCASE_GBP_PRS_PR_SHARED_INTEG_4 ABORTED\n")
|
||||
"Testcase_gbp_prs_pr_shared_integ_1 ABORTED\n")
|
||||
return 0
|
||||
new_act_uuid = self.gbpcfg.gbp_policy_cfg_all(
|
||||
1, 'action', 'grppol_pa1', shared='True')
|
||||
if new_act_uuid == 0:
|
||||
self._log.info(
|
||||
"\nNew Action Create Failed, hence "
|
||||
"TESTCASE_GBP_PRS_PR_SHARED_INTEG_4 ABORTED\n")
|
||||
"testcase_gbp_prs_pr_shared_integ_1 ABORTED\n")
|
||||
return 0
|
||||
rule_uuid_list = []
|
||||
for i in range(4):
|
||||
@@ -118,7 +116,7 @@ class test_gbp_prs_pr_shared_func(object):
|
||||
if new_rule_uuid == 0:
|
||||
self._log.info(
|
||||
"\nNew Rule Create Failed, hence "
|
||||
"TESTCASE_GBP_PRS_PR_SHARED_INTEG_4 ABORTED\n")
|
||||
"testcase_gbp_prs_pr_shared_integ_1 ABORTED\n")
|
||||
return 0
|
||||
rule_uuid_list.append(new_rule_uuid)
|
||||
ruleset_uuid = self.gbpcfg.gbp_policy_cfg_all(
|
||||
@@ -156,7 +154,8 @@ class test_gbp_prs_pr_shared_func(object):
|
||||
"# Step 2C: Verify Policy RuleSet and its "
|
||||
"Multiple PRs using -show option == Failed")
|
||||
return 0
|
||||
# Update the Policy RuleSet with shared=True and update should fail
|
||||
# Update the Policy RuleSet with shared=True and
|
||||
# update MUST fail as it is not supported by RMD
|
||||
if self.gbpcfg.gbp_policy_cfg_all(
|
||||
2, 'ruleset', 'grppol_prs_many', shared='True') != 0:
|
||||
self._log.info(
|
||||
@@ -165,7 +164,7 @@ class test_gbp_prs_pr_shared_func(object):
|
||||
return 0
|
||||
if self.gbpverify.gbp_obj_ver_attr_all_values(
|
||||
'ruleset', 'grppol_prs_many', 'policy_rules',
|
||||
rule_uuid_list) != 0:
|
||||
rule_uuid_list) == 0:
|
||||
self._log.info(
|
||||
"# Step 3A: Verify Policy RuleSet and its "
|
||||
"Multiple PRs, == Failed")
|
||||
@@ -181,8 +180,8 @@ class test_gbp_prs_pr_shared_func(object):
|
||||
"# Step 3B: Verify Policy RuleSet and its "
|
||||
"shared=False, == Failed")
|
||||
return 0
|
||||
|
||||
self._log.info("\nTESTCASE_GBP_PRS_PR_SHARED_INTEG_1: PASSED")
|
||||
self.cleanup()
|
||||
return 1
|
||||
|
||||
def test_gbp_prs_pr_shared_func_2(self):
|
||||
@@ -213,14 +212,14 @@ class test_gbp_prs_pr_shared_func(object):
|
||||
if new_cls_uuid == 0:
|
||||
self._log.info(
|
||||
"\nNew Classifier Create Failed, hence "
|
||||
"TESTCASE_GBP_PRS_PR_SHARED_INTEG_4 ABORTED\n")
|
||||
"testcase_gbp_prs_pr_shared_integ_2 ABORTED\n")
|
||||
return 0
|
||||
new_act_uuid = self.gbpcfg.gbp_policy_cfg_all(
|
||||
1, 'action', 'grppol_pa1', shared='True')
|
||||
if new_act_uuid == 0:
|
||||
self._log.info(
|
||||
"\nNew Action Create Failed, hence "
|
||||
"TESTCASE_GBP_PRS_PR_SHARED_INTEG_4 ABORTED\n")
|
||||
"testcase_gbp_prs_pr_shared_integ_2 ABORTED\n")
|
||||
return 0
|
||||
rule_uuid_list = []
|
||||
shared_flag = ['True', 'False', 'True', 'False']
|
||||
@@ -237,7 +236,7 @@ class test_gbp_prs_pr_shared_func(object):
|
||||
if new_rule_uuid == 0:
|
||||
self._log.info(
|
||||
"\nNew Rule Create Failed, hence "
|
||||
"TESTCASE_GBP_PRS_PR_SHARED_INTEG_4 ABORTED\n")
|
||||
"testcase_gbp_prs_pr_shared_integ_2 ABORTED\n")
|
||||
return 0
|
||||
rule_uuid_list.append(new_rule_uuid)
|
||||
ruleset_uuid = self.gbpcfg.gbp_policy_cfg_all(
|
||||
@@ -278,14 +277,14 @@ class test_gbp_prs_pr_shared_func(object):
|
||||
# Update and Verify the PRS by updating the PRs(removing few existing
|
||||
# ones)
|
||||
if self.gbpcfg.gbp_policy_cfg_all(
|
||||
2, 'ruleset', 'grppol_prs_many', shared='True') == 0:
|
||||
2, 'ruleset', 'grppol_prs_many', shared='True') != 0:
|
||||
self._log.info(
|
||||
"# Step 3: Updating Policy RuleSet's"
|
||||
" Attribute shared=True , Failed")
|
||||
" Attribute shared=True did NOT fail")
|
||||
return 0
|
||||
if self.gbpverify.gbp_obj_ver_attr_all_values(
|
||||
'ruleset', 'grppol_prs_many', 'policy_rules',
|
||||
rule_uuid_list) != 0:
|
||||
rule_uuid_list) == 0:
|
||||
self._log.info(
|
||||
"# Step 3A: Verify Policy RuleSet and its "
|
||||
"Multiple PRs using -show option == Failed")
|
||||
@@ -296,10 +295,10 @@ class test_gbp_prs_pr_shared_func(object):
|
||||
ruleset_uuid,
|
||||
name='grppol_prs_many',
|
||||
description='For devstack demo',
|
||||
shared='True') == 0:
|
||||
shared='False') == 0:
|
||||
self._log.info(
|
||||
"# Step 3B: Verify Policy RuleSet and its "
|
||||
"shared=True, == Failed")
|
||||
"shared=False, == Failed")
|
||||
return 0
|
||||
|
||||
self._log.info("\nTESTCASE_GBP_PRS_PR_SHARED_INTEG_2: PASSED")
|
||||
|
||||
@@ -125,7 +125,7 @@ class test_gbp_ptg_func(object):
|
||||
|
||||
def cleanup(self, tc_name=''):
|
||||
if tc_name != '':
|
||||
self._log.info('Testcase %s: FAILED' % (tc_name))
|
||||
self._log.info('%s: FAILED' % (tc_name))
|
||||
for obj in [
|
||||
'target',
|
||||
'group',
|
||||
@@ -245,7 +245,7 @@ class test_gbp_ptg_func(object):
|
||||
"\n## Step 2G: Implicit-creation of Neutron "
|
||||
"Router-Obj == Failed")
|
||||
return 0
|
||||
## Delete and Verify
|
||||
# Delete and Verify
|
||||
if rep_del == 0 or rep_del > 0:
|
||||
self._log.info('\n## Step 3: Delete Target-Group using name ##\n')
|
||||
if self.gbpcfg.gbp_policy_cfg_all(0, 'group', ptg_uuid) == 0:
|
||||
@@ -343,7 +343,7 @@ class test_gbp_ptg_func(object):
|
||||
if new_prs_uuid == 0:
|
||||
self._log.info(
|
||||
"\n## Step 4: Reqd Policy Target-Group Create Failed, "
|
||||
"hence TESTCASE_GBP_PTG_FUNC_2 Run ABORTED\n ")
|
||||
"hence Testcase_gbp_ptg_func_2 Run ABORTED\n ")
|
||||
return 0
|
||||
if self.gbpcfg.gbp_policy_cfg_all(
|
||||
2,
|
||||
|
||||
@@ -20,10 +20,16 @@ GBP_FUNC_DIR=$GBP_DIR/gbpservice/tests/contrib/gbpfunctests
|
||||
echo "Running gbpfunc test suite"
|
||||
export PYTHONPATH="$GBP_FUNC_DIR:${PYTHONPATH}"
|
||||
cd $GBP_FUNC_DIR/testcases
|
||||
python suite_run.py upstream
|
||||
gbpfunc_exit_code=$?
|
||||
# Run shared_resource tests as admin cred
|
||||
source_creds $TOP_DIR/openrc admin admin
|
||||
python suite_admin_run.py
|
||||
gbpfunc_admin_exit_code=$?
|
||||
# Run rest of the tests as non-admin cred
|
||||
source_creds $TOP_DIR/openrc demo demo
|
||||
python suite_non_admin_run.py upstream
|
||||
gbpfunc_non_admin_exit_code=$?
|
||||
|
||||
# Prepare the log files for Jenkins to upload
|
||||
prepare_logs
|
||||
|
||||
exit $(($exercises_exit_code+$gbpfunc_exit_code))
|
||||
exit $(($exercises_exit_code+$gbpfunc_admin_exit_code+$gbpfunc_non_admin_exit_code))
|
||||
|
||||
Reference in New Issue
Block a user