Skip to content

Commit dd33089

Browse files
committed
move spec files
1 parent d60cf4f commit dd33089

4 files changed

Lines changed: 65 additions & 2 deletions

File tree

.rubocop.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ Metrics/AbcSize:
1717
Metrics/BlockLength:
1818
Exclude:
1919
- 'spec/**/*.rb'
20+
21+
Metrics/LineLength:
22+
Exclude:
23+
- 'spec/**/*.rb'

Gemfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ group :test do
1515
gem 'rack-test'
1616
gem 'rake'
1717
gem 'rspec'
18-
gem 'rubocop'
18+
gem 'rubocop', '< 0.42'
1919
gem 'term-ansicolor', '< 1.4' if ruby_version?('< 2.0')
2020
gem 'tins', '< 1.7' if ruby_version?('< 2.0')
21+
gem 'vcr'
22+
gem 'fakeweb'
2123
end
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# encoding: UTF-8
2+
3+
require 'prometheus/api_client'
4+
require 'fakeweb'
5+
require 'vcr'
6+
7+
VCR.configure do |c|
8+
c.cassette_library_dir = "spec/vcr_cassettes"
9+
c.hook_into :fakeweb
10+
c.allow_http_connections_when_no_cassette = false
11+
end
12+
13+
describe Prometheus::ApiClient::Cadvisor do
14+
token = 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJtYW5hZ2VtZW50LWluZnJhIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZWNyZXQubmFtZSI6Im1hbmFnZW1lbnQtYWRtaW4tdG9rZW4tejBncmYiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoibWFuYWdlbWVudC1hZG1pbiIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6IjEzYjgxZjI0LTcyOTktMTFlNy04MjIxLTAwMWE0YTIzMTRkNyIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDptYW5hZ2VtZW50LWluZnJhOm1hbmFnZW1lbnQtYWRtaW4ifQ.G_ht7AJi1sd73vH8fO8_fZyjYA2-Qpz_M2DJ0JrjiBTBzISfJcUZETLN_ZRQUhqicWtEe3YWmN2lVY-7OoAl24v5mr-_9Qax_p44TUzBgNqng0wl-kXi4Ay6uoTtf470w0QuBMgJGnB05-nxA52G24doZQG493wGqxmKr5OLePJ0cg7vlG6wUjxznbG-u8lQM1qt59CHKzxPc_pgWMtSBHlXisuYV9dwNFLlfvwIHQZwc1qq72eMud9PtorD6QontuHAARLNTieCtrjlKk6-EFH5zOWXDukNyFPcMD43FGLqBxFkqboHaa04iEivViUrmXVvB6CqkOZoNPxSrG98LQ'
15+
url = 'https://prometheus.10.35.19.248.nip.io:443'
16+
instance = 'yzamir-centos7-3.eng.lab.tlv.redhat.com'
17+
18+
describe 'Node' do
19+
it 'reads metrics' do
20+
VCR.use_cassette('prometheus/api_client/cadvisor_node', :record => :new_episodes) do
21+
prometheus = Prometheus::ApiClient::Cadvisor::Node.new(
22+
instance: instance,
23+
url: url,
24+
credentials: { token: token },
25+
options: { verify_ssl: OpenSSL::SSL::VERIFY_NONE },
26+
)
27+
28+
response = prometheus.query(
29+
query: 'sum(container_cpu_usage_seconds_total)',
30+
time: '2017-08-07T06:10:30.781Z',
31+
)
32+
33+
expect(response).to be_a(Hash)
34+
end
35+
end
36+
37+
it 'reads metrics range' do
38+
VCR.use_cassette('spec/vcr/prometheus/api_client/cadvisor_node', :record => :new_episodes) do
39+
prometheus = Prometheus::ApiClient::Cadvisor::Node.new(
40+
instance: instance,
41+
url: url,
42+
credentials: { token: token },
43+
options: { verify_ssl: OpenSSL::SSL::VERIFY_NONE },
44+
)
45+
46+
response = prometheus.query_range(
47+
query: 'sum(container_cpu_usage_seconds_total)',
48+
start: '2017-08-07T06:10:30.781Z',
49+
end: '2017-08-07T06:14:30.781Z',
50+
step: '120s',
51+
)
52+
53+
expect(response).to be_a(Hash)
54+
end
55+
end
56+
end
57+
end
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
describe Prometheus::ApiClient do
66
describe '.client' do
7-
it 'memorizes the returned object' do
7+
it 'returne a client object' do
88
client = Prometheus::ApiClient.client
99

1010
expect(client).to be_a(Prometheus::ApiClient::Client)

0 commit comments

Comments
 (0)