import arvados
import arvados.collection

# Need to create 5000 collections each one containing a file with different contents

api = arvados.api()

project_uuid = api.groups().create(body={"group": {"name": "many collections", "group_class": "project"}}).execute()["uuid"]

for r in range(0, 5000):
    coll = arvados.collection.Collection(api_client=api)
    with coll.open("the_test_file", "wt") as f:
        f.write(("%s_" % r) * 2050)

    coll.save_new("collection %s" % r, owner_uuid=project_uuid)

    with coll.open("the_test_file", "at") as f:
        f.write(("%s_" % (r+1)) * 2050)

    coll.save()

    with coll.open("the_test_file", "at") as f:
        f.write(("%s_" % (r+2)) * 2050)

    coll.save()

    with coll.open("the_test_file", "at") as f:
        f.write(("%s_" % (r+3)) * 2050)

    coll.save()
