Skip to content

ps output is not trimmed before checking for running process #762

@taurus-forever

Description

@taurus-forever

Describe the bug
Goss doesn't trim the output of ps command which can cause false alarm.

How To Reproduce

root@sp1:~# ps auxww | grep ngcp-fax
faxserv+ 1539901  0.1  2.9 126932 90308 ?        Ss   09:54   0:02 ngcp-faxserver --cfg-file /etc/ngcp-faxserver/faxserver.conf
faxserv+ 1539959  0.0  2.2  82880 69800 ?        S    09:54   0:00 ngcp-faxserver --cfg-file /etc/ngcp-faxserver/faxserver.conf
root@sp1:~# 

root@sp1:~# ps -p 1539901 -o comm
COMMAND
ngcp-faxserver 
root@sp1:~# 

root@sp1:~# ps -p 1539901 -o comm | tail -1| hexdump -C
00000000  6e 67 63 70 2d 66 61 78  73 65 72 76 65 72 20 0a  |ngcp-faxserver .|
00000010
root@sp1:~# 

#### Steps to reproduce: 

root@sp1:~# cat /tmp/failure.yaml

process:
  ngcp-faxserver:
    running: true

root@sp1:~# goss -g /tmp/failure.yaml validate
F

Failures/Skipped:

Process: ngcp-faxserver: running:
Expected
    <bool>: false
to equal
    <bool>: true

Total Duration: 0.004s
Count: 1, Failed: 1, Skipped: 0
root@sp1:~# 


root@sp1:~# cat /tmp/workaround.yaml

process:
  "ngcp-faxserver ":
    running: true

root@sp1:~# goss -g /tmp/workaround.yaml validate
.

Total Duration: 0.004s
Count: 1, Failed: 0, Skipped: 0
root@sp1:~# 

Expected Behavior
Goss should trim ps output befome matching it to the value from YAML file.

Actual Behavior
Goss is not removing trailing space from ps output:

00000000 6e 67 63 70 2d 66 61 78 73 65 72 76 65 72 20 0a |ngcp-faxserver .|
........................................................................................................................ ^

Environment:

  • Version of goss: v0.3.14
  • OS/Distribution version (if applicable): Debian 11 (bullseye)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions