Closed leoc closed 10 years ago
hi,
the container always needs to be destroyed but the image can be preserved by enabling this option ( see example in my nodeset configs ) https://github.com/elasticsearch/puppet-elasticsearch/blob/master/spec/acceptance/nodesets/centos-6-x64.yml#L14
Alright, thank you. I added this to the wiki.
Still, when I use that command and remove the BEAKER
env variables beaker seems to run the following commands every run.
apt-get update
apt-get install --force-yes -y curl
apt-get install --force-yes -y ntpdate
apt-get install --force-yes -y lsb-release
Shouldn't that be part of the image creation process, which should only run once unless/until I delete the image? Or might that be some problem with my projects spec_helper_acceptance.rb
? It looks like that:
require 'beaker-rspec'
require 'pry'
hosts.each do |host|
# install_package host, 'rubygems'
# on host, 'DEBIAN_FRONTEND=noninteractive apt-get install --yes -q openssl libssl-dev'
# on host, 'gem install puppet --no-ri --no-rdoc'
on host, "mkdir -p #{host['distmoduledir']}"
end
RSpec.configure do |c|
# Project root
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
# Readable test descriptions
c.formatter = :documentation
# Configure all nodes in nodeset
c.before :suite do
# Install module
puppet_module_install(:source => proj_root, :module_name => 'puma')
end
end
Hi,
Things that should in the image you can do with this: https://github.com/elasticsearch/puppet-elasticsearch/blob/master/spec/acceptance/nodesets/centos-6-x64.yml#L11-L13
I know that. I am just wondering, why every run of the rake task is executing:
apt-get update
apt-get install --force-yes -y curl
apt-get install --force-yes -y ntpdate
apt-get install --force-yes -y lsb-release
Those have not been defined by my projects configuration. Or so I suppose. :-) And I think they should not be run by beaker but by the image creation process. Isn't it? (At least when using the docker hypervisor)
Ah, those are in beaker it self in the pre-build steps. That's to ensure that they will be installed no matter what.
Ah! I understand.
As I am not into the beaker development (yet :-). What do you think about moving those concerns into the docker image creation process when using docker?
I'd love to create a pull request. My solution would be to not install the packages from the prebuilt steps when using docker and just adding the needed packages to https://github.com/puppetlabs/beaker/blob/master/lib/beaker/hypervisor/docker.rb#L96 Do you have any hints on that?
I think this would speed up the execution of specs tremendously.
I looked again. The validate_host
method does check whether a package is installed.
So I think installing those packages per default in beakers docker code would suffice.
I will have a try and request a pull.
Thank you for your help on this. :+1:
Hi,
The packages are setup by default unrelated to which hyper-visor you use. This is to ensure that the required packages are installed even if the base image that is used have it installed or not. I doubt it will have much use to send a PR for this to be very honest.
Hi again,
As far as I can see those packages are mandatory, as are the packages here: https://github.com/puppetlabs/beaker/blob/master/lib/beaker/hypervisor/docker.rb#L115
Beaker always creates a new image; installing openssh. Why not simply install those packages there too? It speeds up the execution and one does not have to add those packages to the projects host config manually. And it would not break other hypervisors.
Hi,
Sorry that i miss understood you. Yeah it makes sense to put them in that step. I've put them in my nodeset files.
Hi, first let me appreciate beaker. It is amazingly helpful. :+1:
I have switched from vagrant to docker. I like how the Docker images can be based on other images. I would like to create a simple image once with
BEAKER_destroy=no
. On further runs withBEAKER_destroy=no BEAKER_provision=no
a new container should be created without having to run all those necessaryapt-get
calls.But when I run
BEAKER_destroy=no BEAKER_provision=no rake acceptance
I get:That is how my
default.yml
looks like:Is there no way to avoid the creation of a new image each run?
EDIT: Maybe I am misunderstanding things. But as far as I can see
destroy
really stops the current container and then deletes the image? Whereas provision creates the image and runs the necessaryapt-get
calls. Shouldn't those two steps be split up into something likecreate image
,start container from image
,stop and destroy container
anddestroy container and images
. I think the two steps in the middle should not be part ofprovision
anddestroy
, no?