def before(self): if self.server['default_binary_paths'] is None: self.skipTest( "default_binary_paths is not set for the server {0}".format( self.server['name'])) if '<' in self.table_name and os.name == 'nt': self.skipTest("HTML tags '<' and '>' in object name does not " "work for windows so skipping the test case") connection = test_utils.get_db_connection(self.server['db'], self.server['username'], self.server['db_password'], self.server['host'], self.server['port'], self.server['sslmode']) self.table_name = self.table_name + str(random.randint(100, 1000)) self.database_name = \ self.database_name + str(random.randint(100, 1000)) test_utils.drop_database(connection, self.database_name) test_utils.create_database(self.server, self.database_name) test_utils.create_table(self.server, self.database_name, self.table_name) test_gui_helper.close_bgprocess_popup(self) self.page.add_server(self.server) self.wait = WebDriverWait(self.page.driver, 20)
def before(self): connection = test_utils.get_db_connection( self.server['db'], self.server['username'], self.server['db_password'], self.server['host'], self.server['port'], self.server['sslmode'] ) self.timezone = int(test_utils.get_timezone_without_dst(connection)) if abs(self.timezone) % 3600 > 0: hh_mm = '%H:%M' else: hh_mm = '%H' self.timezone_hh_mm = time.strftime( hh_mm, time.gmtime(abs(self.timezone))) if self.timezone < 0: self.timezone_hh_mm = '-{}'.format(self.timezone_hh_mm) else: self.timezone_hh_mm = '+{}'.format(self.timezone_hh_mm) test_utils.drop_database(connection, "acceptance_test_db") test_utils.create_database(self.server, "acceptance_test_db") self.database_version = connection.server_version # For this test case we need to set "Insert bracket pairs?" # SQL Editor preference to 'false' to avoid codemirror # to add matching closing bracket by it self. self._update_preferences()
def before(self): with test_utils.Database(self.server) as (connection, _): if connection.server_version < 90100: self.skipTest( "COLLATE is not present in PG versions below v9.1" ) connection = test_utils.get_db_connection( self.server['db'], self.server['username'], self.server['db_password'], self.server['host'], self.server['port'], self.server['sslmode'] ) test_utils.drop_database(connection, "acceptance_test_db") test_utils.create_database(self.server, "acceptance_test_db") # Create pre-requisite table for k, v in {1: 'id', 2: '"ID"'}.items(): test_utils.create_table_with_query( self.server, "acceptance_test_db", CheckForViewDataTest.defaults_query.format(k, v)) # Initialize an instance of WebDriverWait with timeout of 3 seconds self.wait = WebDriverWait(self.driver, 3)
def before(self): connection = test_utils.get_db_connection(self.server['db'], self.server['username'], self.server['db_password'], self.server['host'], self.server['port'], self.server['sslmode']) self.timezone = int(test_utils.get_timezone_without_dst(connection)) if abs(self.timezone) % 3600 > 0: hh_mm = '%H:%M' else: hh_mm = '%H' self.timezone_hh_mm = time.strftime(hh_mm, time.gmtime(abs(self.timezone))) if self.timezone < 0: self.timezone_hh_mm = '-{}'.format(self.timezone_hh_mm) else: self.timezone_hh_mm = '+{}'.format(self.timezone_hh_mm) test_utils.drop_database(connection, "acceptance_test_db") test_utils.create_database(self.server, "acceptance_test_db") self.database_version = connection.server_version # For this test case we need to set "Insert bracket pairs?" # SQL Editor preference to 'false' to avoid codemirror # to add matching closing bracket by it self. self._update_preferences()
def before(self): connection = test_utils.get_db_connection(self.server['db'], self.server['username'], self.server['db_password'], self.server['host'], self.server['port']) test_utils.drop_database(connection, "acceptance_test_db") test_utils.create_database(self.server, "acceptance_test_db")
def setUp(self): self.db_names = ["db_delete_%s" % str(uuid.uuid4())[1:8], "db_delete_%s" % str(uuid.uuid4())[1:8]] self.db_ids = [utils.create_database(self.server, self.db_names[0]), utils.create_database(self.server, self.db_names[1])] self.server_id = parent_node_dict["server"][-1]["server_id"]
def setUp(self): self.src_database = "db_schema_diff_src_%s" % str(uuid.uuid4())[1:8] self.tar_database = "db_schema_diff_tar_%s" % str(uuid.uuid4())[1:8] self.src_db_id = utils.create_database(self.server, self.src_database) self.tar_db_id = utils.create_database(self.server, self.tar_database) self.server = parent_node_dict["server"][-1]["server"] self.server_id = parent_node_dict["server"][-1]["server_id"] self.nodes = ['table', 'function', 'procedure', 'view', 'mview'] self.restore_backup()
def before(self): connection = test_utils.get_db_connection(self.server['db'], self.server['username'], self.server['db_password'], self.server['host'], self.server['port']) test_utils.drop_database(connection, "acceptance_test_db") test_utils.create_database(self.server, "acceptance_test_db") self.page.wait_for_spinner_to_disappear() self._connects_to_server() self._locate_database_tree_node() self.page.open_query_tool()
def before(self): connection = test_utils.get_db_connection( self.server['db'], self.server['username'], self.server['db_password'], self.server['host'], self.server['port'] ) test_utils.drop_database(connection, "acceptance_test_db") test_utils.create_database(self.server, "acceptance_test_db") test_utils.create_table( self.server, "acceptance_test_db", "test_table") self.page.add_server(self.server)
def before(self): connection = test_utils.get_db_connection(self.server['db'], self.server['username'], self.server['db_password'], self.server['host'], self.server['port']) test_utils.drop_database(connection, "acceptance_test_db") test_utils.create_database(self.server, "acceptance_test_db") test_utils.create_table(self.server, "acceptance_test_db", "<h1>X") # This is needed to test dependents tab (eg: BackGrid) test_utils.create_constraint(self.server, "acceptance_test_db", "<h1>X", "unique", "<h1 onmouseover='console.log(2);'>Y")
def before(self): connection = test_utils.get_db_connection(self.server['db'], self.server['username'], self.server['db_password'], self.server['host'], self.server['port']) test_utils.drop_database(connection, "acceptance_test_db") test_utils.create_database(self.server, "acceptance_test_db") self.page.add_server(self.server) self.wait = WebDriverWait(self.page.driver, 10) self.XSS_FILE = '/tmp/<img src=x onmouseover=alert("1")>.sql' # Remove any previous file if os.path.isfile(self.XSS_FILE): os.remove(self.XSS_FILE)
def setUp(self): self.src_database = "db_schema_diff_src_%s" % str(uuid.uuid4())[1:8] self.tar_database = "db_schema_diff_tar_%s" % str(uuid.uuid4())[1:8] self.src_db_id = utils.create_database(self.server, self.src_database) self.tar_db_id = utils.create_database(self.server, self.tar_database) self.server = parent_node_dict["server"][-1]["server"] self.server_id = parent_node_dict["server"][-1]["server_id"] self.schema_name = 'test_schema_diff' self.restored_backup = True status = self.restore_backup() if not status: self.restored_backup = False
def setUp(self): self.db_name = "db_delete_%s" % str(uuid.uuid4())[1:8], self.db_id = utils.create_database(self.server, self.db_name) self.server_id = parent_node_dict["server"][-1]["server_id"] db_dict = {"server_id": self.server_id, "db_id": self.db_id, "db_name": self.db_name} utils.write_node_info("did", db_dict)
def before(self): connection = test_utils.get_db_connection( self.server['db'], self.server['username'], self.server['db_password'], self.server['host'], self.server['port'] ) test_utils.drop_database(connection, "acceptance_test_db") test_utils.create_database(self.server, "acceptance_test_db") self.page.add_server(self.server) self.wait = WebDriverWait(self.page.driver, 10) self.XSS_FILE = '/tmp/<img src=x onmouseover=alert("1")>.sql' # Remove any previous file if os.path.isfile(self.XSS_FILE): os.remove(self.XSS_FILE)
def before(self): if self.server['default_binary_paths'] is None: self.skipTest( "default_binary_paths is not set for the server {0}".format( self.server['name'] ) ) if '<' in self.database_name and os.name == 'nt': self.skipTest( "HTML tags '<' and '>' in object name does not " "work for windows so skipping the test case" ) connection = test_utils.get_db_connection( self.server['db'], self.server['username'], self.server['db_password'], self.server['host'], self.server['port'], self.server['sslmode'] ) test_utils.drop_database(connection, self.database_name) self._update_preferences() db_id = test_utils.create_database(self.server, self.database_name) if not db_id: self.assertTrue(False, "Database {} is not " "created".format(self.database_name)) test_gui_helper.close_bgprocess_popup(self) self.page.add_server(self.server) self.wait = WebDriverWait(self.page.driver, 20)
def setUp(self): self._db_name = 'download_results_' + str(random.randint(10000, 65535)) self._sid = self.server_information['server_id'] server_con = server_utils.connect_server(self, self._sid) self._did = test_utils.create_database(self.server, self._db_name)
def setUp(self): self.db_name = "test_db_put_%s" % str(uuid.uuid4())[1:8] self.db_id = utils.create_database(self.server, self.db_name) self.server_id = parent_node_dict["server"][-1]["server_id"] db_dict = {"server_id": self.server_id, "db_id": self.db_id, "db_name": self.db_name} utils.write_node_info("did", db_dict)
def before(self): if self.server['default_binary_paths'] is None: self.skipTest( "default_binary_paths is not set for the server {0}".format( self.server['name'])) connection = test_utils.get_db_connection(self.server['db'], self.server['username'], self.server['db_password'], self.server['host'], self.server['port'], self.server['sslmode']) test_utils.drop_database(connection, "pg_utility_test_db") test_utils.create_database(self.server, "pg_utility_test_db") self.page.add_server(self.server) self.wait = WebDriverWait(self.page.driver, 20)
def before(self): if self.server['default_binary_paths'] is None: self.skipTest( "default_binary_paths is not set for the server {0}".format( self.server['name'])) connection = test_utils.get_db_connection(self.server['db'], self.server['username'], self.server['db_password'], self.server['host'], self.server['port'], self.server['sslmode']) test_utils.drop_database(connection, self.database_name) test_utils.create_database(self.server, self.database_name) test_utils.create_table(self.server, self.database_name, self.table_name) self.page.add_server(self.server) self.wait = WebDriverWait(self.page.driver, 20) test_gui_helper.close_bgprocess_popup(self)
def before(self): connection = test_utils.get_db_connection( self.server['db'], self.server['username'], self.server['db_password'], self.server['host'], self.server['port'], self.server['sslmode'] ) test_utils.drop_database(connection, "acceptance_test_db") test_utils.create_database(self.server, "acceptance_test_db") test_utils.create_table( self.server, "acceptance_test_db", "<h1>X" ) # This is needed to test dependents tab (eg: BackGrid) test_utils.create_constraint( self.server, "acceptance_test_db", "<h1>X", "unique", "<h1 onmouseover='console.log(2);'>Y" )
def before(self): if self.server['default_binary_paths'] is None: self.skipTest( "default_binary_paths is not set for the server {0}".format( self.server['name'] ) ) connection = test_utils.get_db_connection( self.server['db'], self.server['username'], self.server['db_password'], self.server['host'], self.server['port'], self.server['sslmode'] ) test_utils.drop_database(connection, self.database_name) test_utils.create_database(self.server, self.database_name) test_utils.create_table(self.server, self.database_name, self.table_name) self.page.add_server(self.server) self.wait = WebDriverWait(self.page.driver, 20)
def setUp(self): self.encode_db_name = 'encoding_' + self.db_encoding self.encode_sid = self.server_information['server_id'] server_con = server_utils.connect_server(self, self.encode_sid) if hasattr(self, 'skip_on_database'): if 'data' in server_con and 'type' in server_con['data']: if server_con['data']['type'] in self.skip_on_database: self.skipTest('cannot run in: %s' % server_con['data']['type']) self.encode_did = test_utils.create_database( self.server, self.encode_db_name, (self.db_encoding, self.lc_collate))
def setUp(self): self.encode_db_name = 'test_encoding_' + self.db_encoding self.encode_sid = self.server_information['server_id'] server_con = server_utils.connect_server(self, self.encode_sid) if hasattr(self, 'skip_on_database'): if 'data' in server_con and 'type' in server_con['data']: if server_con['data']['type'] in self.skip_on_database: self.skipTest('cannot run in: %s' % server_con['data']['type']) self.encode_did = test_utils.create_database( self.server, self.encode_db_name, (self.db_encoding, self.lc_collate)) test_utils.create_table_with_query( self.server, self.encode_db_name, """CREATE TABLE {0}( name character varying(200) COLLATE pg_catalog."default") """.format(self.table_name))
def setUp(self): self.db_name = "erdtestdb_{0}".format(str(uuid.uuid4())[1:8]) self.sid = parent_node_dict["server"][-1]["server_id"] self.did = utils.create_database(self.server, self.db_name) try: self.sgid = config_data["server_group"] self.tables = [["erd1", "table_1"], ["erd2", "table_2"]] for tab in self.tables: connection = utils.get_db_connection( self.db_name, self.server['username'], self.server['db_password'], self.server['host'], self.server['port']) schema_utils.create_schema(connection, tab[0]) tables_utils.create_table(self.server, self.db_name, tab[0], tab[1]) connection.close() except Exception as _: self.dropDB() raise
def setUp(self): self.db_name = "psqltestdb_{0}".format(str(uuid.uuid4())[1:8]) self.sid = parent_node_dict["server"][-1]["server_id"] self.did = utils.create_database(self.server, self.db_name) self.sgid = config_data["server_group"] self.theme = 'standard'
def setUp(self): self.db_name = "erdtestdb" self.sid = parent_node_dict["server"][-1]["server_id"] self.did = utils.create_database(self.server, self.db_name) self.sgid = config_data["server_group"]
def execute_test(test_module_list_passed, server_passed, driver_passed): """ Function executes actually test :param test_module_list_passed: :param server_passed: :param driver_passed: :return: """ try: print("\n=============Running the test cases for '%s' =============" % server_passed['name'], file=sys.stderr) # Create test server server_information = \ test_utils.create_parent_server_node(server_passed) # Create test database with random number to avoid conflict in # parallel execution on different platforms. This database will be # used across all feature tests. test_db_name = "acceptance_test_db" + \ str(random.randint(10000, 65535)) connection = test_utils.get_db_connection( server_passed['db'], server_passed['username'], server_passed['db_password'], server_passed['host'], server_passed['port'], server_passed['sslmode'] ) # Add the server version in server information server_information['server_version'] = connection.server_version server_information['type'] = server_passed['type'] # Drop the database if already exists. test_utils.drop_database(connection, test_db_name) # Create database test_utils.create_database(server_passed, test_db_name) # Configure preferences for the test cases test_utils.configure_preferences( default_binary_path=server_passed['default_binary_paths']) # Get unit test suit suite = get_suite(test_module_list_passed, server_passed, test_client, server_information, test_db_name, driver_passed) # Run unit test suit created tests = unittest.TextTestRunner(stream=sys.stderr, descriptions=True, verbosity=2).run(suite) # processing results ran_tests, failed_cases, skipped_cases, passed_cases = \ get_tests_result(tests) # This is required when some tests are running parallel # & some sequential in case of parallel ui tests if threading.current_thread().getName() == "sequential_tests": try: if test_result[server_passed['name']][0] is not None: ran_tests = test_result[server_passed['name']][0] + \ ran_tests failed_cases.update(test_result[server_passed['name']][1]) skipped_cases.update(test_result[server_passed['name']][2]) passed_cases.update(test_result[server_passed['name']][3]) test_result[server_passed['name']] = [ran_tests, failed_cases, skipped_cases, passed_cases] except KeyError: pass # Add final results server wise in test_result dict test_result[server_passed['name']] = [ran_tests, failed_cases, skipped_cases, passed_cases] # Set empty list for 'passed' parameter for each testRun. # So that it will not append same test case name # unittest.result.TestResult.passed = [] # Drop the testing database created initially if connection: test_utils.drop_database(connection, test_db_name) connection.close() # Delete test server # test_utils.delete_test_server(test_client) test_utils.delete_server(test_client, server_information) except Exception as exc: traceback.print_exc(file=sys.stderr) print(str(exc)) print("Exception in {0} {1}".format( threading.current_thread().ident, threading.currentThread().getName())) finally: # Delete web-driver instance thread_name = "parallel_tests" + server_passed['name'] if threading.currentThread().getName() == thread_name: test_utils.quit_webdriver(driver_passed) time.sleep(20) # Print info about completed tests print( "\n=============Completed the test cases for '%s'=============" % server_passed['name'], file=sys.stderr)
def runTest(self): self.db_name = '' self.server_id = parent_node_dict["server"][-1]["server_id"] server_utils.connect_server(self, self.server_id) utils.create_database(self.server, self.params['database']) self.create_backup() url = self.url.format(self.server_id) # Create the restore job response = self.tester.post(url, data=json.dumps(self.params), content_type='html/json') self.assertEqual(response.status_code, 200) response_data = json.loads(response.data.decode('utf-8')) job_id = response_data['data']['job_id'] cnt = 0 while 1: if cnt >= 5: break # Check the process list response1 = self.tester.get('/misc/bgprocess/?_='.format( random.randint(1, 9999999))) self.assertEqual(response1.status_code, 200) process_list = json.loads(response1.data.decode('utf-8')) if len(process_list) > 0 and 'execution_time' in process_list[0]: break time.sleep(0.5) cnt += 1 self.assertTrue('execution_time' in process_list[0]) self.assertTrue('stime' in process_list[0]) self.assertTrue('exit_code' in process_list[0]) self.assertTrue(process_list[0]['exit_code'] in self.expected_exit_code) if self.expected_cmd_opts: for opt in self.expected_cmd_opts: self.assertIn(opt, process_list[0]['details']) if self.not_expected_cmd_opts: for opt in self.not_expected_cmd_opts: self.assertNotIn(opt, process_list[0]['details']) # Check the process details p_details = self.tester.get('/misc/bgprocess/{0}?_='.format( job_id, random.randint(1, 9999999)) ) self.assertEqual(p_details.status_code, 200) json.loads(p_details.data.decode('utf-8')) p_details = self.tester.get('/misc/bgprocess/{0}/{1}/{2}/?_='.format( job_id, 0, 0, random.randint(1, 9999999)) ) self.assertEqual(p_details.status_code, 200) p_details_data = json.loads(p_details.data.decode('utf-8')) # Retrieve the restore job process logs cnt = 0 while 1: out, err, status = RestoreJobTest.get_params(p_details_data) if status or cnt >= 5: break p_details = self.tester.get( '/misc/bgprocess/{0}/{1}/{2}/?_={3}'.format( job_id, out, err, random.randint(1, 9999999)) ) self.assertEqual(p_details.status_code, 200) p_details_data = json.loads(p_details.data.decode('utf-8')) cnt += 1 time.sleep(1) # Check the job is complete. restore_ack = self.tester.put('/misc/bgprocess/{0}'.format(job_id)) self.assertEqual(restore_ack.status_code, 200) restore_ack_res = json.loads(restore_ack.data.decode('utf-8')) self.assertEqual(restore_ack_res['success'], 1) if self.backup_file is not None: if os.path.isfile(self.backup_file): os.remove(self.backup_file)
def runTest(self): self.db_name = '' self.server_id = parent_node_dict["server"][-1]["server_id"] server_utils.connect_server(self, self.server_id) utils.create_database(self.server, self.params['database']) self.create_backup() url = self.url.format(self.server_id) # Create the restore job response = self.tester.post(url, data=json.dumps(self.params), content_type='html/json') self.assertEqual(response.status_code, 200) response_data = json.loads(response.data.decode('utf-8')) job_id = response_data['data']['job_id'] cnt = 0 while 1: if cnt >= 5: break # Check the process list response1 = self.tester.get('/misc/bgprocess/?_='.format( random.randint(1, 9999999))) self.assertEqual(response1.status_code, 200) process_list = json.loads(response1.data.decode('utf-8')) if len(process_list) > 0 and 'execution_time' in process_list[0]: break time.sleep(0.5) cnt += 1 self.assertTrue('execution_time' in process_list[0]) self.assertTrue('stime' in process_list[0]) self.assertTrue('exit_code' in process_list[0]) self.assertTrue( process_list[0]['exit_code'] in self.expected_exit_code) if self.expected_cmd_opts: for opt in self.expected_cmd_opts: self.assertIn(opt, process_list[0]['details']) if self.not_expected_cmd_opts: for opt in self.not_expected_cmd_opts: self.assertNotIn(opt, process_list[0]['details']) # Check the process details p_details = self.tester.get('/misc/bgprocess/{0}?_='.format( job_id, random.randint(1, 9999999))) self.assertEqual(p_details.status_code, 200) json.loads(p_details.data.decode('utf-8')) p_details = self.tester.get('/misc/bgprocess/{0}/{1}/{2}/?_='.format( job_id, 0, 0, random.randint(1, 9999999))) self.assertEqual(p_details.status_code, 200) p_details_data = json.loads(p_details.data.decode('utf-8')) # Retrieve the restore job process logs cnt = 0 while 1: out, err, status = RestoreJobTest.get_params(p_details_data) if status or cnt >= 5: break p_details = self.tester.get( '/misc/bgprocess/{0}/{1}/{2}/?_={3}'.format( job_id, out, err, random.randint(1, 9999999))) self.assertEqual(p_details.status_code, 200) p_details_data = json.loads(p_details.data.decode('utf-8')) cnt += 1 time.sleep(1) # Check the job is complete. restore_ack = self.tester.put('/misc/bgprocess/{0}'.format(job_id)) self.assertEqual(restore_ack.status_code, 200) restore_ack_res = json.loads(restore_ack.data.decode('utf-8')) self.assertEqual(restore_ack_res['success'], 1) if self.backup_file is not None: if os.path.isfile(self.backup_file): os.remove(self.backup_file)
# parallel execution on different platforms. This database will be # used across all feature tests. test_db_name = "acceptance_test_db" + \ str(random.randint(10000, 65535)) connection = test_utils.get_db_connection( server['db'], server['username'], server['db_password'], server['host'], server['port'], server['sslmode']) # Add the server version in server information server_information['server_version'] = connection.server_version server_information['type'] = server['type'] # Drop the database if already exists. test_utils.drop_database(connection, test_db_name) # Create database test_utils.create_database(server, test_db_name) # Configure preferences for the test cases test_utils.configure_preferences( default_binary_path=server['default_binary_paths']) suite = get_suite(test_module_list, server, test_client, server_information, test_db_name) tests = unittest.TextTestRunner(stream=sys.stderr, descriptions=True, verbosity=2).run(suite) ran_tests, failed_cases, skipped_cases, passed_cases = \ get_tests_result(tests) test_result[server['name']] = [ ran_tests, failed_cases, skipped_cases, passed_cases ]
# used across all feature tests. test_db_name = "acceptance_test_db" + \ str(random.randint(10000, 65535)) connection = test_utils.get_db_connection( server['db'], server['username'], server['db_password'], server['host'], server['port'], server['sslmode'] ) # Drop the database if already exists. test_utils.drop_database(connection, test_db_name) # Create database test_utils.create_database(server, test_db_name) if server['default_binary_paths'] is not None: test_utils.set_preference(server['default_binary_paths']) suite = get_suite(test_module_list, server, test_client, server_information, test_db_name) tests = unit_test.TextTestRunner(stream=sys.stderr, descriptions=True, verbosity=2).run(suite) ran_tests, failed_cases, skipped_cases, passed_cases = \ get_tests_result(tests) test_result[server['name']] = [ran_tests, failed_cases,