def add_application(self, app): """ Add application Args: app: name of app """ view = navigate_to(self, "ApplicationsPage") view.add_application_button.click() env = conf.get_config("env") fs = FTPClientWrapper(env.ftpserver.entities.mta) # Download application file to analyze file_path = fs.download(app) view.upload_file.fill(file_path) view.done_button.click() # Save Configuration view = navigate_to(self, "AllProject") analysis_configuration = AnalysisConfiguration(self.application, self.project_name) # Bug WINDUP-2995 analysis_configuration.save_and_run_configuration() # wait for analysis to finish view = self.create_view(AnalysisResultsView) view.wait_displayed("60s") assert view.is_displayed wait_for(lambda: view.analysis_results.in_progress(), delay=0.2, timeout=450) wait_for(lambda: view.analysis_results.is_analysis_complete(), delay=0.2, timeout=450) assert view.analysis_results.is_analysis_complete()
def test_total_global_system_rule(mta_app, request): """Test to upload global custom rules file Polarion: assignee: ghubale initialEstimate: 1/12h caseimportance: medium testSteps: 1. Navigate to Global > Rules configuration > System rules 2. Check show all rules expectedResults: 1. Total system rules count should be 331 """ @request.addfinalizer def _finalize(): # Reset view else the URL does not change view.logout() global_configurations = SystemRulesConfiguration(mta_app) view = navigate_to(global_configurations, "SystemRule") view.show_all_rules.wait_displayed("30s") no_of_rules_before = view.paginator.total_items view.show_all_rules.click() assert view.paginator.total_items >= no_of_rules_before
def test_project_crud(application): project_name = fauxfactory.gen_alphanumeric(12, start="project_") project_collection = application.collections.projects # TO DO paramterize the test later for file_name and trans_path, hardcoding for now project = project_collection.create( name=project_name, description=fauxfactory.gen_alphanumeric(start="desc_"), app_list=["acmeair-webapp-1.0-SNAPSHOT.war"], transformation_path="Containerization", ) assert project.exists # Edit Project with no change , clicks cancel project.update({"name": project_name}) assert project.name == project_name # Edit Project with new desc and save updated_name = fauxfactory.gen_alphanumeric(12, start="edited_") update_descr = "my edited description" with update(project): project.name = updated_name project.description = update_descr assert project.exists view = navigate_to(project.parent, "All") # check name and description both updated on UI or not proj = view.projects.get_project(project.name) assert proj.name == updated_name assert proj.description == update_descr # Delete project project.delete() assert not project.exists
def clear_filters(self): """Method to clear all the system filters""" view = navigate_to(self, "SystemRule") view.wait_displayed() if view.clear.is_displayed: view.clear.click()
def upload_custom_rule_file(self, server_path=False, scan_recursive=False): """Method for uploading custom rule file server_path: if True then upload rule file by server path scan_recursive: If True and the given path is a directory, the subdirectories will also be scanned for rule sets """ view = navigate_to(self, "Add") if server_path: # upload custom rules by providing server path to folder of rule files env = conf.get_config("env") fs1 = FTPClientWrapper(env.ftpserver.entities.mta) file_path = fs1.download(self.file_name) rules_path = file_path.split(self.file_name)[0] view.server_path.click() view.server_path.rules_path.fill(rules_path) if scan_recursive: view.server_path.scan_recursive.click() view.server_path.save_button.click() else: # upload custom rules by browsing rule files env = conf.get_config("env") fs1 = FTPClientWrapper(env.ftpserver.entities.mta) file_path = fs1.download(self.file_name) view.upload_rule.fill(file_path) wait_for(lambda: view.browser.is_displayed(view.file_uploaded), delay=10, timeout=60) view.close_button.click()
def test_filter_global_system_rule(application): """ Test to upload global_1 custom rules file Polarion: assignee: ghubale initialEstimate: 1/12h caseimportance: medium testSteps: 1. Navigate to Global > Rules configuration > System rules 2. Check show all rules expectedResults: 1. Total system rules count should be 331 """ filters = { "Source": ["agroal", "amazon", "avro"], # "Target": ["camel", "cloud-readiness", "quarkus"], # TODO(ghubale): Uncomment it once fixed drop down selection for option - Target } global_configurations = SystemRulesConfiguration(application) view = navigate_to(global_configurations, "SystemRule") view.show_all_rules.wait_displayed("30s") view.show_all_rules.click() for filter_type in filters: for filter_value in filters[filter_type]: global_configurations.search_system_rules( search_value=filter_value, filter_type=filter_type, clear_filters=True) filtered_rules = view.table.read() for rule in filtered_rules: assert filter_value in rule[filter_type]
def test_analysis_global_custom_rule(application, add_global_custom_rule, create_minimal_project): """ Test to upload global_1 custom rules file Polarion: assignee: ghubale initialEstimate: 1/12h caseimportance: medium testSteps: 1. Upload global_1 custom rule file 2. Create project and run analysis 3. Go to analysis details page and check if custom rules contains global_1 scope custom rule file expectedResults: 1. Analysis should be completed successfully 2. Global custom rule should be applied/fired in the analysis report """ file_name, view, rules_configurations = add_global_custom_rule project, project_collection = create_minimal_project analysis_results = AnalysisResults(application, project.name) view = navigate_to(analysis_results, "AnalysisDetailsPage") view.custom_rules.wait_displayed("20s") card_info = view.custom_rules.read() assert file_name in card_info["body"].split("Global")[1] view.execution_link.click() view = analysis_results.create_view(AnalysisResultsView) view.wait_displayed("30s") view.analysis_results.show_report() view = analysis_results.create_view(AllApplicationsView) view.application_table.application_details( "acmeair-webapp-1.0-SNAPSHOT.war") view.tabs.issues.click() view = analysis_results.create_view(Issues) # TODO(ghubale): Updated test case with reading Migration potential table assert view.wait_displayed
def test_delete_application(application): """ Test01 -08 Delete uploaded application file and check if next button gets disabled """ project_name = fauxfactory.gen_alphanumeric(12, start="project_") project_collection = application.collections.projects view = navigate_to(project_collection, "Add") view.create_project.fill({"name": project_name, "description": "desc"}) env = conf.get_config("env") fs = FTPClientWrapper(env.ftpserver.entities.mta) file_path = fs.download("acmeair-webapp-1.0-SNAPSHOT.war") view.add_applications.upload_file.fill(file_path) view.add_applications.next_button.wait_displayed() view.add_applications.delete_application.click() view.add_applications.confirm_delete.wait_displayed() view.add_applications.confirm_delete.click() view.add_applications.next_button.wait_displayed() assert not view.add_applications.next_button.is_enabled view.add_applications.back_button.wait_displayed() view.add_applications.back_button.click() view.add_applications.cancel_button.wait_displayed() view.add_applications.cancel_button.click()
def search_applications(self, app_name): """ Search application Args: app_name: Application """ view = navigate_to(self, "AnalysisResultsPage") view.search.fill(app_name)
def test_default_transformation_path(mta_app, request): """Test default transformation path for Projects Polarion: assignee: ghubale initialEstimate: 1/12h caseimportance: medium testSteps: 1. Create project 2. Go to transformation path page expectedResults: 1. Default value should be eap7 """ project_name = fauxfactory.gen_alphanumeric(12, start="project_") project_collection = mta_app.collections.projects view = navigate_to(project_collection, "Add") view.create_project.fill({"name": project_name, "description": "desc"}) view.add_applications.wait_displayed("20s") env = conf.get_config("env") fs = FTPClientWrapper(env.ftpserver.entities.mta) file_path = fs.download("arit-ear-0.8.1-SNAPSHOT.ear") view.add_applications.upload_file.fill(file_path) view.add_applications.next_button.wait_displayed() wait_for(lambda: view.add_applications.next_button.is_enabled, delay=0.2, timeout=60) view.add_applications.next_button.click() view.configure_analysis.set_transformation_target.wait_displayed() default_value = view.configure_analysis.set_transformation_target.transformation_path.read_card( card_name="Application server migration to" ) @request.addfinalizer def _finalize(): view.configure_analysis.set_transformation_target.cancel_button.click() assert default_value == "eap7"
def search_analysis(self, row): """Search analysis results with analysis number Args: row: row number to search """ view = navigate_to(self, "AnalysisResultsPage") view.wait_displayed("20s") view.search.fill(self.get_analysis_number(view, row))
def delete_custom_rule(self, cancel=False): """Method to delete custom rule file Args: cancel """ view = navigate_to(self, "CustomRule") view.wait_displayed("30s") while self.file_name not in [row.read()["Short path"] for row in view.table]: view = navigate_to(self, "Delete") view.wait_displayed("30s") if cancel: view.cancel_button.click() else: view.delete_button.click() view = self.create_view(CustomRulesView) wait_for(lambda: view.is_displayed, delay=10, timeout=240) return self.file_name not in [row.read()["Short path"] for row in view.table]
def search_application(self, name): """ Search application Args: name: name to search """ view = navigate_to(self, "ApplicationsPage") wait_for(lambda: view.search.is_displayed, delay=5, timeout=30) view.search.fill(name)
def delete_application(self, app_name): """Delete application to be analysed Args: app_name: Application """ view = navigate_to(self, "AnalysisConfigurationPage") view.selected_applications.delete_application(app_name) view.save_and_run_button.click()
def select_none(self): """Delete all application to be analysed Args: app_name: Application """ view = navigate_to(self, "AnalysisConfiguration") view.select_none.click() assert view.select_app_msg.is_displayed()
def exists(self): """Check project exist or not""" view = navigate_to(self.parent, "All") time.sleep(10) if view.table_loaded(): for row in view.table: if row.name.text == self.name: return True return False
def all(self): """Return all projects instance of Project class""" view = navigate_to(self, "All") if view.is_empty: return [] else: return [ self.instantiate(name=p.name, description=p.description) for p in view.projects.projects ]
def upload_custom_label_file(self): """Method for uploading custom label file """ view = navigate_to(self, "Add") view.wait_displayed() # upload custom labels env = conf.get_config("env") fs1 = FTPClientWrapper(env.ftpserver.entities.mta) file_path = fs1.download(self.file_name) view.upload_label.fill(file_path) view.close_button.click()
def run_analysis(self): """ Run analysis""" view = navigate_to(self, "AnalysisResultsPage") view.run_analysis_button.click() wait_for(lambda: view.analysis_results.in_progress(), delay=0.2, timeout=120) wait_for(lambda: view.analysis_results.is_analysis_complete(), delay=0.2, timeout=120) assert view.analysis_results.is_analysis_complete()
def update(self, updates): view = navigate_to(self, "Edit") view.wait_displayed() changed = view.fill(updates) if changed: view.update_project_button.click() else: view.cancel_button.click() view = self.create_view(AllProjectView, override=updates) view.wait_displayed() assert view.is_displayed
def search_system_rules(self, search_value, filter_type="Source", clear_filters=False): """Fill input box with 'search_value', use 'filter_type' to choose filter selector. If no filter_type is entered then the default for page is used. """ view = navigate_to(self, "SystemRule") view.wait_displayed() if clear_filters: self.clear_filters() if filter_type: view.filter_type_selector.item_select(filter_type) view.filter_by.item_select(search_value)
def upload_custom_label_file(self): """Method for uploading custom label file""" view = navigate_to(self, "Add") view.wait_displayed("20s") # upload custom labels env = conf.get_config("env") fs1 = FTPClientWrapper(env.ftpserver.entities.mta) file_path = fs1.download(self.file_name) view.upload_label.fill(file_path) wait_for(lambda: view.browser.is_displayed(view.file_uploaded), delay=10, timeout=30) view.close_button.click()
def delete_analysis(self, row, cancel=False): """Delete analysis results with analysis number Args: row: row number """ view = navigate_to(self, "AnalysisResultsPage") view.analysis_row(row).delete_analysis.click() view = self.create_view(AnalysisDeleteView) wait_for(lambda: view.delete.is_enabled, delay=5, timeout=30) if cancel: view.cancel.click() else: view.delete.click()
def test_login(mta_app): """Test login nav destination Polarion: assignee: ghubale initialEstimate: 1/12h testSteps: 1. Login to MTA project expectedResults: 1. It should successfully navigate to project all page or Welcome to the Migration Toolkit for Applications page """ view = navigate_to(mta_app.collections.base, "LoggedIn") assert view.is_displayed
def delete_application(self, name, cancel=False): """ Delete application Args: name: name of app """ view = navigate_to(self, "ApplicationsPage") view.table.wait_displayed("20s") for row in view.table: if row.application.text == name: row[view.ACTIONS_INDEX].widget.item_select("Delete") wait_for(lambda: view.delete_button.is_enabled, delay=5, timeout=30) if cancel: view.cancel_button.click() else: view.delete_button.click()
def delete(self, cancel=False, wait=False): """ Args: cancel: cancel deletion wait: wait for delete """ view = navigate_to(self, "Delete") view.fill({"delete_project_name": self.name}) if cancel: view.cancel_button.click() else: view.delete_button.click() if wait: wait_for(lambda: not self.exists, delay=5, timeout=30)
def test_add_folder_of_rules(mta_app, request): """Test adding a folder containing both valid and invalid rules Polarion: assignee: ghubale initialEstimate: 1/12h caseimportance: medium testSteps: 1. Login to MTA web console 2. Navigate to Global > Rules configuration > Custom rules 3. Click on Add rule button and got to server path tab and browse rules folder 4. Click on Close button expectedResults: 1. Error should be handled and it should only upload valid rules files from folder """ rule_files = [ "customWebLogic.windup.label.xml", "empty_rule_file.xml", "custom.Test1rules.rhamt.xml", ] server_path = "/tmp" @request.addfinalizer def _finalize(): rules = CustomRulesConfiguration(mta_app, server_path) rules.delete_custom_rule() rules_configurations = CustomRulesConfiguration(mta_app, server_path) view = navigate_to(rules_configurations, "Add") view.wait_displayed("20s") for file_name in rule_files: env = conf.get_config("env") fs1 = FTPClientWrapper(env.ftpserver.entities.mta) fs1.download(file_name) view.server_path.click() view.server_path.rules_path.fill(server_path) view.server_path.scan_recursive.click() view.server_path.save_button.click() view = rules_configurations.create_view(CustomRulesView) view.wait_displayed("50s") all_rules = view.table.read() for rule in all_rules: if rule["Short path"] == "/tmp": # There will be older files downloaded in /tmp directory. Hence asserting number of # rules equal to and greater than 1 only assert int(rule["Number of rules"]) >= 1
def delete_custom_label_file(self, cancel=False): """Method for deleting custom label file Args: cancel """ view = navigate_to(self, "Delete") view.wait_displayed("30s") if cancel: view.cancel_button.click() else: view.delete_button.click() view = self.create_view(CustomLabelsView) view.wait_displayed("20s") return self.file_name not in [ row.read()["Short path"] for row in view.table ]
def test_delete_application(mta_app): """Delete uploaded application file and check if next button gets disabled Polarion: assignee: ghubale initialEstimate: 1/12h caseimportance: medium testSteps: 1. Go to project all page and click on `Create project` button 2. Add name and description and click on `Next` button 3. Browse and add application file 4. Click on delete button expectedResults: 1. Next button should be disabled before uploading application file 1. Next button should be enabled after uploading application file 2. Next button should be disabled after deleting application file """ application = mta_app project_collection = application.collections.projects view = navigate_to(project_collection, "Add") view.wait_displayed("20s") view.create_project.fill({ "name": fauxfactory.gen_alphanumeric(12, start="project_"), "description": "desc" }) view.add_applications.wait_displayed() env = conf.get_config("env") fs = FTPClientWrapper(env.ftpserver.entities.mta) file_path = fs.download("acmeair-webapp-1.0-SNAPSHOT.war") view.add_applications.upload_file.fill(file_path) wait_for(lambda: view.add_applications.next_button.is_enabled, delay=0.2, timeout=60) assert view.add_applications.next_button.is_enabled view.add_applications.delete_application.click() view.add_applications.next_button.wait_displayed() assert not view.add_applications.next_button.is_enabled view.add_applications.back_button.wait_displayed() view.add_applications.back_button.click() view.add_applications.cancel_button.wait_displayed() view.add_applications.cancel_button.click() view.create_project.yes_button.click()
def test_total_global_system_label(application): """ Test to upload global custom label file Polarion: assignee: ghubale initialEstimate: 1/12h caseimportance: medium testSteps: 1. Navigate to Global > Labels configuration > System labels 2. Check show all labels expectedResults: 1. Total system labels count should be equal or greater than 1 """ global_configurations = SystemLabelsConfigurations(application) view = navigate_to(global_configurations, "SystemLabel") view.wait_displayed() assert view.paginator.total_items >= 1