How to use delete_containers method in tempest

Best Python code snippet using tempest_python

paws_ci_tests.py

Source:paws_ci_tests.py Github

copy

Full Screen

...65 cmd = 'ansible-playbook playbooks/create_paws_containers.yml'66 exit_code = self.runner(cmd)67 if exit_code != 0:68 raise Exception('Failed to create paws image containers.')69 def delete_containers(self):70 cmd = 'ansible-playbook playbooks/delete_containers.yml'71 exit_code = self.runner(cmd)72 if exit_code != 0:73 raise Exception('Failed to delete containers.')74 def create_vms(self):75 cmd = 'ansible-playbook playbooks/create_vms.yml'76 exit_code = self.runner(cmd)77 if exit_code != 0:78 raise Exception('Failed to create vms.')79 def delete_vms(self):80 cmd = 'ansible-playbook playbooks/delete_vms.yml'81 exit_code = self.runner(cmd)82 if exit_code != 0:83 raise Exception('Failed to delete vms.')84 def install_paws(self, install_choice):85 cmd = 'ansible-playbook playbooks/install_paws.yml -e '\86 '"install_type=%s" -i %s' % (install_choice, self.inventory)87 exit_code = self.runner(cmd)88 if exit_code != 0:89 raise Exception('Failed to install paws.')90 def unregister_system(self):91 cmd = 'ansible-playbook playbooks/unregister.yml -i %s' %\92 self.inventory93 exit_code = self.runner(cmd)94 if exit_code != 0:95 raise Exception('Failed to unregister systems.')96 def run_paws(self, task):97 cmd = 'ansible-playbook playbooks/run_paws.yml -e'\98 '"task=%s" -i %s' % (task, self.inventory)99 exit_code = self.runner(cmd)100 if exit_code != 0:101 raise Exception('Failed to run paws task %s.' % task)102 def configure_paws(self):103 cmd = 'ansible-playbook playbooks/configure_paws.yml -i %s' %\104 self.inventory105 exit_code = self.runner(cmd)106 if exit_code != 0:107 raise Exception('Failed to configure paws.')108 def unique_resource(self):109 random_num = random.randrange(0, 10000)110 cmd = 'sed -i "s/{{ random }}/%s/g" %s' % (random_num, self.vars_file)111 exit_code = self.runner(cmd)112 if exit_code != 0:113 raise Exception('Failed to set unique resource name.')114 def tc_01(self):115 """Test case 01.116 Actions:117 1. Create containers118 2. Install paws by pip119 3. Configure paws120 4. Test all paws tasks121 5. Un-register systems (if applicable)122 6. Delete containers123 """124 self.unique_resource()125 try:126 self.create_containers()127 self.install_paws('pip')128 self.configure_paws()129 self.run_paws('provision')130 self.run_paws('winsetup')131 self.run_paws('show')132 self.run_paws('group')133 self.run_paws('teardown')134 self.unregister_system()135 self.delete_containers()136 except Exception:137 self.unregister_system()138 self.delete_containers()139 raise SystemExit(1)140 def tc_02(self):141 """Test case 02.142 Actions:143 1. Create vms144 2. Install paws by pip145 3. Configure paws146 4. Test all paws tasks147 5. Un-register systems (if applicable)148 6. Delete vms149 """150 self.unique_resource()151 try:152 self.create_vms()153 self.install_paws('pip')154 self.configure_paws()155 self.run_paws('provision')156 self.run_paws('winsetup')157 self.run_paws('show')158 self.run_paws('group')159 self.run_paws('teardown')160 self.unregister_system()161 self.delete_vms()162 except Exception:163 self.unregister_system()164 self.delete_vms()165 raise SystemExit(1)166 def tc_03(self):167 """Test case 03.168 Actions:169 1. Create containers170 2. Install paws by rpm171 3. Configure paws172 4. Test all paws tasks173 5. Un-register systems (if applicable)174 6. Delete containers175 """176 self.unique_resource()177 try:178 self.create_containers()179 self.install_paws('rpm')180 self.configure_paws()181 self.run_paws('provision')182 self.run_paws('winsetup')183 self.run_paws('show')184 self.run_paws('group')185 self.run_paws('teardown')186 self.unregister_system()187 self.delete_containers()188 except Exception:189 self.unregister_system()190 self.delete_containers()191 raise SystemExit(1)192 def tc_04(self):193 """Test case 04.194 Actions:195 1. Create vms196 2. Install paws by rpm197 3. Configure paws198 4. Test all paws tasks199 5. Un-register systems (if applicable)200 6. Delete vms201 """202 self.unique_resource()203 try:204 self.create_vms()205 self.install_paws('rpm')206 self.configure_paws()207 self.run_paws('provision')208 self.run_paws('winsetup')209 self.run_paws('show')210 self.run_paws('group')211 self.run_paws('teardown')212 self.unregister_system()213 self.delete_vms()214 except Exception:215 self.unregister_system()216 self.delete_vms()217 raise SystemExit(1)218 def tc_05(self):219 """Test case 05.220 Actions:221 1. Create containers based on paws supported docker images222 2. Test all paws tasks223 3. Un-registery systems (if applicable)224 4. Delete containers225 """226 self.unique_resource()227 try:228 self.create_paws_containers()229 self.run_paws('provision')230 self.run_paws('winsetup')231 self.run_paws('show')232 self.run_paws('group')233 self.run_paws('teardown')234 self.unregister_system()235 self.delete_containers()236 except Exception:237 self.unregister_system()238 self.delete_containers()239 raise SystemExit(1)240if __name__ == '__main__':241 parser = argparse.ArgumentParser(description='PAWS CI TEST CASES')242 sub_parser = parser.add_subparsers()243 tc_01 = sub_parser.add_parser('run', help='Run a test case')244 tc_01.add_argument(245 '-tc',246 action='store',247 choices=('tc_01', 'tc_02', 'tc_03', 'tc_04', 'tc_05'),248 help='List of test cases'249 )250 args = parser.parse_args()251 obj = TestPaws()252 getattr(obj, args.tc)()

Full Screen

Full Screen

test.py

Source:test.py Github

copy

Full Screen

...14def get_container(con_id):15 return requests.get(_url('/containers/{:s}'.format(con_id)))16def get_container_log(con_id):17 return requests.get(_url('containers/{:s}/logs'.format(con_id)))18def delete_containers():19 return requests.delete(_url('/containers'))20def delete_container(con_id):21 return requests.delete(_url('/containers/{:s}'.format(con_id)))22def delete_images():23 return requests.delete(_url('/images'))24def delete_image(i_id):25 return requests.delete(_url('/images/{:s}'.format(i_id)))26if __name__ == "__main__":27 print(get_containers())28 print(get_containers_running())29 print(get_services())30 print(get_nodes())31 print(get_images())32 print(get_container("0cf4b3f313f4"))33 #print(get_container_log("b9babde8c4db"))34 print(delete_containers())35 print(delete_container("0cf4b3f313f4"))36 print(delete_images())...

Full Screen

Full Screen

remove_old_containers.py

Source:remove_old_containers.py Github

copy

Full Screen

...4#before you shoul auth in ecr $(aws ecr --login)5REGION='change it'6REPO='change it'7REGISTRY='change it'8def delete_containers(data, cli):9 counter = 010 for d in data:11 counter += 112 if counter > 4:13 cli.batch_delete_image(14 registryId=REGISTRY,15 repositoryName=REPO,16 imageIds=[17 {18 'imageDigest': d.imageDigest19 }20 ]21 )22 print "deleted " + d.imageDigest + " pushed date: " + str(d.imagePushedAt)23def get_list(cli):24 response = cli.describe_images(25 registryId=REGISTRY,26 repositoryName=REPO,27 filter={28 'tagStatus': 'UNTAGGED'29 }30 )31 data = []32 for e in response[u'imageDetails']:33 data.append(namedtuple('image', e.keys())(*e.values()))34 data.sort(key=lambda x: x.imagePushedAt, reverse=True)35 return data36def rem():37 cli = boto3.client('ecr', region_name=REGION)38 data = get_list(cli)39 delete_containers(data, cli)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful