def test_positive_run_recurring_job_with_max_iterations(self): """Run default job template multiple times with max iteration :id: 37fb7d77-dbb1-45ae-8bd7-c70be7f6d949 :expectedresults: Verify the job was run not more than the specified number of times. """ invocation_command = make_job_invocation({ 'job-template': 'Run Command - SSH Default', 'inputs': 'command="ls"', 'search-query': "name ~ {0}".format(self.client.hostname), 'cron-line': '* * * * *', # every minute 'max-iteration': 2, # just two runs }) if not bz_bug_is_open(1431190): JobInvocation.get_output({ 'id': invocation_command[u'id'], 'host': self.client.hostname }) try: self.assertEqual(invocation_command['status'], u'queued') except AssertionError: result = 'host output: {0}'.format( ' '.join(JobInvocation.get_output({ 'id': invocation_command[u'id'], 'host': self.client.hostname}) ) ) raise AssertionError(result) sleep(150) rec_logic = RecurringLogic.info({ 'id': invocation_command['recurring-logic-id']}) self.assertEqual(rec_logic['state'], u'finished') self.assertEqual(rec_logic['iteration'], u'2')
def test_positive_run_reccuring_job(self, fixture_vmsetup, fixture_org): """Tests Ansible REX reccuring job runs successfully multiple times :id: 49b0d31d-58f9-47f1-aa5d-561a1dcb0d66 :Steps: 0. Create a VM and register to SAT and prepare for REX (ssh key) 1. Run recurring Ansible Command job for the host 2. Check the multiple job results at the host :expectedresults: multiple asserts along the code :caseautomation: automated :CaseLevel: System """ self.org = fixture_org self.client = fixture_vmsetup # set connecting to host by ip Host.set_parameter({ 'host': self.client.hostname, 'name': 'remote_execution_connect_by_ip', 'value': 'True', }) invocation_command = make_job_invocation({ 'job-template': 'Run Command - Ansible Default', 'inputs': 'command="ls"', 'search-query': "name ~ {0}".format(self.client.hostname), 'cron-line': '* * * * *', # every minute 'max-iteration': 2, # just two runs }) JobInvocation.get_output({ 'id': invocation_command[u'id'], 'host': self.client.hostname }) try: assert invocation_command['status'] == u'queued' except AssertionError: result = 'host output: {0}'.format( ' '.join(JobInvocation.get_output({ 'id': invocation_command[u'id'], 'host': self.client.hostname}) ) ) raise AssertionError(result) # Wait until the job runs pending_state = u'1' for _ in range(5): if pending_state != u'0': invocation_info = JobInvocation.info({ 'id': invocation_command[u'id']}) pending_state = invocation_info[u'pending'] sleep(30) rec_logic = RecurringLogic.info({ 'id': invocation_command['recurring-logic-id']}) assert rec_logic['state'] == u'finished' assert rec_logic['iteration'] == u'2'
def test_positive_run_recurring_job_with_max_iterations(self): """Run default job template multiple times with max iteration :id: 37fb7d77-dbb1-45ae-8bd7-c70be7f6d949 :expectedresults: Verify the job was run not more than the specified number of times. """ invocation_command = make_job_invocation({ 'job-template': 'Run Command - SSH Default', 'inputs': 'command="ls"', 'search-query': "name ~ {0}".format(self.client.hostname), 'cron-line': '* * * * *', # every minute 'max-iteration': 2, # just two runs }) if not bz_bug_is_open(1431190): JobInvocation.get_output({ 'id': invocation_command[u'id'], 'host': self.client.hostname }) try: self.assertEqual(invocation_command['status'], u'queued') except AssertionError: result = 'host output: {0}'.format( ' '.join(JobInvocation.get_output({ 'id': invocation_command[u'id'], 'host': self.client.hostname}) ) ) raise AssertionError(result) sleep(150) rec_logic = RecurringLogic.info({ 'id': invocation_command['recurring-logic-id']}) self.assertEqual(rec_logic['state'], u'finished') self.assertEqual(rec_logic['iteration'], u'2')
def test_positive_run_recurring_job_with_max_iterations_by_ip( self, rex_contenthost): """Run default job template multiple times with max iteration by ip :id: 0a3d1627-95d9-42ab-9478-a908f2a7c509 :expectedresults: Verify the job was run not more than the specified number of times. :parametrized: yes """ client = rex_contenthost invocation_command = make_job_invocation({ 'job-template': 'Run Command - SSH Default', 'inputs': 'command="ls"', 'search-query': f"name ~ {client.hostname}", 'cron-line': '* * * * *', # every minute 'max-iteration': 2, # just two runs }) result = JobInvocation.info({'id': invocation_command['id']}) try: assert result['status'] == 'queued' except AssertionError: result = 'host output: {}'.format(' '.join( JobInvocation.get_output({ 'id': invocation_command['id'], 'host': client.hostname }))) raise AssertionError(result) sleep(150) rec_logic = RecurringLogic.info({'id': result['recurring-logic-id']}) assert rec_logic['state'] == 'finished' assert rec_logic['iteration'] == '2'
def test_positive_run_reccuring_job(self, fixture_vmsetup, fixture_org): """Tests Ansible REX reccuring job runs successfully multiple times :id: 49b0d31d-58f9-47f1-aa5d-561a1dcb0d66 :Steps: 0. Create a VM and register to SAT and prepare for REX (ssh key) 1. Run recurring Ansible Command job for the host 2. Check the multiple job results at the host :expectedresults: multiple asserts along the code :CaseAutomation: automated :CaseLevel: System :parametrized: yes """ self.org = fixture_org self.client = fixture_vmsetup # set connecting to host by ip Host.set_parameter({ 'host': self.client.hostname, 'name': 'remote_execution_connect_by_ip', 'value': 'True', }) invocation_command = make_job_invocation({ 'job-template': 'Run Command - Ansible Default', 'inputs': 'command="ls"', 'search-query': "name ~ {0}".format(self.client.hostname), 'cron-line': '* * * * *', # every minute 'max-iteration': 2, # just two runs }) JobInvocation.get_output({ 'id': invocation_command['id'], 'host': self.client.hostname }) try: assert invocation_command['status'] == 'queued' except AssertionError: result = 'host output: {0}'.format(' '.join( JobInvocation.get_output({ 'id': invocation_command['id'], 'host': self.client.hostname }))) raise AssertionError(result) sleep(150) rec_logic = RecurringLogic.info( {'id': invocation_command['recurring-logic-id']}) assert rec_logic['state'] == 'finished' assert rec_logic['iteration'] == '2'
def test_positive_run_recurring_job_with_max_iterations_by_ip( self, fixture_vmsetup, fixture_org): """Run default job template multiple times with max iteration by ip :id: 0a3d1627-95d9-42ab-9478-a908f2a7c509 :expectedresults: Verify the job was run not more than the specified number of times. :parametrized: yes """ self.org = fixture_org self.client = fixture_vmsetup # set connecting to host by ip Host.set_parameter({ 'host': self.client.hostname, 'name': 'remote_execution_connect_by_ip', 'value': 'True', }) invocation_command = make_job_invocation({ 'job-template': 'Run Command - SSH Default', 'inputs': 'command="ls"', 'search-query': "name ~ {0}".format(self.client.hostname), 'cron-line': '* * * * *', # every minute 'max-iteration': 2, # just two runs }) JobInvocation.get_output({ 'id': invocation_command['id'], 'host': self.client.hostname }) try: assert invocation_command['status'] == 'queued' except AssertionError: result = 'host output: {0}'.format(' '.join( JobInvocation.get_output({ 'id': invocation_command['id'], 'host': self.client.hostname }))) raise AssertionError(result) sleep(150) rec_logic = RecurringLogic.info( {'id': invocation_command['recurring-logic-id']}) assert rec_logic['state'] == 'finished' assert rec_logic['iteration'] == '2'
def test_positive_run_recurring_job_with_max_iterations_by_ip(self, fixture_vmsetup, fixture_org): """Run default job template multiple times with max iteration by ip :id: 0a3d1627-95d9-42ab-9478-a908f2a7c509 :expectedresults: Verify the job was run not more than the specified number of times. """ self.org = fixture_org self.client = fixture_vmsetup # set connecting to host by ip Host.set_parameter({ 'host': self.client.hostname, 'name': 'remote_execution_connect_by_ip', 'value': 'True', }) invocation_command = make_job_invocation({ 'job-template': 'Run Command - SSH Default', 'inputs': 'command="ls"', 'search-query': "name ~ {0}".format(self.client.hostname), 'cron-line': '* * * * *', # every minute 'max-iteration': 2, # just two runs }) if not bz_bug_is_open(1431190): JobInvocation.get_output({ 'id': invocation_command[u'id'], 'host': self.client.hostname }) try: assert invocation_command['status'] == u'queued' except AssertionError: result = 'host output: {0}'.format( ' '.join(JobInvocation.get_output({ 'id': invocation_command[u'id'], 'host': self.client.hostname}) ) ) raise AssertionError(result) sleep(150) rec_logic = RecurringLogic.info({ 'id': invocation_command['recurring-logic-id']}) assert rec_logic['state'] == u'finished' assert rec_logic['iteration'] == u'2'
def test_positive_run_reccuring_job(self, rex_contenthost): """Tests Ansible REX reccuring job runs successfully multiple times :id: 49b0d31d-58f9-47f1-aa5d-561a1dcb0d66 :Steps: 0. Create a VM and register to SAT and prepare for REX (ssh key) 1. Run recurring Ansible Command job for the host 2. Check the multiple job results at the host :expectedresults: multiple asserts along the code :CaseAutomation: Automated :CaseLevel: System :parametrized: yes """ client = rex_contenthost invocation_command = make_job_invocation({ 'job-template': 'Run Command - Ansible Default', 'inputs': 'command="ls"', 'search-query': f"name ~ {client.hostname}", 'cron-line': '* * * * *', # every minute 'max-iteration': 2, # just two runs }) result = JobInvocation.info({'id': invocation_command['id']}) try: assert result['status'] == 'queued' except AssertionError: result = 'host output: {}'.format(' '.join( JobInvocation.get_output({ 'id': invocation_command['id'], 'host': client.hostname }))) raise AssertionError(result) sleep(150) rec_logic = RecurringLogic.info({'id': result['recurring-logic-id']}) assert rec_logic['state'] == 'finished' assert rec_logic['iteration'] == '2'