def _stop_and_remove_all_containers(self): # check if there are any running containers first cmd = command_defs['docker_ps'] out, err, rc = run_command_to_completion_with_stdout_in_list(cmd) self.assertEqual(rc, 0) if len(out) > 1: # not counting docker ps header cmd = command_defs['docker_stop_and_remove_all_containers'] out, err, rc = run_command_to_completion_with_raw_stdout(cmd) self.assertEqual(rc, 0)
def _stop_and_remove_all_containers(self): # check if there are any running containers first cmd = command_defs['docker_ps'] out, err, rc = run_command_to_completion_with_stdout_in_list(cmd) self.assertEqual(rc, 0) if len(out) > 1: # not counting docker ps header cmd = command_defs['docker_stop_and_remove_all_containers'] out, err, rc = run_command_to_completion_with_raw_stdout(cmd) self.assertEqual(rc, 0)
def test_02_make_fetch(self): print "Test_02_make_fetch_Start:------------------" t0 = time.time() try: # Get list of images to fetch from the Makefile print "Get list of images to fetch ..." cmd = command_defs['makefile_fetch_images'] makefile_images_to_fetch, err, rc \ = run_command_to_completion_with_stdout_in_list(cmd) self.assertEqual(rc, 0) images_to_fetch = [] for image in makefile_images_to_fetch: tmp = ''.join(image.split()) images_to_fetch.append(tmp[len('dockerpull'):]) # make fetch print "Fetching images {} ...".format(images_to_fetch) cmd = command_defs['make_fetch'] out, err, rc = run_command_to_completion_with_raw_stdout(cmd) self.assertEqual(rc, 0) # verify that the images have been downloaded print "Verify images downloaded and present locally ..." cmd = command_defs['docker_images'] local_images, err, rc = \ run_command_to_completion_with_stdout_in_list(cmd) self.assertEqual(rc, 0) local_images_list = [] for local_image in local_images: words = local_image.split() local_images_list.append('{}:{}'.format(words[0], words[1])) intersection_list = [ i for i in images_to_fetch if i in local_images_list ] assert len(intersection_list) == len(images_to_fetch) finally: print "Test_02_make_fetch_End:------------------ took {} " \ "secs \n\n".format(time.time() - t0)
def test_02_make_fetch(self): print "Test_02_make_fetch_Start:------------------" t0 = time.time() try: # Get list of images to fetch from the Makefile print "Get list of images to fetch ..." cmd = command_defs['makefile_fetch_images'] makefile_images_to_fetch, err, rc \ = run_command_to_completion_with_stdout_in_list(cmd) self.assertEqual(rc, 0) images_to_fetch = [] for image in makefile_images_to_fetch: tmp = ''.join(image.split()) images_to_fetch.append(tmp[len('dockerpull'):]) # make fetch print "Fetching images {} ...".format(images_to_fetch) cmd = command_defs['make_fetch'] out, err, rc = run_command_to_completion_with_raw_stdout(cmd) self.assertEqual(rc, 0) # verify that the images have been downloaded print "Verify images downloaded and present locally ..." cmd = command_defs['docker_images'] local_images, err, rc = \ run_command_to_completion_with_stdout_in_list(cmd) self.assertEqual(rc, 0) local_images_list = [] for local_image in local_images: words = local_image.split() local_images_list.append('{}:{}'.format(words[0], words[1])) intersection_list = [i for i in images_to_fetch if i in local_images_list] assert len(intersection_list) == len(images_to_fetch) finally: print "Test_02_make_fetch_End:------------------ took {} " \ "secs \n\n".format(time.time() - t0)