Пример #1
0
def i_delete_one_of_the_chunks(step):
    manifest = release_local_data()
    remote_dir, manifest_name = os.path.split(world.manifest_url)

    chunk, md5sum, size = choice(choice(manifest["files"])["chunks"])

    chunk_url = os.path.join(remote_dir, chunk)
    world.deleted_chunk = chunk_url
    LOG.debug("Lettuce deleting %s" % chunk_url)

    world.driver.delete(chunk_url)
Пример #2
0
def i_delete_one_of_the_chunks(step):
    manifest = release_local_data()
    remote_dir, manifest_name = os.path.split(world.manifest_url)

    chunk, md5sum, size = choice(choice(manifest["files"])["chunks"])

    chunk_url = os.path.join(remote_dir, chunk)
    world.deleted_chunk = chunk_url
    LOG.debug("Lettuce deleting %s" % chunk_url)

    world.driver.delete(chunk_url)
Пример #3
0
def i_replace_the_manifest_with_old_repr(step):
    manifest = release_local_data()

    manifest_ini_path = os.path.join(world.basedir, "manifest.ini")
    with open(manifest_ini_path, 'w') as fd:
        convert_manifest(manifest).write(fd)

    world.driver.delete(world.manifest_url)

    world.manifest_url = world.driver.put(manifest_ini_path,
            os.path.join(os.path.dirname(world.manifest_url), ''))
    LOG.debug("NEW %s" % world.manifest_url)
Пример #4
0
def i_replace_the_manifest_with_old_repr(step):
    manifest = release_local_data()

    manifest_ini_path = os.path.join(world.basedir, "manifest.ini")
    with open(manifest_ini_path, 'w') as fd:
        convert_manifest(manifest).write(fd)

    world.driver.delete(world.manifest_url)

    world.manifest_url = world.driver.put(manifest_ini_path,
            os.path.join(os.path.dirname(world.manifest_url), ''))
    LOG.debug("NEW %s" % world.manifest_url)
Пример #5
0
def i_upload_stream_with_gzipping(context, gzip):
    gzip == 'True'
    src = [cloudfs.NamedStream(stream.src, os.path.basename(stream.src.name)) for stream in context.sources]
    for s in src:
        LOG.debug(s.name)
    time.sleep(1)
    if len(src) == 1:
        src = src[0]
    context.tr = largetransfer.Upload(src, context.remote_dir, gzip=gzip, chunk_size=5)
    context.tr.apply_async()
    try:
        context.tr.join()
    except:
        context.error = sys.exc_info()
    context.manifest = context.tr.manifest
    context.gzip = True
Пример #6
0
def convert_manifest(json_manifest):
    assert len(json_manifest["files"]) == 1
    assert json_manifest["files"][0]["compressor"] == "gzip"

    parser = ConfigParser()
    parser.add_section("snapshot")
    parser.add_section("chunks")

    parser.set("snapshot", "description", json_manifest["description"])
    parser.set("snapshot", "created_at", json_manifest["created_at"])
    parser.set("snapshot", "pack_method", json_manifest["files"][0]["compressor"])

    for chunk, md5sum, size in reversed(json_manifest["files"][0]["chunks"]):
        parser.set("chunks", chunk, md5sum)

    LOG.debug("CONVERT: %s", parser.items("chunks"))
    return parser
Пример #7
0
def convert_manifest(json_manifest):
    assert len(json_manifest["files"]) == 1
    assert json_manifest["files"][0]["compressor"] == "gzip"

    parser = ConfigParser()
    parser.add_section("snapshot")
    parser.add_section("chunks")

    parser.set("snapshot", "description", json_manifest["description"])
    parser.set("snapshot", "created_at", json_manifest["created_at"])
    parser.set("snapshot", "pack_method", json_manifest["files"][0]["compressor"])

    for chunk, md5sum, size in reversed(json_manifest["files"][0]["chunks"]):
        parser.set("chunks", chunk, md5sum)

    LOG.debug("CONVERT: %s", parser.items("chunks"))
    return parser
Пример #8
0
def make_file(base_dir, name=None, size=None):
    name = name or uuid.uuid4().hex
    file_path = os.path.join(base_dir, name)
    if size is None:
        size = random.randint(2, 20)
    if not os.path.exists(base_dir):
        os.mkdir(base_dir)
    subprocess.call([
            "dd",
            "if=/dev/urandom",
            "of=%s" % file_path,
            "bs=1M",
            "count=%s" % size
    ], stdout=open('/dev/null', 'w'), stderr=subprocess.STDOUT, close_fds=True)
    LOG.debug('Make file %s, %s' % (file_path, size))
    assert os.path.exists(file_path), file_path
    return file_path, size