def setUp(self): super(SGConfigTests, self).setUp() for server in self.servers: if self.case_number == 1: with open('pytests/sg/resources/gateway_config_walrus_template.json', 'r') as file: filedata = file.read() filedata = filedata.replace('LOCAL_IP', server.ip) with open('pytests/sg/resources/gateway_config_walrus.json', 'w') as file: file.write(filedata) shell = RemoteMachineShellConnection(server) shell.execute_command("rm -rf {0}/tmp/*".format(self.folder_prefix)) shell.copy_files_local_to_remote('pytests/sg/resources', '{0}/tmp'.format(self.folder_prefix)) # will install sg only the first time self.install(shell) pid = self.is_sync_gateway_process_running(shell) self.assertNotEqual(pid, 0) exist = shell.file_exists('{0}/tmp/'.format(self.folder_prefix), 'gateway.log') self.assertTrue(exist) shell.disconnect() if self.case_number == 1: shutil.copy2('pytests/sg/resources/gateway_config_backup.json', 'pytests/sg/resources/gateway_config.json') BucketOperationHelper.delete_all_buckets_or_assert(self.servers, self) self.cluster = Cluster() self.cluster.create_default_bucket(self.master, 150) task = self.cluster.async_create_sasl_bucket(self.master, 'test_%E-.5', 'password', 150, 1) task.result() task = self.cluster.async_create_standard_bucket(self.master, 'db', 11219, 150, 1) task.result()
def setUp(self): super(GatewayWebhookBaseTest, self).setUp() self.log = logger.Logger.get_logger() self.input = TestInputSingleton.input self.extra_param = self.input.param("extra_param", "") self.configfile = self.input.param("config", "config_webhook_basic.json") self.doc_id = self.input.param("doc_id", "doc1") self.doc_content = self.input.param("doc_content", "{'a':1}") self.expected_error = self.input.param("expected_error", "") self.servers = self.input.servers self.master = self.servers[0] for server in self.servers: shell = RemoteMachineShellConnection(server) if self.case_number == 1: shell.execute_command("rm -rf {0}/tmp/*".format( self.folder_prefix)) # will install sg only the first time self.install(shell) pid = self.is_sync_gateway_process_running(shell) self.assertNotEqual(pid, 0) exist = shell.file_exists( '{0}/tmp/'.format(self.folder_prefix), 'gateway.log') self.assertTrue(exist) shell.copy_files_local_to_remote('pytests/sg/resources', '/tmp') self.start_simpleServe(shell) shell.disconnect()
def setUp(self): super(GatewayWebhookBaseTest, self).setUp() self.log = logger.Logger.get_logger() self.input = TestInputSingleton.input self.version = self.input.param("version", "0.0.0-358") self.extra_param = self.input.param("extra_param", "") self.configfile = self.input.param("config", "config_webhook_basic.json") self.doc_id = self.input.param("doc_id", "doc1") self.doc_content = self.input.param("doc_content", "{'a':1}") self.expected_error = self.input.param("expected_error", "") self.servers = self.input.servers self.master = self.servers[0] for server in self.servers: shell = RemoteMachineShellConnection(server) if self.case_number == 1: shell.execute_command("rm -rf {0}/tmp/*".format(self.folder_prefix)) # will install sg only the first time self.install(shell) pid = self.is_sync_gateway_process_running(shell) self.assertNotEqual(pid, 0) exist = shell.file_exists("{0}/tmp/".format(self.folder_prefix), "gateway.log") self.assertTrue(exist) shell.copy_files_local_to_remote("pytests/sg/resources", "/tmp") self.start_simpleServe(shell) shell.disconnect()
def configStartSgw(self): for server in self.servers: shell = RemoteMachineShellConnection(server) shutil.copy2('pytests/sg/resources/gateway_config_backup.json', 'pytests/sg/resources/gateway_config.json') shell.copy_files_local_to_remote('pytests/sg/resources', '/tmp') self.assertTrue(self.start_sync_gateway(shell)) self.assertTrue(self.check_message_in_gatewaylog(shell, self.expected_log)) if not self.expected_error: if self.admin_port: self.assertTrue(self.get_users(shell)) if self.sync_port: success, revision = self.create_doc(shell) self.assertTrue(success) self.assertTrue(self.delete_doc(shell, revision)) shell.disconnect()
def configStartSgw(self): for server in self.servers: shell = RemoteMachineShellConnection(server) shutil.copy2('pytests/sg/resources/gateway_config_backup.json', 'pytests/sg/resources/gateway_config.json') shell.copy_files_local_to_remote('pytests/sg/resources', '/tmp') self.assertTrue(self.start_sync_gateway(shell)) self.assertTrue( self.check_message_in_gatewaylog(shell, self.expected_log)) if not self.expected_error: if self.admin_port: self.assertTrue(self.get_users(shell)) if self.sync_port: success, revision = self.create_doc(shell) self.assertTrue(success) self.assertTrue(self.delete_doc(shell, revision)) shell.disconnect()
def setUp(self): super(SGConfigTests, self).setUp() for server in self.servers: if self.case_number == 1: with open( 'pytests/sg/resources/gateway_config_walrus_template.json', 'r') as file: filedata = file.read() filedata = filedata.replace('LOCAL_IP', server.ip) with open('pytests/sg/resources/gateway_config_walrus.json', 'w') as file: file.write(filedata) shell = RemoteMachineShellConnection(server) shell.execute_command("rm -rf {0}/tmp/*".format( self.folder_prefix)) shell.copy_files_local_to_remote( 'pytests/sg/resources', '{0}/tmp'.format(self.folder_prefix)) # will install sg only the first time self.install(shell) pid = self.is_sync_gateway_process_running(shell) self.assertNotEqual(pid, 0) exist = shell.file_exists( '{0}/tmp/'.format(self.folder_prefix), 'gateway.log') self.assertTrue(exist) shell.disconnect() if self.case_number == 1: shutil.copy2('pytests/sg/resources/gateway_config_backup.json', 'pytests/sg/resources/gateway_config.json') BucketOperationHelper.delete_all_buckets_or_assert( self.servers, self) self.cluster = Cluster() shared_params = self._create_bucket_params(server=self.master, size=150) self.cluster.create_default_bucket(shared_params) task = self.cluster.async_create_sasl_bucket( name='test_%E-.5', password='******', bucket_params=shared_params) task.result() task = self.cluster.async_create_standard_bucket( name='db', port=11219, bucket_params=shared_params) task.result()
def setUp(self): super(SGWebHookTest, self).setUp() for server in self.servers: shell = RemoteMachineShellConnection(server) shell.copy_files_local_to_remote('pytests/sg/resources', '/root')
def test_win_install(self): query = BuildQuery() builds, changes = query.get_all_builds() version = self.input.test_params['version'] os_version = self.input.test_params['win'] task = 'install' ok = True ex_type = 'exe' bat_file = 'install.bat' version_file = 'VERSION.txt' if self.input.test_params["ostype"] == '64': Arch = 'x86_64' os_type = '64' elif self.input.test_params["ostype"] == '32': Arch = 'x86' os_type = '32' else: ok = False self.log.error("Unknown os version.") product = self.input.test_params["product"] if product == 'cse': name = 'couchbase-server-enterprise' elif product == 'csse': name = 'couchbase-single-server-enterprise' elif product == 'csc': name = 'couchbase-server-community' elif product == 'cssc': name = 'couchbase-single-server-community' else: ok = False self.log.error("Unknon product type.") cb_server_alias = ['cse','csc'] cb_single_alias = ['csse','cssc'] if product in cb_server_alias: server_path = "/cygdrive/c/Program Files/Couchbase/Server/" elif product in cb_single_alias: server_path = "/cygdrive/c/Program Files (x86)/Couchbase/Server/" if ok: for serverInfo in self.servers: remote_client = RemoteMachineShellConnection(serverInfo) info = RemoteMachineShellConnection(serverInfo).extract_remote_info() build = query.find_build(builds, name, ex_type, Arch, version) #self.log.info("what is this {0}".format(build.url)) # check if previous couchbase server installed exist = remote_client.file_exists("/cygdrive/c/Program Files/Couchbase/Server/", version_file) if exist: # call uninstall function to install couchbase server self.log.info("Start uninstall cb server on this server") self.test_win_uninstall(remote_client, product, os_type, os_version, version, server_path) else: self.log.info('I am free. You can install couchbase server now') # directory path in remote server used to create or delete directory dir_paths = ['/cygdrive/c/automation','/cygdrive/c/tmp'] remote_client.create_multiple_dir(dir_paths) # copy files from local server to remote server remote_client.copy_files_local_to_remote('resources/windows/automation', '/cygdrive/c/automation') downloaded = remote_client.download_binary_in_win(build.url,product,version) if downloaded: self.log.info('Successful download {0}_{1}.exe'.format(product, version)) else: self.log.error('Download {0}_{1}.exe failed'.format(product, version)) remote_client.modify_bat_file('/cygdrive/c/automation', bat_file, product, os_type, os_version, version, task) self.log.info('sleep for 5 seconds before running task schedule install me') time.sleep(5) # run task schedule to install Couchbase Server output, error = remote_client.execute_command("cmd /c schtasks /run /tn installme") remote_client.log_command_output(output, error) remote_client.wait_till_file_added(server_path, version_file, timeout_in_seconds=600) self.log.info('sleep 15 seconds before running the next job ...') time.sleep(15) else: self.log.error("Can not install Couchbase Server.")