test-kitchen / test-kitchen

Test Kitchen is an integration tool for developing and testing infrastructure code and software on isolated target platforms
Other
1.87k stars 586 forks source link

serverspec `process` not working corretly #1206

Closed kplimack closed 7 years ago

kplimack commented 7 years ago

Description

this is really an issue for serverspec, but they dont accept issues. https://github.com/mizzy/specinfra/blob/c8a97ef154684452ba059beee4cddbc8e62258c2/lib/specinfra/command/base/process.rb#L4

the process matcher will grab the first thing that partially matches the process that you are looking for. so if you have

haproxy  15473 15466  0 11:49 ?        00:00:00 /usr/sbin/haproxy-master
haproxy  15481 15461  0 11:49 ?        00:00:00 /usr/sbin/haproxy -Ds -f /etc/haproxy/conf.d/jira.cfg -p /var/run/haproxy-jira.pid
haproxy  15484 15473  0 11:49 ?        00:00:00 /usr/sbin/haproxy -Ds -f /etc/haproxy/conf.d/confluence.cfg -p /var/run/haproxy-confluence.pid

and you try to write an audit with

describe process('haproxy') do
  its(:user) { should eq 'haproxy' }
  its(:args) { should contain '-Ds -f /etc/haproxy/conf.d/jira.cfg -p /var/run/haproxy-jira.pid' }
end

you will not be able to match the args, because the process is actually matching haproxy-master, the first one to grep for haproxy.

Kitchen Version

Chef Development Kit Version: 1.2.22 chef-client version: 12.18.31 delivery version: master (0b746cafed65a9ea1a79de3cc546e7922de9187c) berks version: 5.6.3 kitchen version: 1.15.0 specinfra (2.67.2, 2.66.7) serverspec (2.38.0)

coderanger commented 7 years ago

As you said, this is an issue with serverspec/specinfra and we can't really do anything about it.

kplimack commented 7 years ago

@coderanger got any advise on ways to move forwards? I can't be the only one hitting this bug.

coderanger commented 7 years ago

Use a command resource and pgrep instead? Or command('ps something | grep something'). It's all just commands in the end.

MarkGibbons commented 7 years ago

I use a command resource.

kplimack commented 7 years ago

thanks for the advise, thats what I was thinking, too. pretty lame bug, though