vpsb_client 0.0.2 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 10ca3e79c344f1e1453d72c01354f772f1349a92
4
- data.tar.gz: 5bb7605cad616ec8eb65445f6c497aea5f83ae1b
3
+ metadata.gz: 17f4f6854b3a86eb3338dd12d0a65656ed657b5b
4
+ data.tar.gz: 8fb32a5b4d42d02a86368748a43802d9406863f8
5
5
  SHA512:
6
- metadata.gz: ee479c738e4708b7515c9b5a34b94dbc4ee96d99e26bf6ca7bfea8d2466eb455d9f63457b0b6d1cf55a39dc0ff4787c7685e0a47e1523418c2e66ca02cc33990
7
- data.tar.gz: 813ee17457596d106558a87aa8e32ead6b0b85f31bed244dc2401a4dc1530825501f5ff05af2b3c802adb0a3a81c8ad0c53a9e6fe94c6fac7dff33271f8aa219
6
+ metadata.gz: fde114fced005f8331d27554ee4cc6b18a574a13ff92c4a1296cfa83cb2b318c820e7c49746aaf45bcee4e888f738a53c3cfec8c62e29c3f44a51a8ba3a3911c
7
+ data.tar.gz: 8cb74c58b641fff871b31cb41b87ed1c6ecef372bfb72bd19f082768a66a90c4dbf68c209f7d48f62f75020b4eca158457fd44d2a4b6b9f0a0a30dd914ba2946
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path('../../lib/vpsb_client', __FILE__)
4
+
5
+ manager = VpsbClient::Manager.new(File.expand_path('../../config/vpsb.yml', __FILE__))
6
+ manager.setup
7
+
8
+ data = <<DATA
9
+ Test execution summary:
10
+ total time: 7.8366s
11
+ total number of events: 20000
12
+ total time taken by event execution: 31.3283
13
+ per-request statistics:
14
+ min: 1.35ms
15
+ avg: 1.57ms
16
+ max: 21.53ms
17
+ approx. 95 percentile: 1.54ms
18
+ DATA
19
+
20
+ t = manager.create_sysbench_run(1, 'cpu_0_v1', 'sysbench --test=cpu --num-threads=4 --max-requests=20000 run', data)
21
+ if t
22
+ puts "new sysbench run = #{t.inspect}"
23
+ else
24
+ puts "no run was created"
25
+ end
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path('../../lib/vpsb_client', __FILE__)
4
+
5
+ manager = VpsbClient::Manager.new(File.expand_path('../../config/vpsb.yml', __FILE__))
6
+ manager.setup
7
+
8
+ puts manager.trial_sysbench_tests(1)
@@ -9,6 +9,8 @@ require "#{VPSB_BASE_PATH}/vpsb_client/api/request"
9
9
  require "#{VPSB_BASE_PATH}/vpsb_client/api/response"
10
10
  require "#{VPSB_BASE_PATH}/vpsb_client/api/get_current_trial_request"
11
11
  require "#{VPSB_BASE_PATH}/vpsb_client/api/get_trial_last_metric_request"
12
+ require "#{VPSB_BASE_PATH}/vpsb_client/api/get_trial_sysbench_tests"
13
+ require "#{VPSB_BASE_PATH}/vpsb_client/api/post_sysbench_run"
12
14
  require "#{VPSB_BASE_PATH}/vpsb_client/api/get_item_id_request"
13
15
  require "#{VPSB_BASE_PATH}/vpsb_client/api/create_trial_request"
14
16
  require "#{VPSB_BASE_PATH}/vpsb_client/api/post_metric_request"
@@ -0,0 +1,19 @@
1
+ module VpsbClient
2
+ module Api
3
+ class GetTrialSysbenchTests < GetRequest
4
+ def initialize(http_client, params)
5
+ super(http_client)
6
+ @trial_id = params[:trial_id]
7
+ end
8
+
9
+ def url_path
10
+ "/api/trials/#{@trial_id}/sysbench_tests"
11
+ end
12
+
13
+ def self.tests(http_response)
14
+ return [] if http_response.parsed_response.empty?
15
+ http_response.parsed_response
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,31 @@
1
+ module VpsbClient
2
+ module Api
3
+ class PostSysbenchRun < PostRequest
4
+
5
+ def initialize(http_client, trial_id, test_id, command, data)
6
+ super(http_client)
7
+ @trial_id = trial_id
8
+ @test_id = test_id
9
+ @command = command
10
+ @data = data
11
+ end
12
+
13
+ def url_path
14
+ "/api/trials/#{@trial_id}/sysbench_runs"
15
+ end
16
+
17
+ def post_params
18
+ @post_params = { sysbench_run: {
19
+ test_id: @test_id,
20
+ command: @command,
21
+ data: @data
22
+ }
23
+ }
24
+ end
25
+
26
+ def content_type
27
+ 'application/json'
28
+ end
29
+ end
30
+ end
31
+ end
@@ -36,7 +36,7 @@ module VpsbClient
36
36
  raw_sar_filenames.each do |filename|
37
37
  filename.match /sa(?<num>\d+)$/ do |matchdata|
38
38
  fileday = matchdata[:num]
39
- next if fileday.to_i == Time.now.day
39
+ next if fileday == Time.now.strftime('%Y%m%d')
40
40
 
41
41
  formatted_filename = "#{@target_path}/formatted_sa#{fileday}"
42
42
  next if File.exist?(formatted_filename)
@@ -46,8 +46,8 @@ module VpsbClient
46
46
  end
47
47
 
48
48
  def create_current_day_temp_formatted
49
- sa_filename = "#{@orig_path}/sa#{'%02d' % Time.now.day}"
50
- formatted_filename = "#{@target_path}/formatted_sa#{'%02d' % Time.now.day}"
49
+ sa_filename = "#{@orig_path}/sa#{Time.now.strftime('%Y%m%d')}"
50
+ formatted_filename = "#{@target_path}/formatted_sa#{Time.now.strftime('%Y%m%d')}"
51
51
  File.delete(formatted_filename) if File.exist?(formatted_filename)
52
52
  sadf(sa_filename, formatted_filename)
53
53
  end
@@ -68,4 +68,4 @@ module VpsbClient
68
68
  end
69
69
  end
70
70
  end
71
- end
71
+ end
@@ -52,6 +52,12 @@ module VpsbClient
52
52
  Api::CreateTrialRequest.trial(http_response)
53
53
  end
54
54
 
55
+ def create_sysbench_run(trial_id, test_id, command, data)
56
+ create_sysbench_run_request = Api::PostSysbenchRun.new(@http_client, trial_id, test_id, command, data)
57
+ curl_response = create_sysbench_run_request.run
58
+ http_response = Api::Response.new(curl_response)
59
+ end
60
+
55
61
  def current_trial
56
62
  builder = Builders::Trial.new(@config)
57
63
  current_trial_request = Api::GetCurrentTrialRequest.new(@http_client, builder.lookup_params)
@@ -67,6 +73,13 @@ module VpsbClient
67
73
  Api::GetTrialLastMetricRequest.started_at(http_response)
68
74
  end
69
75
 
76
+ def trial_sysbench_tests(trial_id)
77
+ trial_sysbench_tests_request = Api::GetTrialSysbenchTests.new(@http_client, trial_id: trial_id)
78
+ curl_response = trial_sysbench_tests_request.run
79
+ http_response = Api::Response.new(curl_response)
80
+ Api::GetTrialSysbenchTests.tests(http_response)
81
+ end
82
+
70
83
  def hoster_id
71
84
  return @hoster_id if @hoster_id
72
85
  id_request = Api::GetItemIdRequest.new(@http_client, 'hosters', @config['hoster_name'])
@@ -103,7 +116,7 @@ module VpsbClient
103
116
  end
104
117
 
105
118
  prepare_logfiles
106
-
119
+
107
120
  metric_ids = []
108
121
  interval_length = 604800
109
122
  last_started_at = trial_last_metric_started_at(trial['id'], interval_length)
@@ -1,3 +1,3 @@
1
1
  module VpsbClient
2
- VERSION = "0.0.2"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -128,6 +128,34 @@ module VpsbClient
128
128
  end
129
129
  end
130
130
 
131
+ describe GetTrialSysbenchTests do
132
+ it 'gets /api/trials/:id/sysbench_tests' do
133
+ @params = {trial_id: 1 }
134
+ expect(@curl).to receive(:get).with('http://localhost/api/trials/1/sysbench_tests.json').once
135
+
136
+ req = GetTrialSysbenchTests.new(@client, @params)
137
+ req.run
138
+ end
139
+ end
140
+
141
+ describe PostSysbenchRun do
142
+ it 'posts to /api/trials/:id/sysbench_runs' do
143
+ run_params = {
144
+ sysbench_run: {
145
+ test_id: 2,
146
+ command: 'do it',
147
+ data: 'all done'
148
+ }
149
+ }
150
+ expect(@curl).to receive(:post).with('http://localhost/api/trials/1/sysbench_runs.json',
151
+ run_params.to_json,
152
+ "application/json").once
153
+
154
+ req = PostSysbenchRun.new(@client, 1, 2, 'do it', 'all done')
155
+ req.run
156
+ end
157
+ end
158
+
131
159
  describe PostMetricRequest do
132
160
  before :each do
133
161
  @trial_id = 1
@@ -47,9 +47,9 @@ module VpsbClient
47
47
 
48
48
  it 'replaces current day formatted file if it exists' do
49
49
  system "mkdir #{@target_dir}"
50
- system "echo \"hello\" > #{@target_dir}/formatted_sa21"
50
+ system "echo \"hello\" > #{@target_dir}/formatted_sa20140921"
51
51
  @manager.run
52
- lines = File.readlines("#{@target_dir}/formatted_sa21")
52
+ lines = File.readlines("#{@target_dir}/formatted_sa20140921")
53
53
  expect(lines.first).not_to match(/hello/)
54
54
  end
55
55
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vpsb_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philippe Le Rohellec
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-08 00:00:00.000000000 Z
11
+ date: 2016-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: curb
@@ -113,10 +113,12 @@ email:
113
113
  - philippe@lerohellec.com
114
114
  executables:
115
115
  - close_trial.rb
116
+ - create_sysbench_run.rb
116
117
  - create_trial.rb
117
118
  - get_current_trial.rb
118
119
  - get_item_ids.rb
119
120
  - get_trial_last_metric.rb
121
+ - get_trial_sysbench_tests.rb
120
122
  - signed_in.rb
121
123
  - sync_metrics.rb
122
124
  - test_timing_interval.rb
@@ -130,10 +132,12 @@ files:
130
132
  - README.md
131
133
  - Rakefile
132
134
  - bin/close_trial.rb
135
+ - bin/create_sysbench_run.rb
133
136
  - bin/create_trial.rb
134
137
  - bin/get_current_trial.rb
135
138
  - bin/get_item_ids.rb
136
139
  - bin/get_trial_last_metric.rb
140
+ - bin/get_trial_sysbench_tests.rb
137
141
  - bin/signed_in.rb
138
142
  - bin/sync_metrics.rb
139
143
  - bin/test_timing_interval.rb
@@ -145,7 +149,9 @@ files:
145
149
  - lib/vpsb_client/api/get_current_trial_request.rb
146
150
  - lib/vpsb_client/api/get_item_id_request.rb
147
151
  - lib/vpsb_client/api/get_trial_last_metric_request.rb
152
+ - lib/vpsb_client/api/get_trial_sysbench_tests.rb
148
153
  - lib/vpsb_client/api/post_metric_request.rb
154
+ - lib/vpsb_client/api/post_sysbench_run.rb
149
155
  - lib/vpsb_client/api/request.rb
150
156
  - lib/vpsb_client/api/response.rb
151
157
  - lib/vpsb_client/builders/system_info_parser.rb
@@ -210,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
216
  version: '0'
211
217
  requirements: []
212
218
  rubyforge_project:
213
- rubygems_version: 2.4.5.1
219
+ rubygems_version: 2.5.1
214
220
  signing_key:
215
221
  specification_version: 4
216
222
  summary: Client gem for vpsbenchmarks.com