Skip to content
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

service().must_be_running doesn't properly work on CentOS #66

Open
kadishmal opened this issue Jul 30, 2013 · 7 comments
Open

service().must_be_running doesn't properly work on CentOS #66

kadishmal opened this issue Jul 30, 2013 · 7 comments

Comments

@kadishmal
Copy link

I have the following assertion test in test/cookbooks/cubrid_test/files/default/tests/minitest/default_test.rb file.

it "should start CUBRID Service" do
    service('cub_master').must_be_running
end

Running it CentOS 6.4 x64 Vagrant box via Test Kitchen returned the following failure:

Finished tests in 0.376402s, 45.1645 tests/s, 45.1645 assertions/s.

1) Failure:
recipe::cubrid::default#test_0009_should start CUBRID Service [/var/chef/minitest/cubrid_test/default_test.rb:46]:
Expected service 'cub_master' to be running

17 tests, 17 assertions, 1 failures, 0 errors, 0 skips

If I login to this CentOS Vagrant box, I can confirm that the service is running:

$ sudo su -
[root@cubrid-910-centos-64-x64 ~]# ps axl | grep cub_master
1     0  2100     1  20   0  51884   184 poll_s Ss   ?          0:00 cub_master
0     0 15999 15977  20   0 103240   868 pipe_w S+   pts/0      0:00 grep cub_master

Running Kitchen test on Ubuntu 10+ Vagrant boxes, passes all tests.

@stevendanna
Copy link

I believe there are two issues here.

  1. Minitest will use whatever the default provider on the platform is. In the case of Centos it is Chef::Provider::Service::Redhat. According to my reading, this doesn't check for whether or not the service is running in it's load_current_resource method. (This should probably be filed as a Chef bug.)
  2. Because it is using the default provider for the platform, it might still get the wrong answer if the cookbook you are testing specifically set the provider to a different service provider such as Upstart.

@ppg
Copy link

ppg commented Jun 18, 2014

@stevendanna Is there a way to tell minitest to use a different provider, if you know for example that its an upstart service instead of lsbinit or whatever?

@Rucknar
Copy link

Rucknar commented Jun 19, 2014

@ppgengler We had this issue with vmware tools which uses upstart on RH6 and init on RH5.
The code in our test looks like this:

 if Chef::VersionConstraint.new(">= 6.0").include?(node['platform_version'])
    result = assert_sh("/sbin/status vmware-tools-services")
    assert_includes result, "start/running"
 else
    service("vmware-tools-services").must_be_running
 end

@stevendanna
Copy link

@ppgengler An alternative to something like superted mentioned would be something like:

https://github.com/opscode-cookbooks/chef-client/pull/115/files

@Rucknar
Copy link

Rucknar commented Jun 19, 2014

^ Definitely a cleaner method.

@ppg
Copy link

ppg commented Jun 19, 2014

That's cool, although I'll admit I was hoping for something on the minitest-chef-handler side like:

service('foobar', :provider => Chef::Provider::Service::Upstart).must_be_running

That did that work for me; perhaps even took symbols like :upstart and translated into the providers. I'll poke around and contemplate a PR for it, if you're open?

@bplunkert
Copy link

👍 @ppgengler that syntax looks ideal to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants