Skip to content

Commit b07ecf8

Browse files
committed
Fix acceptance tests
1 parent 10106e5 commit b07ecf8

File tree

11 files changed

+68
-85
lines changed

11 files changed

+68
-85
lines changed

.sync.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Gemfile:
77
':system_tests':
88
- gem: bcrypt
99
- gem: rspec-retry
10-
- gem: infrataster
10+
- gem: simp-beaker-helpers
1111
spec/spec_helper.rb:
1212
hiera_config: "'spec/fixtures/hiera/hiera.yaml'"
1313
spec/spec_helper_acceptance.rb:

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ group :system_tests do
2121
gem 'voxpupuli-acceptance', '~> 1.0', :require => false
2222
gem 'bcrypt', :require => false
2323
gem 'rspec-retry', :require => false
24-
gem 'infrataster', :require => false
24+
gem 'simp-beaker-helpers', :require => false
2525
end
2626

2727
group :release do

lib/puppet/provider/elastic_rest.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def self.prefetch(resources)
158158
(p.key?(:password) ? p[:password].value : nil),
159159
(p.key?(:ca_file) ? p[:ca_file].value : nil),
160160
(p.key?(:ca_path) ? p[:ca_path].value : nil),
161-
p[:validate_tls].value,
161+
{ validate_tls: p[:validate_tls].value },
162162
]
163163
# Deduplicate identical settings, and fetch templates
164164
end.uniq

spec/helpers/acceptance/tests/basic_shared_examples.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,21 @@
4949
end
5050
end
5151

52-
describe server :container do
53-
describe http("http://localhost:#{es_port}/_nodes/_local") do
54-
it 'serves requests', :with_retries do
55-
expect(response.status).to eq(200)
56-
end
52+
describe "http://localhost:#{es_port}/_nodes/_local" do
53+
subject { shell("curl http://localhost:#{es_port}/_nodes/_local") }
5754

58-
it 'uses the default data path', :with_retries do
59-
json = JSON.parse(response.body)['nodes'].values.first
60-
data_dir = ['/var/lib/elasticsearch']
61-
expect(
62-
json['settings']['path']
63-
).to include(
64-
'data' => data_dir
65-
)
66-
end
55+
it 'serves requests', :with_retries do
56+
expect(subject.exit_code).to eq(0)
57+
end
58+
59+
it 'uses the default data path', :with_retries do
60+
json = JSON.parse(subject.stdout)['nodes'].values.first
61+
data_dir = ['/var/lib/elasticsearch']
62+
expect(
63+
json['settings']['path']
64+
).to include(
65+
'data' => data_dir
66+
)
6767
end
6868
end
6969
end

spec/helpers/acceptance/tests/datadir_shared_examples.rb

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,14 @@
2727
end
2828
end
2929

30-
describe server :container do
31-
describe http(
32-
"http://localhost:#{es_port}/_nodes/_local"
33-
) do
34-
it 'uses a custom data path' do
35-
json = JSON.parse(response.body)['nodes'].values.first
36-
expect(
37-
json['settings']['path']['data']
38-
).to(datapaths.one? && v[:elasticsearch_major_version] <= 2 ? eq(datapaths.first) : contain_exactly(*datapaths))
39-
end
30+
describe "http://localhost:#{es_port}/_nodes/_local" do
31+
subject { shell("curl http://localhost:#{es_port}/_nodes/_local") }
32+
33+
it 'uses a custom data path' do
34+
json = JSON.parse(subject.stdout)['nodes'].values.first
35+
expect(
36+
json['settings']['path']['data']
37+
).to(datapaths.one? && v[:elasticsearch_major_version] <= 2 ? eq(datapaths.first) : contain_exactly(*datapaths))
4038
end
4139
end
4240
end

spec/helpers/acceptance/tests/pipeline_shared_examples.rb

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,12 @@
4646
end
4747
end
4848

49-
describe server :container do
50-
describe http(
51-
"http://localhost:#{elasticsearch_port}/_ingest/pipeline"
52-
) do
53-
it 'returns the configured pipelines', :with_retries do
54-
expect(JSON.parse(response.body).values).
55-
to include(include(pipeline))
56-
end
49+
describe "http://localhost:#{elasticsearch_port}/_ingest/pipeline" do
50+
subject { shell("curl http://localhost:#{elasticsearch_port}/_ingest/pipeline") }
51+
52+
it 'returns the configured pipelines', :with_retries do
53+
expect(JSON.parse(subject.stdout).values).
54+
to include(include(pipeline))
5755
end
5856
end
5957
end

spec/helpers/acceptance/tests/plugin_api_shared_examples.rb

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@
99
end
1010
end
1111

12-
describe server :container do
13-
describe http(
14-
"http://localhost:#{es_config['http.port']}/_cluster/stats"
15-
) do
16-
it desc, :with_retries do
17-
expect(
18-
JSON.parse(response.body)['nodes']['plugins']
19-
).to include(include(val))
20-
end
12+
describe "http://localhost:#{es_config['http.port']}/_cluster/stats" do
13+
subject { shell("curl http://localhost:#{es_config['http.port']}/_cluster/stats") }
14+
15+
it desc, :with_retries do
16+
expect(
17+
JSON.parse(subject.stdout)['nodes']['plugins']
18+
).to include(include(val))
2119
end
2220
end
2321
end

spec/helpers/acceptance/tests/security_shared_examples.rb

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,11 @@
5656
end
5757
end
5858

59-
describe server :container do
60-
describe http(
61-
"https://localhost:#{es_port}#{path}",
62-
{
63-
ssl: { verify: false }
64-
}.merge(user && pass ? { basic_auth: [user, pass] } : {})
65-
) do
66-
it test_desc, :with_retries do
67-
expect(http_test.call(response)).to eq(expected)
68-
end
59+
describe "https://localhost:#{es_port}#{path}" do
60+
subject { shell("curl -k -u #{user}:#{pass} https://localhost:#{es_port}#{path}") }
61+
62+
it test_desc, :with_retries do
63+
expect(http_test.call(subject.stdout)).to eq(expected)
6964
end
7065
end
7166
end

spec/helpers/acceptance/tests/snapshot_repository_shared_examples.rb

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,16 @@
6565
end
6666
end
6767

68-
describe server :container do
69-
describe http(
70-
"http://localhost:#{es_port}/_snapshot/backup"
71-
) do
72-
it 'returns the snapshot repository', :with_retries do
73-
expect(JSON.parse(response.body)['backup']).
74-
to include('settings' => a_hash_including(
75-
'location' => '/var/lib/elasticsearch/backup',
76-
'max_restore_rate' => '20mb',
77-
'max_snapshot_rate' => '80mb'
78-
))
79-
end
68+
describe "http://localhost:#{es_port}/_snapshot/backup" do
69+
subject { shell("curl http://localhost:#{es_port}/_snapshot/backup") }
70+
71+
it 'returns the snapshot repository', :with_retries do
72+
expect(JSON.parse(subject.stdout)['backup']).
73+
to include('settings' => a_hash_including(
74+
'location' => '/var/lib/elasticsearch/backup',
75+
'max_restore_rate' => '20mb',
76+
'max_snapshot_rate' => '80mb'
77+
))
8078
end
8179
end
8280
end

spec/helpers/acceptance/tests/template_shared_examples.rb

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,12 @@
4343
end
4444
end
4545

46-
describe server :container do
47-
describe http(
48-
"http://localhost:#{elasticsearch_port}/_template",
49-
params: { 'flat_settings' => 'false' }
50-
) do
51-
it 'returns the installed template', :with_retries do
52-
expect(JSON.parse(response.body).values).
53-
to include(include(template))
54-
end
46+
describe "http://localhost:#{elasticsearch_port}/_template" do
47+
subject { shell("curl http://localhost:#{elasticsearch_port}/_template") }
48+
49+
it 'returns the installed template', :with_retries do
50+
expect(JSON.parse(subject.stdout).values).
51+
to include(include(template))
5552
end
5653
end
5754
end

0 commit comments

Comments
 (0)