-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add integration test with itamae local
command
#281
Conversation
@@ -206,7 +178,7 @@ | |||
end | |||
|
|||
describe command('gem list') do | |||
its(:stdout) { should include('rake (11.1.0)') } | |||
its(:stdout) { should match(/^rake \(.*11.1.0.*\)/) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another rake version is installed in the docker image that is used for itamae local
command test, so relax the test.
@@ -0,0 +1,10 @@ | |||
package 'sl' do | |||
version '3.03-17+b2' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ruby
docker image does not have sl
package version 3.03-17
, it only has 3.03-17+b2
.
|
||
gem_package 'bundler' do | ||
version '1.17.3' | ||
options ['--no-document'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New rubygems, which is installed in ruby
docker image, does not have --no-rdoc
and --no-ri
options. So use --no-document
option instead.
Note: Ubuntu trusty, which is used in the existing integration test, installs Ruby 1.9.3!!!!! Rubygems on Ruby 1.9.3 has --no-rodc
and --no-ri
options 🙃 .
@@ -1,5 +1,6 @@ | |||
language: ruby | |||
sudo: required | |||
dist: xenial |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need upgrading ubuntu version to use new version docker.
In trusty, docker exec
does not have --workdir
option, so I upgraded it to xenial.
9dc4102
to
427bf88
Compare
Because bundler is too special gem, I got an unexpected and mysterious error with bundler, so I replaced bundler with ast, which is not a special gem.
|
||
def docker_run | ||
mount_dir = Pathname(__dir__).join('../').to_s | ||
sh 'docker', 'run', '--privileged', '-d', '--name', CONTAINER_NAME, '-v', "#{mount_dir}:/itamae", "ruby:#{@ruby_version}", 'sleep', '1d' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sleep
command is a hack...
/sbin/init
is used for the existing integration test, but the image does not have /sbin/init
.
So use sleep
command instead.
Because `ruby:2.7` image does not exist until releasing Ruby 2.7
itamae local
commanditamae local
command
I think this pull request is ready to review. Can you review this pull request? I still have an unchecked TODO, but I will work on the todo on #277 . |
@@ -64,7 +69,7 @@ namespace :spec do | |||
RSpec::Core::RakeTask.new(target.to_sym) do |t| | |||
ENV['DOCKER_CONTAINER'] = container_name | |||
t.ruby_opts = '-I ./spec/integration' | |||
t.pattern = "spec/integration/*_spec.rb" | |||
t.pattern = "spec/integration/[default|docker]_spec.rb" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary?
Even without changing here, I think that default_spec.rb
and docker_spec.rb
will be executed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, it is unnecessary, but I think it is necessary in the near future.
Because I'll add a test case(s) for #277 , and serverspec file. Probably the new serverspec file is needed only by the new test. Test for itamae docker
should not load the new serverspec file, so it's necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🕺
@pocke Can I merge this PR? |
Sure! Thanks for your reviewing! |
Since itamae-kitchen#281 , spec for integration tests are not executed. Because the pattern is not correct. `[default|docker]` is bad for OR pattern. It should be `{default,docker}`. It was introduced by me. I'm sorry🙇🙇 Before === ```console $ bundle exec rake spec:integration:ubuntu:trusty (snip) /home/pocke/.rbenv/versions/trunk/bin/ruby -I ./spec/integration -I/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/rspec-core-3.8.0/lib:/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/rspec-support-3.8.0/lib /home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/rspec-core-3.8.0/exe/rspec --pattern spec/integration/\[default\|docker\]_spec.rb No examples found. Finished in 0.00016 seconds (files took 0.03293 seconds to load) 0 examples, 0 failures ``` After === ```console $ bundle exec rake spec:integration:ubuntu:trusty (snip) /home/pocke/.rbenv/versions/trunk/bin/ruby -I ./spec/integration -I/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/rspec-core-3.8.0/lib:/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/rspec-support-3.8.0/lib /home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/rspec-core-3.8.0/exe/rspec --pattern spec/integration/\{default,docker\}_spec.rb (snip) Finished in 13.9 seconds (files took 0.28032 seconds to load) 139 examples, 0 failures ```
Problem
We don't have any integration test for
itamae local
command, so we cannot test #277.Solution
Add an integation test for
itamae local
command.Strategy:
itamae local
comamnd in the container.Goal of this pull request
itamae local
alsosend_file
aware ofuser
option #277 (maybe I should work this todo on Makesend_file
aware ofuser
option #277 )