Skip to content

Commit a320072

Browse files
author
Josh Mervine
committed
adding logs.json integration test and benchmark
1 parent 23fbc0b commit a320072

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

BENCHMARKS.md

+10-8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Running benchmarks as follows in order:
22

33
maxcdn.get('zones/pull.json')
44
maxcdn.get('reports/popularfiles.json')
5+
maxcdn.get('v3/reporting/logs.json')
56
maxcdn.post('zones/pull.json', { :name => 'NAM', :url => 'URL' })
67
maxcdn.put('account.json', { :name => 'NAME' })
78
maxcdn.delete('zones/pull.json/ZONEID')
@@ -10,11 +11,12 @@ Running benchmarks as follows in order:
1011
maxcdn.purge('ZONEID', [ 'FILE1','FILE2' ])
1112

1213
user system total real
13-
get : 0.060000 0.060000 0.120000 ( 1.014527)
14-
get : 0.010000 0.000000 0.010000 ( 0.613805)
15-
post : 0.020000 0.000000 0.020000 ( 19.011447)
16-
put : 0.020000 0.000000 0.020000 ( 0.670025)
17-
delete: 0.010000 0.000000 0.010000 ( 1.076173)
18-
purge : 0.020000 0.000000 0.020000 ( 11.109962)
19-
purge : 0.010000 0.010000 0.020000 ( 0.813984)
20-
purge : 0.030000 0.000000 0.030000 ( 6.704786)
14+
get : 0.010000 0.000000 0.010000 ( 1.356269)
15+
get : 0.010000 0.000000 0.010000 ( 0.911275)
16+
get : 0.010000 0.000000 0.010000 ( 1.069133)
17+
post : 0.000000 0.000000 0.000000 ( 6.513997)
18+
put : 0.010000 0.000000 0.010000 ( 0.831379)
19+
delete: 0.010000 0.000000 0.010000 ( 1.248739)
20+
purge : 0.010000 0.000000 0.010000 ( 4.019390)
21+
purge : 0.010000 0.000000 0.010000 ( 6.221071)
22+
purge : 0.010000 0.000000 0.010000 ( 2.496699)

test/benchmark.rb

+7-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
puts " "
1313
puts " maxcdn.get('zones/pull.json')"
1414
puts " maxcdn.get('reports/popularfiles.json')"
15+
puts " maxcdn.get('v3/reporting/logs.json')"
1516
puts " maxcdn.post('zones/pull.json', { :name => 'NAM', :url => 'URL' })"
1617
puts " maxcdn.put('account.json', { :name => 'NAME' })"
1718
puts " maxcdn.delete('zones/pull.json/ZONEID')"
@@ -23,16 +24,20 @@
2324
Benchmark.bm do |mark|
2425

2526
maxcdn = MaxCDN::Client.new(ENV["ALIAS"], ENV["KEY"], ENV["SECRET"])
26-
time = Time.now.to_i.to_s
2727

2828
mark.report("get :") do
29-
@pullzone = maxcdn.get("zones/pull.json")["data"]["pullzones"][0]["id"]
29+
zones = maxcdn.get("zones/pull.json")["data"]["pullzones"]
30+
@pullzone = zones[zones.length-1]["id"]
3031
end
3132

3233
mark.report("get :") do
3334
@popularfiles = maxcdn.get("reports/popularfiles.json")["data"]["popularfiles"]
3435
end
3536

37+
mark.report("get :") do
38+
@popularfiles = maxcdn.get("v3/reporting/logs.json")["next_page_key"]
39+
end
40+
3641
@zone = {
3742
:name => @time,
3843
:url => "http://www.example.com"

test/integration.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ def test_get
3131
end
3232
end
3333

34+
def test_get_logs
35+
assert @max.get("v3/reporting/logs.json")["next_page_key"], "get next_page_key with data"
36+
end
37+
3438
def test_post_and_delete
3539

3640
zone = {
@@ -50,7 +54,8 @@ def test_put
5054
end
5155

5256
def test_purge
53-
zone = @max.get("zones/pull.json")["data"]["pullzones"][0]["id"]
57+
zones = @max.get("zones/pull.json")["data"]["pullzones"]
58+
zone = zones[zones.length-1]["id"]
5459
assert_equal 200, @max.purge(zone)["code"], "purge"
5560

5661
popularfiles = @max.get("reports/popularfiles.json")["data"]["popularfiles"]

0 commit comments

Comments
 (0)