def setUp(self): self.semaphore_base_url = 'http://localhost:3000/api' if SemaphoreHelper.service_is_up(self.semaphore_base_url): self.username = '******' self.password = '******' self.project_name = 'test' self.private_key = '-----BEGIN RSA PRIVATE KEY-----MIIEowIBAAKCAQEAg0blRNV6cm3RTiivpzE8HR4JzKZRVIBZ7bxeNoMz0' \ '-----END RSA PRIVATE KEY-----' vms = [] vm = {} vm['role'] = 'master' vm['public_ip'] = '192.168.1.10' vm['user_name'] = 'user_name' vms.append(vm) vm['role'] = 'worker' vm['public_ip'] = '192.168.1.11' vm['role'] = 'worker' vm['public_ip'] = '192.168.1.12' vms.append(vm) self.inventory_contents = yaml.dump(self.build_yml_inventory(vms), default_flow_style=False) self.git_url = 'https://github.com/skoulouzis/playbooks.git' self.playbook_name = 'get_ip_addresses.yaml' self.semaphore_helper = SemaphoreHelper(self.semaphore_base_url, self.username, self.password)
def setUp(self): self.semaphore_base_url = 'http://127.0.0.1:3000/api' if SemaphoreHelper.service_is_up(self.semaphore_base_url): self.username = '******' self.password = '******' now = datetime.datetime.now() self.project_name = 'project_name_test' + '_' + str(now) self.private_key = '-----BEGIN RSA PRIVATE KEY-----MIIEowIBAAKCAQEAg0blRNV6cm3RTiivpzE8HR4JzKZRVIBZ7bxeNoMz0' \ '-----END RSA PRIVATE KEY-----' vms = [] vm = {} vm['role'] = 'master' vm['public_ip'] = '127.0.0.1' vm['semaphore'] = 'semaphore' vms.append(vm) vm['role'] = 'worker' vm['public_ip'] = '127.0.0.1' vm['role'] = 'worker' vm['public_ip'] = '127.0.0.1' vms.append(vm) self.inventory_contents = yaml.dump(self.build_yml_inventory(vms), default_flow_style=False) self.git_url = 'https://github.com/QCDIS/playbooks.git' self.playbook_name = 'get_ip_addresses.yaml' self.semaphore_helper = SemaphoreHelper(self.semaphore_base_url, self.username, self.password)
def testGetRepository(self): """Test Login""" if SemaphoreHelper.service_is_up(self.semaphore_base_url): helper = SemaphoreHelper(self.semaphore_base_url, self.username, self.password) project_name = 'test' key = '-----BEGIN RSA PRIVATE KEY-----MIIEowIBAAKCAQEAg0blRNV6cm3RTiivpzE8HR4JzKZRVIBZ7bxeNoMz0' \ '-----END RSA PRIVATE KEY-----' project_id = helper.create_project(project_name) git_url_1 = 'https://github.com/QCDIS/playbooks.git' key_id = helper.create_ssh_key(project_name, project_id, key) repository_id_1 = helper.create_repository(project_name, project_id, key_id,git_url_1) git_url_2 = 'https://github.com/QCDIS/mysome_glusterfs.git' repository_id_2 = helper.create_repository(project_name, project_id,key_id, git_url_2) self.assertNotEqual(repository_id_1,repository_id_2)
def testTask(self): if SemaphoreHelper.service_is_up(self.semaphore_base_url): project_id = self.semaphore_helper.create_project( self.project_name) key_id = self.semaphore_helper.create_ssh_key( self.project_name, project_id, self.private_key) inventory_id = self.semaphore_helper.create_inventory( self.project_name, project_id, key_id, self.inventory_contents) repository_id = self.semaphore_helper.create_repository( self.project_name, project_id, key_id, self.git_url) template_id = self.semaphore_helper.create_template( project_id, key_id, inventory_id, repository_id, self.playbook_name) task_id = self.semaphore_helper.execute_task( project_id, template_id, self.playbook_name) for x in range(0, 2): task = self.semaphore_helper.get_task(project_id, task_id) print(task) # task_output = self.semaphore_helper.get_task_output(project_id, task_id) # print(task_output) sleep(1) task_id = self.semaphore_helper.execute_task( project_id, template_id, self.playbook_name) for x in range(0, 2): task = self.semaphore_helper.get_task(project_id, task_id) print(task) # task_output = self.semaphore_helper.get_task_output(project_id, task_id) # print(task_output) sleep(1) task_id = self.semaphore_helper.execute_task( project_id, template_id, 'mount.yaml') for x in range(0, 2): task = self.semaphore_helper.get_task(project_id, task_id) print(task) # task_output = self.semaphore_helper.get_task_output(project_id, task_id) # print(task_output) sleep(1)
def testTask(self): if SemaphoreHelper.service_is_up(self.semaphore_base_url): project_id = self.semaphore_helper.create_project( self.project_name) now = datetime.datetime.now() key_name = 'key_name' + str(now) key_id = self.semaphore_helper.create_ssh_key( key_name, project_id, self.private_key) now = datetime.datetime.now() inventory_name = 'inventory_name' + str(now) inventory_id = self.semaphore_helper.create_inventory( inventory_name, project_id, key_id, self.inventory_contents) now = datetime.datetime.now() repository_name = 'repository_name' + str(now) repository_id = self.semaphore_helper.create_repository( repository_name, project_id, key_id, self.git_url) template_id = self.semaphore_helper.create_template( project_id, key_id, inventory_id, repository_id, self.playbook_name) env_vars = {"SOME_VAR": "the contents"} now = datetime.datetime.now() environment_name = 'environment_name_name_' + str(now) environment_id = self.semaphore_helper.create_environment( project_id, environment_name, env_vars) task_id = self.semaphore_helper.execute_task( project_id, template_id, self.playbook_name, environment_id=environment_id) for x in range(0, 2): task = self.semaphore_helper.get_task(project_id, task_id) print(task) # task_output = self.semaphore_helper.get_task_output(project_id, task_id) # print(task_output) sleep(1)
def setUp(self): self.semaphore_base_url = 'http://127.0.0.1:3000/api' if SemaphoreHelper.service_is_up(self.semaphore_base_url): self.username = '******' self.password = '******'
def testLogin(self): """Test Login""" if SemaphoreHelper.service_is_up(self.semaphore_base_url): self.helper = SemaphoreHelper(self.semaphore_base_url, self.username, self.password)