From dd61967c22d9064f037dafad9bccb69b9eeda774 Mon Sep 17 00:00:00 2001 From: Harry Huang Date: Fri, 9 Mar 2018 11:28:18 +0800 Subject: Update for resiliency improvements [WIP] JIRA: AUTO-13 On behalf of Gerard Damm to commit his codes. Temporarily keep resiliency test case under auto/testcase/resiliency. Change-Id: Iafcb74177673afc3f84f0797ebd93b02852d120d Signed-off-by: Harry Huang --- auto/testcase/resiliency/AutoResilIftCloud.py | 30 +++++- auto/testcase/resiliency/AutoResilItfOS.py | 29 +++++- auto/testcase/resiliency/AutoResilItfVNFMNFVO.py | 29 +++++- auto/testcase/resiliency/AutoResilMain.py | 119 +++++++++++++++++++++-- auto/testcase/resiliency/AutoResilMgTestDef.py | 47 ++++++--- auto/testcase/resiliency/AutoResilRunTest.py | 47 ++++++++- 6 files changed, 267 insertions(+), 34 deletions(-) diff --git a/auto/testcase/resiliency/AutoResilIftCloud.py b/auto/testcase/resiliency/AutoResilIftCloud.py index bc4d983..bca8b95 100644 --- a/auto/testcase/resiliency/AutoResilIftCloud.py +++ b/auto/testcase/resiliency/AutoResilIftCloud.py @@ -1,11 +1,35 @@ #!/usr/bin/env python3 +# ===============LICENSE_START======================================================= +# Apache-2.0 +# =================================================================================== +# Copyright (C) 2018 Wipro. All rights reserved. +# =================================================================================== +# +# 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. +# ===============LICENSE_END========================================================= + + # OPNFV Auto project # https://wiki.opnfv.org/pages/viewpage.action?pageId=12389095 -# (c) by Gerard Damm (Wipro) -# Use case group: Resilience Improvements -# this module: interfaces with cloud managers (OpenStack, Kubernetes, AWS, ...) +# Use case 02: Resilience Improvements +# Use Case description: https://wiki.opnfv.org/display/AUTO/Auto+Use+Cases +# Test case design: https://wiki.opnfv.org/display/AUTO/Use+case+2+%28Resilience+Improvements+through+ONAP%29+analysis + +# This module: interfaces with cloud managers (OpenStack, Kubernetes, AWS, ...) + + def f1(): return 0 diff --git a/auto/testcase/resiliency/AutoResilItfOS.py b/auto/testcase/resiliency/AutoResilItfOS.py index 864f680..2fc6c85 100644 --- a/auto/testcase/resiliency/AutoResilItfOS.py +++ b/auto/testcase/resiliency/AutoResilItfOS.py @@ -1,11 +1,34 @@ #!/usr/bin/env python3 +# ===============LICENSE_START======================================================= +# Apache-2.0 +# =================================================================================== +# Copyright (C) 2018 Wipro. All rights reserved. +# =================================================================================== +# +# 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. +# ===============LICENSE_END========================================================= + + # OPNFV Auto project # https://wiki.opnfv.org/pages/viewpage.action?pageId=12389095 -# (c) by Gerard Damm (Wipro) -# Use case group: Resilience Improvements -# this module: interfaces with OS, or servers +# Use case 02: Resilience Improvements +# Use Case description: https://wiki.opnfv.org/display/AUTO/Auto+Use+Cases +# Test case design: https://wiki.opnfv.org/display/AUTO/Use+case+2+%28Resilience+Improvements+through+ONAP%29+analysis + +# This module: interfaces with OS, or servers + def f1(): return 0 diff --git a/auto/testcase/resiliency/AutoResilItfVNFMNFVO.py b/auto/testcase/resiliency/AutoResilItfVNFMNFVO.py index 6e66e63..b6b1745 100644 --- a/auto/testcase/resiliency/AutoResilItfVNFMNFVO.py +++ b/auto/testcase/resiliency/AutoResilItfVNFMNFVO.py @@ -1,13 +1,36 @@ #!/usr/bin/env python3 +# ===============LICENSE_START======================================================= +# Apache-2.0 +# =================================================================================== +# Copyright (C) 2018 Wipro. All rights reserved. +# =================================================================================== +# +# 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. +# ===============LICENSE_END========================================================= + + # OPNFV Auto project # https://wiki.opnfv.org/pages/viewpage.action?pageId=12389095 -# (c) by Gerard Damm (Wipro) -# Use case group: Resilience Improvements -# this module: interfaces with VNF/NVF managers (focus on ONAP) +# Use case 02: Resilience Improvements +# Use Case description: https://wiki.opnfv.org/display/AUTO/Auto+Use+Cases +# Test case design: https://wiki.opnfv.org/display/AUTO/Use+case+2+%28Resilience+Improvements+through+ONAP%29+analysis + +# This module: interfaces with VNF/NVF managers (focus on ONAP) # entities that manage VNFs and orchestrates services (VNF-M and NFV-O) + def f1(): return 0 diff --git a/auto/testcase/resiliency/AutoResilMain.py b/auto/testcase/resiliency/AutoResilMain.py index 7ebb182..a69e777 100644 --- a/auto/testcase/resiliency/AutoResilMain.py +++ b/auto/testcase/resiliency/AutoResilMain.py @@ -1,32 +1,133 @@ #!/usr/bin/env python3 +# ===============LICENSE_START======================================================= +# Apache-2.0 +# =================================================================================== +# Copyright (C) 2018 Wipro. All rights reserved. +# =================================================================================== +# +# 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. +# ===============LICENSE_END========================================================= + + # OPNFV Auto project # https://wiki.opnfv.org/pages/viewpage.action?pageId=12389095 -# (c) by Gerard Damm (Wipro) -# Use case group: Resilience Improvements -# this module: main program +# Use case 02: Resilience Improvements +# Use Case description: https://wiki.opnfv.org/display/AUTO/Auto+Use+Cases +# Test case design: https://wiki.opnfv.org/display/AUTO/Use+case+2+%28Resilience+Improvements+through+ONAP%29+analysis + +# This module: main program +# data initialization +# interactive CLI user menu: +# 1) select a test definition to run +# 2) view definition of selected test (pull all data from definition files) +# 3) start test +# 4) exit + #docstring +""" This is the main module for OPNFV Auto Test Data for Use Case 2: Resilience Improvements Through ONAP. +Auto project: https://wiki.opnfv.org/pages/viewpage.action?pageId=12389095 """ -This is the main module for OPNFV Auto Test Data for Use Caes 2: Resilience Improvements Through ONAP. -""" + + + ###################################################################### # import statements from AutoResilMgTestDef import * # Constants -PROJECT = "Auto" -USE_CASE_GROUP = "Resilience Improvements Through ONAP" +PROJECT_NAME = "Auto" +USE_CASE_NAME = "Resilience Improvements Through ONAP" + + +###################################################################### + +def show_menu(selected_test_def_ID): + print("Project ", PROJECT_NAME, ", Use Case: ",USE_CASE_NAME) + if selected_test_def_ID>0 : + print("Current test Definition ID: ",selected_test_def_ID) + else: + print("Current test Definition ID: (none)") + print("1: select Test Definition ID") + print("2: view current Test Definition details") + print("3: start an execution of current Test Definition") + print("4: exit") + + +def get_menu_choice(): + + while True: + try: + user_choice = int(input(" Choice: ")) + except ValueError: + print("Invalid choice (must be an integer). Try again.") + continue + if user_choice < 1 or user_choice > 4: + print("Invalid choice (must be between 1 and 4). Try again.") + continue + else: + return user_choice + + +def get_test_def_ID(): + + while True: + try: + user_test_def_ID = int(input(" Test Definition ID: ")) + except ValueError: + print("Invalid choice (must be an integer). Try again.") + continue + + test_defs = read_list_bin(FILE_TEST_DEFINITIONS) + if (test_defs == None) or (test_defs==[]): + print("Problem with test definition file: empty") + sys.exit() + + if index_already_there(user_test_def_ID, test_defs): + return user_test_def_ID + else: + print("Invalid choice (Test Definition ID ",user_test_def_ID," does not exist). Try again.") + continue + ###################################################################### def main(): - print(get_test_case(5)) + # TODO: run initializations to refresh data and make sure files are here + + selected_test_def_ID = -1 + + while True: + + show_menu(selected_test_def_ID) + user_choice = get_menu_choice() + #print("user_choice:",user_choice) #test + + if user_choice == 1: + selected_test_def_ID = get_test_def_ID() + + if user_choice == 4: + sys.exit() + + print(get_indexed_item_from_file(selected_test_def_ID,FILE_TEST_DEFINTIONS)) + + print(get_indexed_item_from_file(5,FILE_TEST_CASES)) - print("End of Main\n Project: \t\t", PROJECT, "\n Use Case Group:\t",USE_CASE_GROUP) + print("End of Main\n Project: \t\t", PROJECT_NAME, "\n Use Case:\t",USE_CASE_NAME) if __name__ == "__main__": main() diff --git a/auto/testcase/resiliency/AutoResilMgTestDef.py b/auto/testcase/resiliency/AutoResilMgTestDef.py index 4df942e..cc3d0ef 100644 --- a/auto/testcase/resiliency/AutoResilMgTestDef.py +++ b/auto/testcase/resiliency/AutoResilMgTestDef.py @@ -1,13 +1,35 @@ #!/usr/bin/env python3 +# ===============LICENSE_START======================================================= +# Apache-2.0 +# =================================================================================== +# Copyright (C) 2018 Wipro. All rights reserved. +# =================================================================================== +# +# 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. +# ===============LICENSE_END========================================================= + + # OPNFV Auto project # https://wiki.opnfv.org/pages/viewpage.action?pageId=12389095 -# (c) by Gerard Damm (Wipro) -# Use case group: Resilience Improvements -# this module: management of test definitions +# Use case 02: Resilience Improvements +# Use Case description: https://wiki.opnfv.org/display/AUTO/Auto+Use+Cases +# Test case design: https://wiki.opnfv.org/display/AUTO/Use+case+2+%28Resilience+Improvements+through+ONAP%29+analysis -# Functions to View/Edit/Delete: +# This module: management of test definitions + +# Functions and classes to manage and initialize test data relative to: # physical resources # cloud resources # VNFs @@ -15,8 +37,8 @@ # challenge definitions # optional metrics # test definitions -# Functions to Initialize Data (initial storage population) -# Implicit Data Model, with classes +# Storage of definition data in binary files (pickle), and test data results in .CSV files + #docstring """This module contains functions and classes to manage OPNFV Auto Test Data for Use Case 2: Resilience Improvements Through ONAP. @@ -42,8 +64,8 @@ FILE_METRIC_DEFINITIONS = "DefinitionsMetrics.bin" FILE_CHALLENGE_DEFINITIONS = "DefinitionsChallenges.bin" FILE_TEST_DEFINITIONS = "DefinitionsTests.bin" -###################################################################### +###################################################################### def read_list_bin(file_name): """Generic function to extract a list from a binary file.""" @@ -229,7 +251,7 @@ class TestDefinition(AutoBaseObject): """Test Definition class for Auto project.""" def __init__ (self, test_def_ID, test_def_name, test_def_challengeDefID, - test_def_useCaseID, + test_def_testCaseID, test_def_VNFIDs, test_def_associatedMetricsIDs, test_def_recipientIDs, @@ -243,8 +265,8 @@ class TestDefinition(AutoBaseObject): # associated Challenge Definition (ID) self.challenge_def_ID = test_def_challengeDefID - # associated Use Case (ID) - self.use_case_ID = test_def_useCaseID + # associated Test Case (ID) + self.test_case_ID = test_def_testCaseID # associated VNFs (list of IDs) self.VNF_ID_list = test_def_VNFIDs # associated Metrics (list of IDs) @@ -265,7 +287,7 @@ def init_test_definitions(): test_def_ID = 1 test_def_name = "VM failure impact on virtual firewall (vFW VNF)" test_def_challengeDefID = 1 - test_def_useCaseID = 5 + test_def_testCaseID = 5 test_def_VNFIDs = [1] test_def_associatedMetricsIDs = [] test_def_recipientIDs = [2] @@ -273,14 +295,13 @@ def init_test_definitions(): test_def_testAPICommandSent = ["data1","data2"] test_definitions.append(TestDefinition(test_def_ID, test_def_name, test_def_challengeDefID, - test_def_useCaseID, + test_def_testCaseID, test_def_VNFIDs, test_def_associatedMetricsIDs, test_def_recipientIDs, test_def_testCLICommandSent, test_def_testAPICommandSent)) - # write list to binary file write_list_bin(test_definitions, FILE_TEST_DEFINITIONS) diff --git a/auto/testcase/resiliency/AutoResilRunTest.py b/auto/testcase/resiliency/AutoResilRunTest.py index ab390cc..2ceba40 100644 --- a/auto/testcase/resiliency/AutoResilRunTest.py +++ b/auto/testcase/resiliency/AutoResilRunTest.py @@ -1,11 +1,52 @@ #!/usr/bin/env python3 +# ===============LICENSE_START======================================================= +# Apache-2.0 +# =================================================================================== +# Copyright (C) 2018 Wipro. All rights reserved. +# =================================================================================== +# +# 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. +# ===============LICENSE_END========================================================= + + # OPNFV Auto project # https://wiki.opnfv.org/pages/viewpage.action?pageId=12389095 -# (c) by Gerard Damm (Wipro) -# Use case group: Resilience Improvements -# this module: execution of tests +# Use case 02: Resilience Improvements +# Use Case description: https://wiki.opnfv.org/display/AUTO/Auto+Use+Cases +# Test case design: https://wiki.opnfv.org/display/AUTO/Use+case+2+%28Resilience+Improvements+through+ONAP%29+analysis + +# This module: execution of tests +# (might merge this module with Main module) +## Receive/retrieve chosen test def info +##pre-test (pings, etc.) +##launch test: +## create execution instances of Test and Challenge +## simulate challenge +## get time T1 +## loop: +## wait for VNF recovery +## optional other metrics +## store data and logs +## get time T2 +## stop challenge +## reset (with ONAP MSO) +## store data and logs +##post-tests +##logs + + def f1(): return 0 -- cgit 1.2.3-korg