Exemple #1
0
    def test_monitor2_images(self):
        """
        Test the POST, GET and DELETE images APIs.
        """
        # Upload image stack
        url = _MON_IMAGES_URL
        url = add_url_argument(url, STACK_TYPE, MONITOR2, True)
        url = add_url_argument(url, NAME, 'monitor1_images_name')
        url = add_url_argument(url, DESCRIPTION, 'monitor1 images description')

        response = upload_file(self, _TEST_DIR, url, _MON2_IMAGES, 200)
        image_stack_uuid = response[UUID]

        # Ensure duplicate image stacks cannot be uploaded
        upload_file(self, _TEST_DIR, url, _MON2_IMAGES, 403)

        # Ensure image stack exists in the database and can be retrieved
        response = get_data(self, _MON_IMAGES_URL, 200)
        record_found = False
        for record in response[MONITOR_IMAGES]:
            if record[UUID] == image_stack_uuid:
                record_found = True
        msg = "Monitor image stack %s doesn't exist in the database." % image_stack_uuid
        self.assertTrue(record_found, msg)

        # Delete image stack
        url = add_url_argument(_IMAGES_URL, UUID, image_stack_uuid, True)
        delete_data(self, url, 200)

        # Ensure image stack no longer exists in the database
        response = get_data(self, _MON_IMAGES_URL, 200)
        for record in response[MONITOR_IMAGES]:
            msg = "Monitor image stack %s still exists in the database." % record[UUID]
            self.assertNotEqual(image_stack_uuid, record[UUID], msg)
Exemple #2
0
    def exercise_file_upload_api(self, url, filename):
        response_key = url.split("/")[-1]

        # Test successful file upload
        response = upload_file(self, _TEST_DIR, url, filename, 200)
        uuid = response[UUID]

        # Test error code 403: File already exists.
        upload_file(self, _TEST_DIR, url, filename, 403)

        # Test error code 415: File is not a valid FASTA file.
        upload_file(self, _TEST_DIR, url, _INVALID_FASTA_FILENAME, 415)

        # Test successful retrieval of uploaded file
        response = get_data(self, url, 200)
        retrieved_uuid = response[response_key][0][UUID]
        msg = "Expected uuid (%s) doesn't match observed uuid (%s) for %s" % \
              (uuid, retrieved_uuid, url)
        self.assertEqual(uuid, retrieved_uuid, msg)

        # Test successful deletion of uploaded file
        delete_data(self, url + "?uuid=%s" % uuid, 200)

        # Test unsuccessful deletion of non-existent file
        delete_data(self, url + "?uuid=%s" % str(uuid4()), 404)
Exemple #3
0
    def test_images(self):
        """
        Test the POST, GET and DELETE images APIs.
        """
        # Upload image stack
        url = _IMAGES_URL
        url = add_url_argument(url, EXP_DEF, 'Beta_24b_p1_V6', True)
        url = add_url_argument(url, NAME, 'golden_run')
        url = add_url_argument(url, DESCRIPTION, 'Short description.')

        response = upload_file(self, _TEST_DIR, url, _PNG_IMAGES, 200)
        image_stack_uuid = response[UUID]

        # Ensure duplicate image stacks cannot be uploaded
        response = upload_file(self, _TEST_DIR, url, _PNG_IMAGES, 403)

        # Ensure image stack exists in the database and can be retrieved
        response = get_data(self, _IMAGES_URL, 200)
        record_found = False
        for record in response[IMAGES]:
            if record[UUID] == image_stack_uuid:
                record_found = True
        msg = "Image stack %s doesn't exist in the database." % image_stack_uuid
        self.assertTrue(record_found, msg)

        # Delete image stack
        url = add_url_argument(_IMAGES_URL, UUID, image_stack_uuid, True)
        delete_data(self, url, 200)

        # Ensure image stack no longer exists in the database
        response = get_data(self, _IMAGES_URL, 200)
        for record in response[IMAGES]:
            msg = "Image stack %s still exists in the database." % record[UUID]
            self.assertNotEqual(image_stack_uuid, record[UUID], msg)
Exemple #4
0
    def test_absorption(self):
        # Upload targets and probes files
        response = upload_file(self, _TEST_DIR, _PROBES_URL, _PROBES_FILENAME,
                               200)
        probes_uuid = response[UUID]
        response = upload_file(self, _TEST_DIR, _TARGETS_URL,
                               _TARGETS_FILENAME, 200)
        targets_uuid = response[UUID]

        # Post absorption job
        url = _ABSORPTION_URL + "?probes=%s&targets=%s&job_name=%s&%s=%s" % \
             (probes_uuid, targets_uuid, _JOB_NAME, STRICT, _STRICT)
        response = post_data(self, url, 200)
        abs_job_uuid = response[UUID]

        running = True
        job_details = None
        while running:
            time.sleep(10)
            response = get_data(self, _ABSORPTION_URL, 200)
            for job in response[_ABSORPTION]:
                if abs_job_uuid == job[UUID]:
                    job_details = job
                    running = job_details[_STATUS] == 'running'

        # Copy result file to cwd for bamboo to ingest as an artifact
        absorption_path = None
        if _RESULT in job_details:
            absorption_path = job_details[_RESULT]
            if absorption_path and os.path.isfile(absorption_path):
                shutil.copy(absorption_path, "observed_absorption.txt")

        # Clean up by removing targets and probes files
        delete_data(self, _PROBES_URL + "?uuid=%s" % probes_uuid, 200)
        delete_data(self, _TARGETS_URL + "?uuid=%s" % targets_uuid, 200)

        msg = "Expected absorption job status succeeded, but found: %s" % \
              job_details[_STATUS]
        self.assertEquals(job_details[_STATUS], "succeeded", msg)

        exp_result_path = os.path.join(
            os.path.abspath(os.path.dirname(__file__)),
            _EXPECTED_RESULT_FILENAME)
        msg = "Observed result (%s) doesn't match expected result (%s)." % \
              (absorption_path, exp_result_path)
        self.assertTrue(filecmp.cmp(exp_result_path, absorption_path), msg)

        # Delete absorption job
        delete_data(self, _ABSORPTION_URL + "?uuid=%s" % abs_job_uuid, 200)

        # Ensure job no longer exists in the database
        response = get_data(self, _ABSORPTION_URL, 200)
        for job in response[_ABSORPTION]:
            msg = "Absorption job %s still exists in database." % abs_job_uuid
            self.assertNotEqual(abs_job_uuid, job[UUID], msg)
Exemple #5
0
    def test_bin_images(self):
        # Upload image stack
        url = _IMAGES_URL
        url = add_url_argument(url, EXP_DEF, 'Beta_24b_p1_V6', True)
        url = add_url_argument(url, NAME, 'bin_images')
        url = add_url_argument(url, DESCRIPTION, 'Binary image stack.')

        response = upload_file(self, _TEST_DIR, url, _BIN_IMAGES, 200)
        msg = "Expected number of images (%d) not equal to observed (%d)." % \
            (4, response[NUM_IMAGES])
        self.assertEqual(response[NUM_IMAGES], 4, msg)

        # Delete image stack
        url = add_url_argument(_IMAGES_URL, UUID, response[UUID], True)
        delete_data(self, url, 200)
Exemple #6
0
 def test_invalid_ham_dir_name(self):
     url = _IMAGES_URL
     url = add_url_argument(url, EXP_DEF, 'Beta_24b_p1_V6', True)
     url = add_url_argument(url, NAME, 'invalid ham dir name')
     url = add_url_argument(url, DESCRIPTION, 'invalid ham dir name')
     upload_file(self, _TEST_DIR, url, _INVALID_HAM_NAME, 415)
Exemple #7
0
 def test_not_an_archive(self):
     url = _IMAGES_URL
     url = add_url_argument(url, EXP_DEF, 'Beta_24b_p1_V6', True)
     url = add_url_argument(url, NAME, 'not_an_archive')
     url = add_url_argument(url, DESCRIPTION, 'Not an archive.')
     upload_file(self, _TEST_DIR, url, _NOT_AN_ARCHIVE, 415)
Exemple #8
0
 def test_empty_archive(self):
     url = _IMAGES_URL
     url = add_url_argument(url, EXP_DEF, 'Beta_24b_p1_V6', True)
     url = add_url_argument(url, NAME, 'empty_archive')
     url = add_url_argument(url, DESCRIPTION, 'Empty archive.')
     upload_file(self, _TEST_DIR, url, _NO_IMAGES, 415)
Exemple #9
0
 def test_invalid_exp_def(self):
     url = _IMAGES_URL
     url = add_url_argument(url, EXP_DEF, 'invalid_exp_def', True)
     url = add_url_argument(url, NAME, 'invalid_exp_def')
     url = add_url_argument(url, DESCRIPTION, 'Invalid exp def.')
     upload_file(self, _TEST_DIR, url, _PNG_IMAGES, 404)
Exemple #10
0
    def test_replay(self):
        """
        Test the POST, GET and DELETE images APIs.
        """

        # Upload ham image stack
        ham_url = _IMAGES_URL
        ham_url = add_url_argument(ham_url, EXP_DEF, 'Beta_24b_p1_V6', True)
        ham_url = add_url_argument(ham_url, NAME, 'golden_run')
        ham_url = add_url_argument(ham_url, DESCRIPTION, 'Short description.')
        ham_response = upload_file(self, _TEST_DIR, ham_url, _HAM_IMAGES, 200)
        ham_uuid = ham_response[UUID]

        # Upload monitor 1 image stack
        mon1_url = _MON_IMAGES_URL
        mon1_url = add_url_argument(mon1_url, STACK_TYPE, MONITOR1, True)
        mon1_url = add_url_argument(mon1_url, NAME, 'monitor1_images_name')
        mon1_url = add_url_argument(mon1_url, DESCRIPTION, 'monitor1 images description')
        mon1_response = upload_file(self, _TEST_DIR, mon1_url, _MON1_IMAGES, 200)
        mon1_uuid = mon1_response[UUID]

        # Upload monitor 2 image stack
        mon2_url = _MON_IMAGES_URL
        mon2_url = add_url_argument(mon2_url, STACK_TYPE, MONITOR2, True)
        mon2_url = add_url_argument(mon2_url, NAME, 'monitor2_images_name')
        mon2_url = add_url_argument(mon2_url, DESCRIPTION, 'monitor2 images description')
        mon2_response = upload_file(self, _TEST_DIR, mon2_url, _MON2_IMAGES, 200)
        mon2_uuid = mon2_response[UUID]

        # create a replay image stack from existing stacks
        replay_url = _REPLAY_IMAGES_URL
        replay_url = add_url_argument(replay_url, NAME, 'replay_images_name', True)
        replay_url = add_url_argument(replay_url, HAM_NAME, 'golden_run')
        replay_url = add_url_argument(replay_url, MON1_NAME, 'monitor1_images_name')
        replay_url = add_url_argument(replay_url, MON2_NAME, 'monitor2_images_name')
        replay_url = add_url_argument(replay_url, DESCRIPTION, 'replay images description')
        replay_response = post_data(self, replay_url, 200)
        replay_uuid = replay_response[UUID]

        # try to add replay image stack with same name
        replay_url = _REPLAY_IMAGES_URL
        replay_url = add_url_argument(replay_url, NAME, 'replay_images_name', True)
        replay_url = add_url_argument(replay_url, HAM_NAME, 'golden_run')
        replay_url = add_url_argument(replay_url, MON1_NAME, 'monitor1_images_name')
        replay_url = add_url_argument(replay_url, MON2_NAME, 'monitor2_images_name')
        replay_url = add_url_argument(replay_url, DESCRIPTION, 'replay images description')
        post_data(self, replay_url, 403)

        # try to add replay image stack comprised of the same ham/mon image stacks
        replay_url = _REPLAY_IMAGES_URL
        replay_url = add_url_argument(replay_url, NAME, 'different_replay_images_name', True)
        replay_url = add_url_argument(replay_url, HAM_NAME, 'golden_run')
        replay_url = add_url_argument(replay_url, MON1_NAME, 'monitor1_images_name')
        replay_url = add_url_argument(replay_url, MON2_NAME, 'monitor2_images_name')
        replay_url = add_url_argument(replay_url, DESCRIPTION, 'replay images description')
        post_data(self, replay_url, 403)

        # Delete image stacks
        url = add_url_argument(_IMAGES_URL, UUID, ham_uuid, True)
        delete_data(self, url, 200)
        url = add_url_argument(_IMAGES_URL, UUID, mon1_uuid, True)
        delete_data(self, url, 200)
        url = add_url_argument(_IMAGES_URL, UUID, mon2_uuid, True)
        delete_data(self, url, 200)
        url = add_url_argument(_IMAGES_URL, UUID, replay_uuid, True)
        delete_data(self, url, 200)
Exemple #11
0
 def test_invalid_mon_bad_compression(self):
     url = _MON_IMAGES_URL
     url = add_url_argument(url, STACK_TYPE, MONITOR1, True)
     url = add_url_argument(url, NAME, 'invalid monitor bad compression')
     url = add_url_argument(url, DESCRIPTION, 'invalid monitor bad compression')
     upload_file(self, _TEST_DIR, url, _INVALID_MON_BADCOMPRESS, 415)
Exemple #12
0
 def test_invalid_mon_uncropped(self):
     url = _MON_IMAGES_URL
     url = add_url_argument(url, STACK_TYPE, MONITOR1, True)
     url = add_url_argument(url, NAME, 'invalid monitor crop on name')
     url = add_url_argument(url, DESCRIPTION, 'invalid monitor crop on name')
     upload_file(self, _TEST_DIR, url, _INVALID_MON_CROP_ON, 415)
Exemple #13
0
 def test_invalid_mon_no_images(self):
     url = _MON_IMAGES_URL
     url = add_url_argument(url, STACK_TYPE, MONITOR1, True)
     url = add_url_argument(url, NAME, 'invalid monitor no images name')
     url = add_url_argument(url, DESCRIPTION, 'invalid monitor no images name')
     upload_file(self, _TEST_DIR, url, _INVALID_MON_NO_IMAGES, 415)
Exemple #14
0
 def test_invalid_mon_additional_files(self):
     url = _MON_IMAGES_URL
     url = add_url_argument(url, STACK_TYPE, MONITOR1, True)
     url = add_url_argument(url, NAME, 'invalid monitor additional files name')
     url = add_url_argument(url, DESCRIPTION, 'invalid monitor additional files name')
     upload_file(self, _TEST_DIR, url, _INVALID_MON_ADD_FILES, 415)
Exemple #15
0
 def test_invalid_mon_dir_name(self):
     url = _MON_IMAGES_URL
     url = add_url_argument(url, STACK_TYPE, MONITOR1, True)
     url = add_url_argument(url, NAME, 'invalid monitor root dir name')
     url = add_url_argument(url, DESCRIPTION, 'invalid monitor root dir name')
     upload_file(self, _TEST_DIR, url, _INVALID_MON_ROOT_NAME, 415)