mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[aws|cdn] add aws cdn tests for streaming distributions
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
This commit is contained in:
parent
3272490dec
commit
2cf7a4111e
1 changed files with 117 additions and 16 deletions
|
@ -2,7 +2,7 @@ Shindo.tests('Fog::CDN[:aws] | CDN requests', ['aws', 'cdn']) do
|
||||||
|
|
||||||
@cf_connection = Fog::CDN[:aws]
|
@cf_connection = Fog::CDN[:aws]
|
||||||
|
|
||||||
tests('success') do
|
tests('distributions success') do
|
||||||
|
|
||||||
test('get current ditribution list count') do
|
test('get current ditribution list count') do
|
||||||
pending if Fog.mocking?
|
pending if Fog.mocking?
|
||||||
|
@ -118,7 +118,7 @@ Shindo.tests('Fog::CDN[:aws] | CDN requests', ['aws', 'cdn']) do
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
test("disable distribution #{@dist_id}") {
|
test("disable distribution #{@dist_id} - can take 15 minutes to complete...") {
|
||||||
pending if Fog.mocking?
|
pending if Fog.mocking?
|
||||||
|
|
||||||
result = false
|
result = false
|
||||||
|
@ -140,20 +140,11 @@ Shindo.tests('Fog::CDN[:aws] | CDN requests', ['aws', 'cdn']) do
|
||||||
result = true
|
result = true
|
||||||
|
|
||||||
# unfortunately you can delete only after a distribution becomes Deployed
|
# unfortunately you can delete only after a distribution becomes Deployed
|
||||||
first = Time.now
|
Fog.wait_for {
|
||||||
catch(:deployed) do
|
|
||||||
loop do
|
|
||||||
response = @cf_connection.get_distribution(@dist_id)
|
response = @cf_connection.get_distribution(@dist_id)
|
||||||
return false if response.status != 200
|
|
||||||
return false if (Time.now - first) > 20 * 60 # abort after 20 minutes
|
|
||||||
|
|
||||||
if response.status == 200 and response.body['Status'] == 'Deployed'
|
|
||||||
@etag = response.headers['ETag']
|
@etag = response.headers['ETag']
|
||||||
throw :deployed
|
response.status == 200 and response.body['Status'] == 'Deployed'
|
||||||
end
|
}
|
||||||
sleep 15
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
response = @cf_connection.delete_distribution(@dist_id, @etag)
|
response = @cf_connection.delete_distribution(@dist_id, @etag)
|
||||||
if response.status != 204
|
if response.status != 204
|
||||||
|
@ -163,4 +154,114 @@ Shindo.tests('Fog::CDN[:aws] | CDN requests', ['aws', 'cdn']) do
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
tests('streaming distributions success') do
|
||||||
|
|
||||||
|
test('get current streaming ditribution list count') do
|
||||||
|
pending if Fog.mocking?
|
||||||
|
|
||||||
|
@count= 0
|
||||||
|
response = @cf_connection.get_streaming_distribution_list
|
||||||
|
if response.status == 200
|
||||||
|
@distributions = response.body['StreamingDistributionSummary']
|
||||||
|
@count = @distributions.count
|
||||||
|
end
|
||||||
|
|
||||||
|
response.status == 200
|
||||||
|
end
|
||||||
|
|
||||||
|
test('create distribution') {
|
||||||
|
pending if Fog.mocking?
|
||||||
|
|
||||||
|
result = false
|
||||||
|
|
||||||
|
response = @cf_connection.post_streaming_distribution('S3Origin' => { 'DNSName' => 'test_cdn.s3.amazonaws.com'}, 'Enabled' => true)
|
||||||
|
if response.status == 201
|
||||||
|
@dist_id = response.body['Id']
|
||||||
|
@etag = response.headers['ETag']
|
||||||
|
@caller_reference = response.body['StreamingDistributionConfig']['CallerReference']
|
||||||
|
if (@dist_id.length > 0)
|
||||||
|
result = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
result
|
||||||
|
}
|
||||||
|
|
||||||
|
test("get info on distribution #{@dist_id}") {
|
||||||
|
pending if Fog.mocking?
|
||||||
|
|
||||||
|
result = false
|
||||||
|
|
||||||
|
response = @cf_connection.get_streaming_distribution(@dist_id)
|
||||||
|
if response.status == 200
|
||||||
|
@etag = response.headers['ETag']
|
||||||
|
status = response.body['Status']
|
||||||
|
if ((status == 'Deployed') or (status == 'InProgress')) and not @etag.nil?
|
||||||
|
result = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
result
|
||||||
|
}
|
||||||
|
|
||||||
|
test('list streaming distributions') do
|
||||||
|
pending if Fog.mocking?
|
||||||
|
|
||||||
|
result = false
|
||||||
|
|
||||||
|
response = @cf_connection.get_streaming_distribution_list
|
||||||
|
if response.status == 200
|
||||||
|
distributions = response.body['StreamingDistributionSummary']
|
||||||
|
if (distributions.count > 0)
|
||||||
|
dist = distributions[0]
|
||||||
|
dist_id = dist['Id']
|
||||||
|
end
|
||||||
|
max_items = response.body['MaxItems']
|
||||||
|
|
||||||
|
if (dist_id.length > 0) and (max_items > 0)
|
||||||
|
result = true
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
|
test("disable distribution #{@dist_id} - can take 15 minutes to complete...") {
|
||||||
|
pending if Fog.mocking?
|
||||||
|
|
||||||
|
result = false
|
||||||
|
|
||||||
|
response = @cf_connection.put_streaming_distribution_config(@dist_id, @etag, 'S3Origin' => { 'DNSName' => 'test_cdn.s3.amazonaws.com'}, 'Enabled' => false, 'CallerReference' => @caller_reference)
|
||||||
|
if response.status == 200
|
||||||
|
@etag = response.headers['ETag']
|
||||||
|
unless @etag.nil?
|
||||||
|
result = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
result
|
||||||
|
}
|
||||||
|
|
||||||
|
test("remove distribution #{@dist_id}") {
|
||||||
|
pending if Fog.mocking?
|
||||||
|
|
||||||
|
result = true
|
||||||
|
|
||||||
|
# unfortunately you can delete only after a distribution becomes Deployed
|
||||||
|
Fog.wait_for {
|
||||||
|
response = @cf_connection.get_distribution(@dist_id)
|
||||||
|
@etag = response.headers['ETag']
|
||||||
|
response.status == 200 and response.body['Status'] == 'Deployed'
|
||||||
|
}
|
||||||
|
|
||||||
|
response = @cf_connection.delete_streaming_distribution(@dist_id, @etag)
|
||||||
|
if response.status != 204
|
||||||
|
result = false
|
||||||
|
end
|
||||||
|
|
||||||
|
result
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue