示例#1
0
 def test_six(self):
     """
     Verify that a file uploaded to one server can be Deleted from another server
     """
     self.test_name = self.test_six.__doc__
     try:
         txn.test_configs.API_SERVER_URL = self.servers[0]
         response = txn.upload_a_file(
             config.TEST_DATA.milestone_1b.file_to_upload_2)
         assert (response.status_code == 200)
         id = response.text
         r = txn.retrive_a_file_by_id(id)
         assert (r.status_code == 200)
         txn.test_configs.API_SERVER_URL = self.servers[1]
         delete = txn.delete_a_file_by_id(id)
         assert (delete.status_code == 200)
         txn.test_configs.API_SERVER_URL = self.servers[0]
         r = txn.retrive_a_file_by_id(id)
         assert (r.status_code == 404)
         txn.test_configs.API_SERVER_URL = self.servers[2]
         list_of_files = txn.list_available_files().json()
         assert (str(id) not in str(list_of_files))
         self.status = 'Pass'
     except Exception as e:
         self.status = 'Fail'
         raise e
示例#2
0
    def test_four(self):
        """
        Verify redundancy 
        - Have a known configuration of node count , chunk size  and redunduncy level
        - Load a sequence of files with specific sizes
        - Delete number of nodes as redunduncy specification
        - Check if the files can be retrived
        """
        self.test_name = self.test_four.__doc__
        try:
            app_config = json.load(
                open(config.TEST_DATA.milestone_3.app_config_location))
            node_count = app_config['node_count']
            size_per_slice = app_config['size_per_slice']
            redunduncy_count = app_config['redundancy_count']
            print("\nVerifying Pre-Requisites for the Test")
            assert (node_count == 10)
            assert (size_per_slice == 1024)
            assert (redunduncy_count == 1)
            print("\nSuccessfully verified Pre-Requisites for the test")

            #Load 10KB file
            md5 = FileHash('sha1')
            input_checksum = md5.hash_file(
                config.TEST_DATA.milestone_3.file_1_path)
            rs = txn.upload_a_file(config.TEST_DATA.milestone_3.file_1_path)
            assert (rs.status_code == 200)
            file_id = str(rs.text)
            nodes = []
            for items in os.listdir(
                    config.TEST_DATA.milestone_3.location_of_nodes):
                if (os.path.isdir(
                        config.TEST_DATA.milestone_3.location_of_nodes + '/' +
                        items) and 'node_' in items):
                    nodes.append(items)

            # delete a node
            #shutil.rmtree( os.path.join( config.TEST_DATA.milestone_3.location_of_nodes , nodes[0]) )
            #rename a file
            os.rename(
                os.path.join(config.TEST_DATA.milestone_3.location_of_nodes,
                             nodes[0]),
                os.path.join(config.TEST_DATA.milestone_3.location_of_nodes,
                             'XYZQBC'))

            # try getting the file back
            rs = txn.retrive_a_file_by_id(file_id)
            assert (rs.status_code == 200)
            open('Output.file', 'wb+').write(rs.content)
            output_checksum = md5.hash_file('Output.file')
            assert input_checksum, output_checksum
            self.status = 'Pass'
        except Exception as e:
            self.status = 'Fail'
            raise e
 def test_seven(self):
     """
     Verify that appopriate error message is displayed while trying to access a file that doesnt exist
     """
     self.test_name = self.test_seven.__doc__
     try:
         r = txn.retrive_a_file_by_id(str(uuid4()))
         assert (r.status_code == 404)
         self.status = 'Pass'
     except Exception as e:
         self.status = 'Fail'
         raise e
 def test_six(self):
     """
     Verify that a delete operation happens successfully
     """
     self.test_name = self.test_six.__doc__
     try:
         response = txn.upload_a_file(
             config.TEST_DATA.test_five.file_to_upload)
         assert (response.status_code == 200)
         id = response.text
         r = txn.retrive_a_file_by_id(id)
         assert (r.status_code == 200)
         delete = txn.delete_a_file_by_id(id)
         assert (delete.status_code == 200)
         r = txn.retrive_a_file_by_id(id)
         assert (r.status_code == 404)
         list_of_files = txn.list_available_files().json()
         assert (str(id) not in str(list_of_files))
         self.status = 'Pass'
     except Exception as e:
         self.status = 'Fail'
         raise e
示例#5
0
 def test_download(self):
     """
     Verify that Download of a file works fine
     """
     self.test_name = self.test_download.__doc__
     try:
         download_response = txn.retrive_a_file_by_id(
             os.environ['sanity_file_name'])
         # , "status code 200 was required during downlod, but got {0}".format(download_response.status_code))
         assert (download_response.status_code == 200)
         self.status = 'Pass'
     except Exception as e:
         self.status = 'Fail'
         raise e
 def test_four(self):
     """
     Verify that the uploaded file can be reterived sucessfully - Verify check sum before upload and after reterive
     """
     self.test_name = self.test_four.__doc__
     try:
         md5 = FileHash('sha1')
         hash = md5.hash_file(config.TEST_DATA.test_four.file_to_upload)
         response = txn.upload_a_file(
             config.TEST_DATA.test_four.file_to_upload)
         assert (response.status_code == 200)
         id = response.text
         r = txn.retrive_a_file_by_id(id)
         open(config.TEST_DATA.test_four.file_name, 'wb+').write(r.content)
         hash_2 = md5.hash_file(config.TEST_DATA.test_four.file_name)
         assert (hash == hash_2)
         self.status = 'Pass'
     except Exception as e:
         self.status = 'Fail'
         raise e
示例#7
0
 def test_four(self):
     """
     Verify that a file uploaded to a server can be retrieved from another server with integrity
     """
     self.test_name = self.test_four.__doc__
     try:
         txn.test_configs.API_SERVER_URL = self.servers[1]
         md5 = FileHash('sha1')
         hash = md5.hash_file(
             config.TEST_DATA.milestone_1b.file_to_upload_1)
         response = txn.upload_a_file(
             config.TEST_DATA.milestone_1b.file_to_upload_1)
         assert (response.status_code == 200)
         id = response.text
         txn.test_configs.API_SERVER_URL = self.servers[0]
         r = txn.retrive_a_file_by_id(id)
         open(config.TEST_DATA.milestone_1b.file_name_1,
              'wb+').write(r.content)
         hash_2 = md5.hash_file(config.TEST_DATA.milestone_1b.file_name_1)
         assert (hash == hash_2)
         self.status = 'Pass'
     except Exception as e:
         self.status = 'Fail'
         raise e