onceover 3.2.6 → 3.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/Rakefile +21 -7
- data/features/init.feature +19 -0
- data/features/step_definitions/command.rb +28 -0
- data/features/step_definitions/common.rb +50 -8
- data/lib/onceover/testconfig.rb +1 -1
- data/onceover.gemspec +1 -1
- data/spec/acceptance/controlrepo_spec.rb +37 -0
- data/spec/fixtures/controlrepo_basic/Puppetfile +17 -0
- data/spec/fixtures/controlrepo_basic/environment.conf +2 -1
- data/spec/fixtures/controlrepo_basic/hieradata/common.yaml +2 -0
- data/spec/fixtures/controlrepo_basic/hieradata/nodes/example-node.yaml +1 -0
- data/spec/fixtures/controlrepo_basic/manifests/site.pp +32 -0
- data/spec/fixtures/controlrepo_basic/site/profile/manifests/base.pp +5 -0
- data/spec/fixtures/controlrepo_basic/site/profile/manifests/example.pp +3 -0
- data/spec/fixtures/controlrepo_basic/site/role/manifests/database_server.pp +7 -0
- data/spec/fixtures/controlrepo_basic/site/role/manifests/example.pp +3 -0
- data/spec/fixtures/controlrepo_basic/site/role/manifests/webserver.pp +7 -0
- data/spec/fixtures/controlrepo_minimal/environment.conf +2 -0
- data/spec/onceover/controlrepo_spec.rb +1 -34
- metadata +15 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6258620982ccd165a8b28db772919db88228298f
|
4
|
+
data.tar.gz: a605dc65458a48fe892558a350d08f69c1478ac3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6de5b5c139e1b6a931dfa34f748967c69d54866d3ddce13b2a7e77f6ccc203cde527f8d6ed6bef4002eb83b9c458cda3b61f38e5f569ca5c319f1a7e0d9856ec
|
7
|
+
data.tar.gz: c4671a56297178b4d61c9f49984b86cc3a7ab3c2302e77528685d62fc9b19c482885c781e60f2e2e3cba01db5115f5e610e8c5090ee35da4440bdaeb1471875b
|
data/.gitignore
CHANGED
data/Rakefile
CHANGED
@@ -4,24 +4,32 @@ require 'cucumber/rake/task'
|
|
4
4
|
Gem::Tasks.new
|
5
5
|
|
6
6
|
RSpec::Core::RakeTask.new(:spec) do |t|
|
7
|
-
t.rspec_opts = '--pattern spec
|
7
|
+
t.rspec_opts = '--pattern spec/onceover/**/*_spec.rb'
|
8
|
+
end
|
9
|
+
|
10
|
+
RSpec::Core::RakeTask.new(:acceptance) do |t|
|
11
|
+
t.rspec_opts = '--pattern spec/acceptance/**/*_spec.rb'
|
8
12
|
end
|
9
13
|
|
10
14
|
Cucumber::Rake::Task.new
|
11
15
|
|
12
16
|
task default: :full_tests
|
13
17
|
|
14
|
-
desc "Run full set of tests"
|
15
|
-
task full_tests: [:unit_tests, :acceptance_tests]
|
16
18
|
|
17
19
|
desc "Run unit tests"
|
18
|
-
task
|
20
|
+
task rspec_unit_tests: [:syntax, :rubocop, :spec]
|
19
21
|
|
20
|
-
desc "Run acceptance tests"
|
21
|
-
task
|
22
|
+
desc "Run acceptance cucumber tests"
|
23
|
+
task cucumber_acceptance_tests: [:syntax, :rubocop, :cucumber]
|
24
|
+
|
25
|
+
desc "Run acceptance rspec tests"
|
26
|
+
task rspec_acceptance_tests: [:syntax, :rubocop, :fixtures, :acceptance]
|
27
|
+
|
28
|
+
desc "Run full set of tests"
|
29
|
+
task full_tests: [:rspec_unit_tests, :rspec_acceptance_tests, :cucumber_acceptance_tests]
|
22
30
|
|
23
31
|
task :syntax do
|
24
|
-
paths = ['lib',]
|
32
|
+
paths = ['lib', 'spec/onceover', 'spec/acceptance', 'features']
|
25
33
|
require 'find'
|
26
34
|
Find.find(*paths) do |path|
|
27
35
|
next unless path =~ /\.rb$/
|
@@ -35,3 +43,9 @@ task :rubocop do
|
|
35
43
|
exit_code = cli.run(%w(--display-cop-names --format simple))
|
36
44
|
raise "RuboCop detected offenses" if exit_code != 0
|
37
45
|
end
|
46
|
+
|
47
|
+
task :fixtures do
|
48
|
+
system 'git submodule init && git submodule update --recursive'
|
49
|
+
raise "Couldn't clone controlrepo to fixtures directory" unless $?.success?
|
50
|
+
end
|
51
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Feature: Initialize Onceover application
|
2
|
+
For correct control repo I would like to generate all folders and files needed
|
3
|
+
by Onceover. For incorrect control repo I would like to get information why
|
4
|
+
I can not initialize application.
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given onceover executable
|
8
|
+
|
9
|
+
Scenario: Initialize basic repo
|
10
|
+
Given control repo "controlrepo_basic"
|
11
|
+
When I run onceover command "init"
|
12
|
+
Then I should not see any errors
|
13
|
+
And I should see generated all necessary files and folders
|
14
|
+
|
15
|
+
Scenario: Initialize repo with missing environment.conf file
|
16
|
+
Given control repo "controlrepo_basic" without "environment.conf"
|
17
|
+
When I run onceover command "init"
|
18
|
+
Then I should see error with message pattern "No such file or directory.*environment.conf"
|
19
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "open3"
|
2
|
+
|
3
|
+
class Command
|
4
|
+
|
5
|
+
attr_reader(:output, :result)
|
6
|
+
|
7
|
+
attr_writer(:command, :params, :controlrepo)
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@executable = ENV["BUNDLE_GEMFILE"] ? "bundle exec onceover" : "onceover"
|
11
|
+
end
|
12
|
+
|
13
|
+
def run
|
14
|
+
controlrepo_param = @controlrepo ? "--path tmp/tests/#{@controlrepo}" : ''
|
15
|
+
full_cmd = "#{@executable} #{@command} #{controlrepo_param}"
|
16
|
+
@output, @result = Open3.capture2e full_cmd
|
17
|
+
end
|
18
|
+
|
19
|
+
def success?
|
20
|
+
return @result.success?
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_s
|
24
|
+
controlrepo_param = @controlrepo ? "--path tmp/tests/#{@controlrepo}" : ''
|
25
|
+
return "#{@executable} #{@command} #{controlrepo_param}"
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -1,18 +1,60 @@
|
|
1
|
-
Given /^onceover executable$/
|
2
|
-
@
|
1
|
+
Given /^onceover executable$/ do
|
2
|
+
@cmd = Command.new
|
3
3
|
end
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
Given(/^control repo "([^"]*)"$/) do |controlrepo_name|
|
6
|
+
@cmd.controlrepo = controlrepo_name
|
7
|
+
FileUtils.rm_rf "tmp/tests/#{controlrepo_name}"
|
8
|
+
FileUtils.mkdir_p 'tmp/tests'
|
9
|
+
FileUtils.cp_r "spec/fixtures/#{controlrepo_name}", 'tmp/tests'
|
10
|
+
end
|
11
|
+
|
12
|
+
Given(/^control repo "([^"]*)" without "([^"]*)"$/) do |controlrepo_name, filename|
|
13
|
+
step %Q(control repo "#{controlrepo_name}")
|
14
|
+
controlrepo_path = "tmp/tests/#{controlrepo_name}"
|
15
|
+
FileUtils.rm_rf( controlrepo_path + "/#{filename}" )
|
16
|
+
end
|
17
|
+
|
18
|
+
Then(/^I should see all tests pass$/) do
|
19
|
+
pending # Write code here that turns the phrase above into concrete actions
|
20
|
+
end
|
21
|
+
|
22
|
+
When /^I run onceover command "([^"]*)"$/ do |command|
|
23
|
+
@cmd.command = command
|
24
|
+
puts @cmd
|
25
|
+
@cmd.run
|
10
26
|
end
|
11
27
|
|
12
28
|
Then /^I see help for commands: "([^"]*)"$/ do |commands|
|
13
|
-
|
29
|
+
# Get chunk of output between COMMANDS and OPTION, there should be help section
|
30
|
+
commands_help = @cmd.output[/COMMANDS(.*)OPTIONS/m, 1]
|
14
31
|
commands.split(',').each do |command|
|
15
32
|
result = commands_help.match(/^\s+#{command.strip}.+\n/)
|
16
33
|
puts result.to_s if expect(result).not_to be nil
|
17
34
|
end
|
18
35
|
end
|
36
|
+
|
37
|
+
Then(/^I should not see any errors$/) do
|
38
|
+
expect(@cmd.success?).to be true
|
39
|
+
end
|
40
|
+
|
41
|
+
Then(/^I should see error with message pattern "([^"]*)"$/) do |err_msg_regexp|
|
42
|
+
expect(@cmd.success?).to be false
|
43
|
+
puts @cmd.output
|
44
|
+
expect(@cmd.output.match err_msg_regexp).to_not be nil
|
45
|
+
end
|
46
|
+
|
47
|
+
Then(/^I should see generated all necessary files and folders$/) do
|
48
|
+
controlrepo_path = "tmp/tests/controlrepo_basic/"
|
49
|
+
files = [ 'spec/onceover.yaml', 'Rakefile', 'Gemfile' ].map { |x| controlrepo_path + x }
|
50
|
+
folders = [ 'spec/factsets', 'spec/pre_conditions'].map! { |x| controlrepo_path + x}
|
51
|
+
|
52
|
+
files.each do |file|
|
53
|
+
puts file
|
54
|
+
expect( File.exist? file ).to be true
|
55
|
+
end
|
56
|
+
folders.each do |folder|
|
57
|
+
puts folder
|
58
|
+
expect( Dir.exist? folder ).to be true
|
59
|
+
end
|
60
|
+
end
|
data/lib/onceover/testconfig.rb
CHANGED
@@ -218,7 +218,7 @@ class Onceover
|
|
218
218
|
# R10K::Action::Deploy::Environment
|
219
219
|
prod_dir = "#{repo.tempdir}/#{repo.environmentpath}/production"
|
220
220
|
Dir.chdir(prod_dir) do
|
221
|
-
install_cmd = "r10k puppetfile install --verbose --color"
|
221
|
+
install_cmd = "r10k puppetfile install --verbose --color --puppetfile #{repo.puppetfile}"
|
222
222
|
logger.debug "Running #{install_cmd} from #{prod_dir}"
|
223
223
|
system(install_cmd)
|
224
224
|
end
|
data/onceover.gemspec
CHANGED
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "onceover"
|
6
|
-
s.version = "3.2.
|
6
|
+
s.version = "3.2.7"
|
7
7
|
s.authors = ["Dylan Ratcliffe"]
|
8
8
|
s.email = ["dylan.ratcliffe@puppet.com"]
|
9
9
|
s.homepage = "https://github.com/dylanratcliffe/onceover"
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'onceover/controlrepo'
|
3
|
+
|
4
|
+
describe "Onceover::Controlrepo" do
|
5
|
+
context "in a complex repo" do
|
6
|
+
before do
|
7
|
+
@repo = Onceover::Controlrepo.new(
|
8
|
+
{
|
9
|
+
path:'spec/fixtures/puppet_controlrepo'
|
10
|
+
}
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
context "when initialising the object" do
|
15
|
+
it { expect(@repo).not_to be_nil }
|
16
|
+
end
|
17
|
+
|
18
|
+
context "when running the tests" do
|
19
|
+
it "doesn't die horribly" do
|
20
|
+
expect{
|
21
|
+
Dir.chdir('spec/fixtures/puppet_controlrepo') do
|
22
|
+
require 'onceover/controlrepo'
|
23
|
+
require 'onceover/cli'
|
24
|
+
require 'onceover/runner'
|
25
|
+
require 'onceover/testconfig'
|
26
|
+
require 'onceover/logger'
|
27
|
+
|
28
|
+
repo = Onceover::Controlrepo.new({})
|
29
|
+
runner = Onceover::Runner.new(repo,Onceover::TestConfig.new(repo.onceover_yaml, {}), :spec)
|
30
|
+
runner.prepare!
|
31
|
+
runner.run_spec!
|
32
|
+
end
|
33
|
+
}.not_to raise_error
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
forge "http://forge.puppetlabs.com"
|
2
|
+
|
3
|
+
# Modules from the Puppet Forge
|
4
|
+
# Versions should be updated to be the latest at the time you start
|
5
|
+
#mod "puppetlabs/inifile", '1.5.0'
|
6
|
+
#mod "puppetlabs/stdlib", '4.11.0'
|
7
|
+
#mod "puppetlabs/concat", '2.1.0'
|
8
|
+
|
9
|
+
# Modules from Git
|
10
|
+
# Examples: https://github.com/puppetlabs/r10k/blob/master/doc/puppetfile.mkd#examples
|
11
|
+
#mod 'apache',
|
12
|
+
# :git => 'https://github.com/puppetlabs/puppetlabs-apache',
|
13
|
+
# :commit => '83401079053dca11d61945bd9beef9ecf7576cbf'
|
14
|
+
|
15
|
+
#mod 'apache',
|
16
|
+
# :git => 'https://github.com/puppetlabs/puppetlabs-apache',
|
17
|
+
# :branch => 'docs_experiment'
|
@@ -1 +1,2 @@
|
|
1
|
-
modulepath=
|
1
|
+
modulepath = site:modules:$basemodulepath
|
2
|
+
config_version = 'scripts/config_version.sh $environmentpath $environment'
|
@@ -0,0 +1 @@
|
|
1
|
+
---
|
@@ -0,0 +1,32 @@
|
|
1
|
+
## site.pp ##
|
2
|
+
|
3
|
+
# This file (/etc/puppetlabs/puppet/manifests/site.pp) is the main entry point
|
4
|
+
# used when an agent connects to a master and asks for an updated configuration.
|
5
|
+
#
|
6
|
+
# Global objects like filebuckets and resource defaults should go in this file,
|
7
|
+
# as should the default node definition. (The default node can be omitted
|
8
|
+
# if you use the console and don't define any other nodes in site.pp. See
|
9
|
+
# http://docs.puppetlabs.com/guides/language_guide.html#nodes for more on
|
10
|
+
# node definitions.)
|
11
|
+
|
12
|
+
## Active Configurations ##
|
13
|
+
|
14
|
+
# Disable filebucket by default for all File resources:
|
15
|
+
#https://docs.puppet.com/pe/2015.3/release_notes.html#filebucket-resource-no-longer-created-by-default
|
16
|
+
File { backup => false }
|
17
|
+
|
18
|
+
# DEFAULT NODE
|
19
|
+
# Node definitions in this file are merged with node data from the console. See
|
20
|
+
# http://docs.puppetlabs.com/guides/language_guide.html#nodes for more on
|
21
|
+
# node definitions.
|
22
|
+
|
23
|
+
# The default node definition matches any node lacking a more specific node
|
24
|
+
# definition. If there are no other nodes in this file, classes declared here
|
25
|
+
# will be included in every node's catalog, *in addition* to any classes
|
26
|
+
# specified in the console for that node.
|
27
|
+
|
28
|
+
node default {
|
29
|
+
# This is where you can declare classes for all nodes.
|
30
|
+
# Example:
|
31
|
+
# class { 'my_class': }
|
32
|
+
}
|
@@ -6,7 +6,7 @@ describe "Onceover::Controlrepo" do
|
|
6
6
|
before do
|
7
7
|
@repo = Onceover::Controlrepo.new(
|
8
8
|
{
|
9
|
-
path:'spec/fixtures/
|
9
|
+
path:'spec/fixtures/controlrepo_minimal'
|
10
10
|
}
|
11
11
|
)
|
12
12
|
end
|
@@ -15,37 +15,4 @@ describe "Onceover::Controlrepo" do
|
|
15
15
|
it { expect(@repo.hiera_config_file_relative_path).to be_nil }
|
16
16
|
end
|
17
17
|
end
|
18
|
-
|
19
|
-
context "in a complex repo" do
|
20
|
-
before do
|
21
|
-
@repo = Onceover::Controlrepo.new(
|
22
|
-
{
|
23
|
-
path:'spec/fixtures/puppet_controlrepo'
|
24
|
-
}
|
25
|
-
)
|
26
|
-
end
|
27
|
-
|
28
|
-
context "when initialising the object" do
|
29
|
-
it { expect(@repo).not_to be_nil }
|
30
|
-
end
|
31
|
-
|
32
|
-
context "when running the tests" do
|
33
|
-
it "doesn't die horribly" do
|
34
|
-
expect{
|
35
|
-
Dir.chdir('spec/fixtures/puppet_controlrepo') do
|
36
|
-
require 'onceover/controlrepo'
|
37
|
-
require 'onceover/cli'
|
38
|
-
require 'onceover/runner'
|
39
|
-
require 'onceover/testconfig'
|
40
|
-
require 'onceover/logger'
|
41
|
-
|
42
|
-
repo = Onceover::Controlrepo.new({})
|
43
|
-
runner = Onceover::Runner.new(repo,Onceover::TestConfig.new(repo.onceover_yaml, {}), :spec)
|
44
|
-
runner.prepare!
|
45
|
-
runner.run_spec!
|
46
|
-
end
|
47
|
-
}.not_to raise_error
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
18
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onceover
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dylan Ratcliffe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -342,6 +342,8 @@ files:
|
|
342
342
|
- factsets/solaris-10_u9-sparc-64.json
|
343
343
|
- factsets/solaris-11.2-sparc-64.json
|
344
344
|
- features/basic.feature
|
345
|
+
- features/init.feature
|
346
|
+
- features/step_definitions/command.rb
|
345
347
|
- features/step_definitions/common.rb
|
346
348
|
- features/support/env.rb
|
347
349
|
- lib/onceover/beaker.rb
|
@@ -362,7 +364,18 @@ files:
|
|
362
364
|
- lib/onceover/test.rb
|
363
365
|
- lib/onceover/testconfig.rb
|
364
366
|
- onceover.gemspec
|
367
|
+
- spec/acceptance/controlrepo_spec.rb
|
368
|
+
- spec/fixtures/controlrepo_basic/Puppetfile
|
365
369
|
- spec/fixtures/controlrepo_basic/environment.conf
|
370
|
+
- spec/fixtures/controlrepo_basic/hieradata/common.yaml
|
371
|
+
- spec/fixtures/controlrepo_basic/hieradata/nodes/example-node.yaml
|
372
|
+
- spec/fixtures/controlrepo_basic/manifests/site.pp
|
373
|
+
- spec/fixtures/controlrepo_basic/site/profile/manifests/base.pp
|
374
|
+
- spec/fixtures/controlrepo_basic/site/profile/manifests/example.pp
|
375
|
+
- spec/fixtures/controlrepo_basic/site/role/manifests/database_server.pp
|
376
|
+
- spec/fixtures/controlrepo_basic/site/role/manifests/example.pp
|
377
|
+
- spec/fixtures/controlrepo_basic/site/role/manifests/webserver.pp
|
378
|
+
- spec/fixtures/controlrepo_minimal/environment.conf
|
366
379
|
- spec/onceover/controlrepo_spec.rb
|
367
380
|
- spec/spec_helper.rb
|
368
381
|
- templates/.fixtures.yml.erb
|