goss-org / goss

Quick and Easy server testing/validation
https://goss.rocks
Apache License 2.0
5.57k stars 472 forks source link

dgoss running process check fails whereas goss pass due to SystemV/Systemd setup #323

Closed JackLeo closed 4 years ago

JackLeo commented 6 years ago

I am using rabbitmq so have a test:

package:
  rabbitmq-server:
    installed: true
    versions:
    - 3.5.0n

process:
  rabbitmq-server:
    running: true

This works a charm on Centos7. Now I want to run the same tests on Docker to validate the automation. In Docker container from centos:7 this does fail with the process not running.

Now the reason as far as I understand is that rabbitmq-server, when launched through System V script, is more detectable.

Centos7:

ps aux | grep rabbitmq-server
root      1173  0.0  0.1 115512  1068 ?        S    09:35   0:00 /bin/sh /etc/rc.d/init.d/rabbitmq-server start
root      1175  0.0  0.1 115244  1480 ?        S    09:35   0:00 /bin/bash -c ulimit -S -c 0 >/dev/null 2>&1 ; /usr/sbin/rabbitmq-server
root      1179  0.0  0.2 187668  2404 ?        S    09:35   0:00 su rabbitmq -s /bin/sh -c /usr/lib/rabbitmq/bin/rabbitmq-server

Docker centos:7:

root         1  0.0  0.0  79812  3868 ?        Ss   16:41   0:00 su rabbitmq -s /bin/sh -c /usr/lib/rabbitmq/bin/rabbitmq-server

So because it is wrapped in su rabbitmq -s /bin/sh -c a test for process running sh does work.

aelsabbahy commented 6 years ago

Correct, the process is bin/sh if you need to test for a portion of the full command name, you can use command with ps or whatever you desire.

JackLeo commented 6 years ago

So process running detects rabbitmq-server within /bin/sh /etc/rc.d/init.d/rabbitmq-server start but not within su rabbitmq -s /bin/sh -c /usr/lib/rabbitmq/bin/rabbitmq-server? How come?

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

aelsabbahy commented 4 years ago

NOTE: This check is inspecting the name of the binary, not the name of the process. For example, a process with the name nginx: master process /usr/sbin/nginx would be checked with the process nginx. To discover the binary of a pid run ps -p -o comm.

Documentation was updated a while back to clarify this. If the functionality changes, the documentation will be updated to reflect that.

https://github.com/aelsabbahy/goss/blob/master/docs/manual.md#process