Beispiel #1
0
    def _downloadWin2k8SrvR2Range(self):
	"""Manual test for downloading a range of win2k8srvr2 - you must provision this first"""
	vdi_uuid = "35b420af-9fc1-48de-b0dd-13cb5c27828f"
	req_start = "6442254336"
	req_end   = "7050322431"
	dest = "win2k8srvr2-%s-%s-download.vhd" % (req_start, req_end)

	hostname = testsetup.HOST
        bitmap = transferclient.get_vdi_bitmap(hostname, vdi_uuid)
	record = expose_vdi_as_vhd(hostname,vdi_uuid, bitmap)

        download_range_of_vhd(record, dest, req_start, req_end)
        unexpose(hostname, record)
Beispiel #2
0
    def _downloadWin2k8SrvR2Range(self):
        """Manual test for downloading a range of win2k8srvr2 - you must provision this first"""
        vdi_uuid = "35b420af-9fc1-48de-b0dd-13cb5c27828f"
        req_start = "6442254336"
        req_end = "7050322431"
        dest = "win2k8srvr2-%s-%s-download.vhd" % (req_start, req_end)

        hostname = testsetup.HOST
        bitmap = transferclient.get_vdi_bitmap(hostname, vdi_uuid)
        record = expose_vdi_as_vhd(hostname, vdi_uuid, bitmap)

        download_range_of_vhd(record, dest, req_start, req_end)
        unexpose(hostname, record)
Beispiel #3
0
    def _downloadFromVdi(self, vdi_uuid, dest, request_size):
	"""Given a vdi_uuid, the test case downloads the vdi as a VHD"""
	"""and compares the original bitmap with the downloaded bitmap"""

	hostname = testsetup.HOST
        bitmap = transferclient.get_vdi_bitmap(hostname, vdi_uuid)
	record = expose_vdi_as_vhd(hostname,vdi_uuid, bitmap)

	#Download VHD using the python bitsclient
	bits_download_vhd(record, dest, request_size)
	logging.debug("Downloaded %s" % dest)

	assert_matching_bitmap(dest, bitmap) #Check the block allocation table
	check_downloaded_bitmaps(dest)
	unexpose(hostname, record)
Beispiel #4
0
    def _downloadFromVdi(self, vdi_uuid, dest, request_size):
        """Given a vdi_uuid, the test case downloads the vdi as a VHD"""
        """and compares the original bitmap with the downloaded bitmap"""

        hostname = testsetup.HOST
        bitmap = transferclient.get_vdi_bitmap(hostname, vdi_uuid)
        record = expose_vdi_as_vhd(hostname, vdi_uuid, bitmap)

        #Download VHD using the python bitsclient
        bits_download_vhd(record, dest, request_size)
        logging.debug("Downloaded %s" % dest)

        assert_matching_bitmap(dest, bitmap)  #Check the block allocation table
        check_downloaded_bitmaps(dest)
        unexpose(hostname, record)
Beispiel #5
0
    def _doTest(self, src, frag_size, sleep_time, delta, randomise_delta=False):
        """Tests how we handle the client droping/losing packets
        when they are POSTing a BITS request"""

        physize = os.stat(src).st_size                
        vdi_mb = vhd.get_virtual_size(src)
        
        #Expose a new VDI
        record, hostname = create_and_expose(vdi_mb)
        url_path = record['url_path'] + ".vhd"

        #Create BITS Session
        conn, session = create_BITS_session(record)
        
        logging.debug("Frag_Size = %d" % frag_size)
        
        #Adjust frag size for the case we have small disks
        if physize < frag_size:
            frag_size = physize

        #Initialise Upload variables
        range_start = 0
        range_end = frag_size
        file_offset = 0
        fh = open(src, 'r')
        count = 0
        while file_offset < physize:
            if randomise_delta:
                #Generate a random number within the request range
                delta = random.randint(0, range_end - range_start)
                logging.debug("Random Delta = %d" % delta)

            if range_end == physize:
                delta = 0

            logging.debug("Uploading %d-%d/%d" % (range_start, range_end, physize))
            data_size = (range_end - range_start - delta)

            if count == 1:
                data_size = 10
            logging.debug("Actually uploading %d bytes" % data_size)
            data = fh.read(data_size)
            logging.debug("Data Read")
            try:
                bits.fragment(conn, session, url_path, data, range_start, range_end, physize)
            except:
                logging.debug("Fragment Sent partially %d-%d/%d" % (range_start, range_end, physize))

            file_offset += (range_end - range_start - delta)
            range_start = file_offset + 1

            count += 1

            if count > 1:
                sys.exit(1)
    
            #Condition for last frag upload
            range_end = file_offset + frag_size
            if physize < range_end:
                range_end = physize

            #Sleep before creating new connection 
            logging.debug("Sleeping for %d seconds" % sleep_time)
            time.sleep(sleep_time)

            #Garbage Collect to make sure we don't run out of memory
            data = ''
            gc.collect()
            
            #Create new connection
            logging.debug("Get a new connection...")
            conn = bits.open_connection(get_proto(record), record['ip'], record['port'])

        #Close file handle
        fh.close()
        
        #Unexpose the transfervm
        logging.debug("Unexposing the Transfer VM for vdi %s" % record['vdi_uuid'])
        transferclient.unexpose(hostname, vdi_uuid=record['vdi_uuid'])

        #Retrieve the blockmap to expose the VDI as a vhd
        bitmap = transferclient.get_vdi_bitmap(hostname, record['vdi_uuid'])
        logging.debug("Got bitmap %s" % bitmap)

        #Expose disk with vhd_block_map
        args = {'transfer_mode': 'bits',
                'vdi_uuid': record['vdi_uuid'],
                'network_uuid': 'management',
                'vhd_blocks': bitmap,
                'vhd_uuid': record['vdi_uuid']}

        transferclient.expose(hostname, **args)

        record = transferclient.get_record(hostname, vdi_uuid=record['vdi_uuid'])
        logging.debug("Got new record: %s" % record)

        dst = 'test-download.vhd'
        logging.debug("Destination file will be %s" % dst)
        request_size = 200*M
        vhd_tests.bits_download_vhd(record, dst, request_size)
        
        #Compare the two VHDs to check they are identical
        rc = vhd.diff(src, dst)
        logging.debug("Return Code %s" % rc)
        
        #Unexpose the transfervm
        logging.debug("Unexposing the Transfer VM for vdi %s" % record['vdi_uuid'])
        transferclient.unexpose(hostname, vdi_uuid=record['vdi_uuid'])
        
        #Cleanup Disks
        transferclient.remove_vdi(hostname, record['vdi_uuid'])
        
        #Remove Downloaded File
        os.unlink(dst)