2015-06-05 23:36:43 +00:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
import json
|
2018-03-22 05:13:09 +00:00
|
|
|
import time
|
2015-06-05 23:36:43 +00:00
|
|
|
|
|
|
|
from boto.glacier.layer1 import Layer1
|
|
|
|
import sure # noqa
|
|
|
|
|
2017-02-16 03:35:45 +00:00
|
|
|
from moto import mock_glacier_deprecated
|
2015-06-05 23:36:43 +00:00
|
|
|
|
|
|
|
|
2017-02-16 03:35:45 +00:00
|
|
|
@mock_glacier_deprecated
|
2015-06-05 23:36:43 +00:00
|
|
|
def test_init_glacier_job():
|
|
|
|
conn = Layer1(region_name="us-west-2")
|
|
|
|
vault_name = "my_vault"
|
|
|
|
conn.create_vault(vault_name)
|
2017-02-24 02:37:43 +00:00
|
|
|
archive_id = conn.upload_archive(
|
|
|
|
vault_name, "some stuff", "", "", "some description")
|
2015-06-05 23:36:43 +00:00
|
|
|
|
|
|
|
job_response = conn.initiate_job(vault_name, {
|
|
|
|
"ArchiveId": archive_id,
|
|
|
|
"Type": "archive-retrieval",
|
|
|
|
})
|
|
|
|
job_id = job_response['JobId']
|
2017-02-24 02:37:43 +00:00
|
|
|
job_response['Location'].should.equal(
|
|
|
|
"//vaults/my_vault/jobs/{0}".format(job_id))
|
2015-06-05 23:36:43 +00:00
|
|
|
|
|
|
|
|
2017-02-16 03:35:45 +00:00
|
|
|
@mock_glacier_deprecated
|
2015-06-05 23:36:43 +00:00
|
|
|
def test_describe_job():
|
|
|
|
conn = Layer1(region_name="us-west-2")
|
|
|
|
vault_name = "my_vault"
|
|
|
|
conn.create_vault(vault_name)
|
2017-02-24 02:37:43 +00:00
|
|
|
archive_id = conn.upload_archive(
|
|
|
|
vault_name, "some stuff", "", "", "some description")
|
2015-06-05 23:36:43 +00:00
|
|
|
job_response = conn.initiate_job(vault_name, {
|
|
|
|
"ArchiveId": archive_id,
|
|
|
|
"Type": "archive-retrieval",
|
|
|
|
})
|
|
|
|
job_id = job_response['JobId']
|
|
|
|
|
|
|
|
job = conn.describe_job(vault_name, job_id)
|
2018-03-22 05:13:09 +00:00
|
|
|
joboutput = json.loads(job.read().decode("utf-8"))
|
|
|
|
|
|
|
|
joboutput.should.have.key('Tier').which.should.equal('Standard')
|
|
|
|
joboutput.should.have.key('StatusCode').which.should.equal('InProgress')
|
|
|
|
joboutput.should.have.key('VaultARN').which.should.equal('arn:aws:glacier:RegionInfo:us-west-2:012345678901:vaults/my_vault')
|
2015-06-05 23:36:43 +00:00
|
|
|
|
|
|
|
|
2017-02-16 03:35:45 +00:00
|
|
|
@mock_glacier_deprecated
|
2015-06-05 23:36:43 +00:00
|
|
|
def test_list_glacier_jobs():
|
|
|
|
conn = Layer1(region_name="us-west-2")
|
|
|
|
vault_name = "my_vault"
|
|
|
|
conn.create_vault(vault_name)
|
2017-02-24 02:37:43 +00:00
|
|
|
archive_id1 = conn.upload_archive(
|
|
|
|
vault_name, "some stuff", "", "", "some description")['ArchiveId']
|
|
|
|
archive_id2 = conn.upload_archive(
|
|
|
|
vault_name, "some other stuff", "", "", "some description")['ArchiveId']
|
2015-06-05 23:36:43 +00:00
|
|
|
|
|
|
|
conn.initiate_job(vault_name, {
|
|
|
|
"ArchiveId": archive_id1,
|
|
|
|
"Type": "archive-retrieval",
|
|
|
|
})
|
|
|
|
conn.initiate_job(vault_name, {
|
|
|
|
"ArchiveId": archive_id2,
|
|
|
|
"Type": "archive-retrieval",
|
|
|
|
})
|
|
|
|
|
|
|
|
jobs = conn.list_jobs(vault_name)
|
|
|
|
len(jobs['JobList']).should.equal(2)
|
|
|
|
|
|
|
|
|
2017-02-16 03:35:45 +00:00
|
|
|
@mock_glacier_deprecated
|
2015-06-05 23:36:43 +00:00
|
|
|
def test_get_job_output():
|
|
|
|
conn = Layer1(region_name="us-west-2")
|
|
|
|
vault_name = "my_vault"
|
|
|
|
conn.create_vault(vault_name)
|
2017-02-24 02:37:43 +00:00
|
|
|
archive_response = conn.upload_archive(
|
|
|
|
vault_name, "some stuff", "", "", "some description")
|
2015-06-05 23:36:43 +00:00
|
|
|
archive_id = archive_response['ArchiveId']
|
|
|
|
job_response = conn.initiate_job(vault_name, {
|
|
|
|
"ArchiveId": archive_id,
|
|
|
|
"Type": "archive-retrieval",
|
|
|
|
})
|
|
|
|
job_id = job_response['JobId']
|
|
|
|
|
2018-03-22 05:13:09 +00:00
|
|
|
time.sleep(6)
|
|
|
|
|
2015-06-05 23:36:43 +00:00
|
|
|
output = conn.get_job_output(vault_name, job_id)
|
2015-06-06 00:09:15 +00:00
|
|
|
output.read().decode("utf-8").should.equal("some stuff")
|