Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

[MODULES-4152] Implement install_module and install_module_on methods #3

Merged
merged 4 commits into from
Dec 16, 2016

Conversation

wilson208
Copy link
Contributor

@wilson208 wilson208 commented Dec 5, 2016

Also implemented accompanying unit tests and readme updates. Several supporting functions implemented and unit tested also.

@wilson208 wilson208 changed the title [WIP] Implement install_module_on method [MODULES-4152] Implement install_module and install_module_on methods Dec 5, 2016
Copy link
Contributor

@DavidS DavidS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting close!

before do
@module_source_dir = '/a/b/c/d'
allow(File).to receive(:exist?).and_return(true)
allow(File).to receive(:read).and_return('{"name": "puppetlabs-vcsrepo"}')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be more specific. Add a with() clause like you did below to avoid poisoning the well if the implementation changes later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now added.

end
end

context 'hosts_to_install_module_on with split master/agent setup' do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The duplicated hosts_to_install_module_on in the context description hints at this and the previous context needing a joint parent. "with" is always a good indicator for denoting a context, and therefore usually should go first:

context "#hosts_to_install_module_on" do
  context "with split master/agent setup" do ... end
  context "with solo agent setup" do ... end

PS: also the description here does not describe the reality of the test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made changes to rectify this. Had to disable an rspec cop in .rubocop.yml to allow this change.

# valid metadata.json
while module_source_dir.nil? && search_in.length > 1
# remove last segment (file or folder, doesn't matter)
search_in = search_in.split('/')[0...-1].join('/')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have updated this implementation, let me know what you think!

@@ -3,7 +3,7 @@ source 'https://rubygems.org'
gemspec

group :test do
gem 'beaker', '2.51.0' if RUBY_VERSION <= '2.1.6'
gem 'beaker', '2.52.0' if RUBY_VERSION <= '2.1.6'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does puppet_install_helper also need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have removed this. It is defined in gemspec.


This will install the module under test on the specified host using the local source
### `install_module_on`
This will install the module under test on the specified host using the local source. The module name will be derived from the name property of the module's metadata.json file, assuming it is in format author-modulename.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation could also do with examples. People love copy&pasting working code ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have added usage of install_module and install_module_on. These usage examples are basic and will be more useful when further functionality is implemented.

@wilson208 wilson208 force-pushed the initial_functionality branch 2 times, most recently from 1e207ba to 348656e Compare December 6, 2016 14:17
@wilson208
Copy link
Contributor Author

@DavidS would you be able to take a look at this if you get a chance? Thanks :)

@@ -28,5 +28,6 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'rspec'

# Run time dependencies
spec.add_runtime_dependency 'beaker', '>= 2.0'
spec.add_runtime_dependency 'beaker', '= 2.52' if RUBY_VERSION <= '2.1.6'
spec.add_runtime_dependency 'beaker' if RUBY_VERSION > '2.1.6'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • This is only evaluated at gem build time, but the RUBY_VERSION constraint depends on the executing runtime.
  • there is no 2.52 version of beaker, it's 2.52.0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I should be moving this dependency to the Gemfile and updating the version correctly?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still in the wrong place?

# valid metadata.json
while module_source_dir.nil? && search_in.length > 1
# remove last segment (file or folder, doesn't matter)
search_in = File.join(search_in.split(File::SEPARATOR)[0...-1])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have now fixed this in the latest commits and added an Assumptions section to the README based on what we discussed about requiring a metadata.json in the module. I also included the assumption that for the metadata.json to be found, the bundle install path must be within the module directory, as the bundle install --path option allows the bundle gems to be installed anywhere on the system.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. Have fixed this now, sorry!

@wilson208 wilson208 force-pushed the initial_functionality branch 4 times, most recently from 6f46fe2 to 2235176 Compare December 14, 2016 13:14
…nd install_module_on methods, along with some supporting methods and accompanying tests
module_source_dir = nil
# here we go up the file tree and search the directories for a
# valid metadata.json
while module_source_dir.nil? && search_in.length > 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we also talked about fixing this here for windows.

module_source_dir = nil
# here we go up the file tree and search the directories for a
# valid metadata.json
while module_source_dir.nil? && search_in.length > 2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'C:/'.length is bigger than 2. Alternatively try File.dirname(search_in) == search_in, which should work on any filesystem.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a testcase with no metadata.json to the unit tests below, to avoid any further dead ends here ;-)

@@ -26,7 +26,4 @@ Gem::Specification.new do |spec|

## Testing dependencies
spec.add_development_dependency 'rspec'

# Run time dependencies
spec.add_runtime_dependency 'beaker', '>= 2.0'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is still needed for documentation purposes.

Wilson McCoubrey and others added 2 commits December 16, 2016 12:27
@wilson208 wilson208 merged commit 5ff1ccb into voxpupuli:master Dec 16, 2016
@wilson208 wilson208 deleted the initial_functionality branch December 16, 2016 12:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants