-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from github/kpaulisse-modulepath
Use modulepath from environment.conf if available
- Loading branch information
Showing
14 changed files
with
364 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.5.4 | ||
0.5.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
spec/octocatalog-diff/fixtures/catalogs/catalog-modules-test.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{ | ||
"document_type": "Catalog", | ||
"tags": ["settings","test"], | ||
"name": "my.rspec.node", | ||
"version": "production", | ||
"environment": "production", | ||
"resources": [ | ||
{ | ||
"type": "Stage", | ||
"title": "main", | ||
"tags": ["stage"], | ||
"exported": false, | ||
"parameters": { | ||
"name": "main" | ||
} | ||
}, | ||
{ | ||
"type": "Class", | ||
"title": "Settings", | ||
"tags": ["class","settings"], | ||
"exported": false | ||
}, | ||
{ | ||
"type": "File", | ||
"title": "/tmp/foo", | ||
"tags": ["file","class"], | ||
"file": "/x/modules/modulestest/manifests/init.pp", | ||
"line": 37, | ||
"exported": false, | ||
"parameters": { | ||
"backup": false, | ||
"mode": "0440", | ||
"owner": "root", | ||
"group": "root", | ||
"source": "puppet:///modules/modulestest/tmp/modulestest" | ||
} | ||
}, | ||
{ | ||
"type": "File", | ||
"title": "/tmp/foobaz", | ||
"tags": ["file","class"], | ||
"file": "/x/modules/modulestest/manifests/init.pp", | ||
"line": 37, | ||
"exported": false, | ||
"parameters": { | ||
"backup": false, | ||
"ensure": "directory", | ||
"mode": "0755", | ||
"owner": "root", | ||
"group": "root", | ||
"source": "puppet:///modules/modulestest/foo" | ||
} | ||
} | ||
], | ||
"classes": [ | ||
"test" | ||
] | ||
} |
1 change: 1 addition & 0 deletions
1
spec/octocatalog-diff/fixtures/repos/modulepath/environment.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
modulepath=modules:site:$basemodulepath |
4 changes: 4 additions & 0 deletions
4
spec/octocatalog-diff/fixtures/repos/modulepath/manifests/site.pp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node default { | ||
include modulestest | ||
include sitetest | ||
} |
1 change: 1 addition & 0 deletions
1
spec/octocatalog-diff/fixtures/repos/modulepath/modules/modulestest/files/foo/bar.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Hi |
1 change: 1 addition & 0 deletions
1
spec/octocatalog-diff/fixtures/repos/modulepath/modules/modulestest/files/tmp/modulestest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Modules Test |
11 changes: 11 additions & 0 deletions
11
spec/octocatalog-diff/fixtures/repos/modulepath/modules/modulestest/manifests/init.pp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class modulestest { | ||
file { '/tmp/modulestest': | ||
source => 'puppet:///modules/modulestest/tmp/modulestest', | ||
} | ||
|
||
file { '/tmp/foobaz': | ||
ensure => directory, | ||
source => 'puppet:///modules/modulestest/foo', | ||
recurse => true, | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
spec/octocatalog-diff/fixtures/repos/modulepath/site/sitetest/files/tmp/sitetest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Site Test |
5 changes: 5 additions & 0 deletions
5
spec/octocatalog-diff/fixtures/repos/modulepath/site/sitetest/manifests/init.pp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class sitetest { | ||
file { '/tmp/sitetest': | ||
source => 'puppet:///modules/sitetest/tmp/sitetest', | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
require_relative 'integration_helper' | ||
require OctocatalogDiff::Spec.require_path('/catalog') | ||
|
||
describe 'multiple module paths' do | ||
# Make sure the catalog compiles correctly, without using any of the file | ||
# conversion resources. If the catalog doesn't compile correctly this could | ||
# indicate a problem that lies somewhere other than the comparison code. | ||
describe 'catalog only' do | ||
before(:all) do | ||
@result = OctocatalogDiff::Integration.integration( | ||
spec_fact_file: 'facts.yaml', | ||
spec_repo: 'modulepath', | ||
argv: [ | ||
'--catalog-only', | ||
'-n', 'rspec-node.github.net', | ||
'--no-compare-file-text' | ||
] | ||
) | ||
@catalog = OctocatalogDiff::Catalog.new( | ||
backend: :json, | ||
json: @result[:output] | ||
) | ||
end | ||
|
||
it 'should compile' do | ||
expect(@result[:exitcode]).not_to eq(-1), OctocatalogDiff::Integration.format_exception(@result) | ||
end | ||
|
||
it 'should be a valid catalog' do | ||
pending 'catalog failed to compile' if @result[:exitcode] == -1 | ||
expect(@catalog.valid?).to eq(true) | ||
end | ||
|
||
it 'should have expected resources in catalog' do | ||
pending 'catalog was invalid' unless @catalog.valid? | ||
expect(@catalog.resources).to be_a_kind_of(Array) | ||
|
||
mf = @catalog.resource(type: 'File', title: '/tmp/modulestest') | ||
expect(mf).to be_a_kind_of(Hash) | ||
expect(mf['parameters']).to eq('source' => 'puppet:///modules/modulestest/tmp/modulestest') | ||
|
||
sf = @catalog.resource(type: 'File', title: '/tmp/sitetest') | ||
expect(sf).to be_a_kind_of(Hash) | ||
expect(sf['parameters']).to eq('source' => 'puppet:///modules/sitetest/tmp/sitetest') | ||
end | ||
end | ||
|
||
# Test the file comparison feature itself here in its various iterations. | ||
describe 'file comparison feature' do | ||
before(:each) do | ||
@from_dir = Dir.mktmpdir | ||
FileUtils.cp_r OctocatalogDiff::Spec.fixture_path('repos/modulepath'), @from_dir | ||
|
||
@to_dir = Dir.mktmpdir | ||
FileUtils.cp_r OctocatalogDiff::Spec.fixture_path('repos/modulepath'), @to_dir | ||
|
||
file1 = File.join(@to_dir, 'modulepath', 'modules', 'modulestest', 'files', 'tmp', 'modulestest') | ||
File.open(file1, 'w') { |f| f.write("New content of modulestest\n") } | ||
|
||
file2 = File.join(@to_dir, 'modulepath', 'site', 'sitetest', 'files', 'tmp', 'sitetest') | ||
File.open(file2, 'w') { |f| f.write("New content of sitetest\n") } | ||
end | ||
|
||
after(:each) do | ||
OctocatalogDiff::Spec.clean_up_tmpdir(@from_dir) | ||
OctocatalogDiff::Spec.clean_up_tmpdir(@to_dir) | ||
end | ||
|
||
let(:module_answer) do | ||
['~', | ||
"File\f/tmp/modulestest\fparameters\fcontent", | ||
"Modules Test\n", | ||
"New content of modulestest\n"] | ||
end | ||
|
||
let(:site_answer) do | ||
[ | ||
'~', | ||
"File\f/tmp/sitetest\fparameters\fcontent", | ||
"Site Test\n", | ||
"New content of sitetest\n" | ||
] | ||
end | ||
|
||
context 'with environment.conf' do | ||
# The environment.conf is a fixture within the repository so there is no need | ||
# to create it or manipulate it. | ||
before(:each) do | ||
@result = OctocatalogDiff::Integration.integration( | ||
spec_fact_file: 'facts.yaml', | ||
argv: [ | ||
'-n', 'rspec-node.github.net', | ||
'--bootstrapped-from-dir', File.join(@from_dir, 'modulepath'), | ||
'--bootstrapped-to-dir', File.join(@to_dir, 'modulepath') | ||
] | ||
) | ||
end | ||
|
||
it 'should compile catalogs and compute differences' do | ||
expect(@result[:exitcode]).to eq(2), OctocatalogDiff::Integration.format_exception(@result) | ||
expect(@result[:diffs]).to be_a_kind_of(Array) | ||
expect(@result[:diffs].size).to eq(2) | ||
expect(OctocatalogDiff::Spec.array_contains_partial_array?(@result[:diffs], module_answer)).to eq(true) | ||
expect(OctocatalogDiff::Spec.array_contains_partial_array?(@result[:diffs], site_answer)).to eq(true) | ||
end | ||
end | ||
|
||
context 'without environment.conf in one directory' do | ||
before(:each) do | ||
FileUtils.rm_f File.join(@from_dir, 'modulepath', 'environment.conf') | ||
FileUtils.mv File.join(@from_dir, 'modulepath', 'site', 'sitetest'), File.join(@from_dir, 'modulepath', 'modules') | ||
@result = OctocatalogDiff::Integration.integration( | ||
spec_fact_file: 'facts.yaml', | ||
argv: [ | ||
'-n', 'rspec-node.github.net', | ||
'--bootstrapped-from-dir', File.join(@from_dir, 'modulepath'), | ||
'--bootstrapped-to-dir', File.join(@to_dir, 'modulepath') | ||
] | ||
) | ||
end | ||
|
||
it 'should compile catalogs and compute differences' do | ||
expect(@result[:exitcode]).to eq(2), OctocatalogDiff::Integration.format_exception(@result) | ||
expect(@result[:diffs]).to be_a_kind_of(Array) | ||
expect(@result[:diffs].size).to eq(2) | ||
expect(OctocatalogDiff::Spec.array_contains_partial_array?(@result[:diffs], module_answer)).to eq(true) | ||
expect(OctocatalogDiff::Spec.array_contains_partial_array?(@result[:diffs], site_answer)).to eq(true) | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.