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

[dgoss] Use inspect instead of top in health check #473

Merged
merged 1 commit into from
Nov 11, 2019

Conversation

jgeorgeson
Copy link
Contributor

Just started using Goss, very nice! I came across #376 trying to publish JUnit results in my CI. This change tests if the container is running without producing any output to be redirected. This change is working in my environment. Additionally tested with your dgoss-examples repo nginx goss.yaml

$ GOSS_OPTS="--format junit" dgoss run nginx:1.11.10 > junit.xml
INFO: Starting docker container
INFO: Container ID: 9ddf7dec
INFO: Sleeping for 0.2
INFO: Container health
INFO: Running Tests
INFO: Deleting container
$ head -3 junit.xml 
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="goss" errors="0" tests="13" failures="0" skipped="0" time="0.010" timestamp="2019-08-08T22:46:38Z">
<testcase name="Process nginx running" time="0.000">

@jgeorgeson
Copy link
Contributor Author

Doesn't look like the Travis test includes dgoss. I should have mentioned too that I tested with the 3.7.0 release of the goss executable, didn't compile it from source.

@jgeorgeson
Copy link
Contributor Author

Anything additional I should here?

@nathysOne
Copy link

nathysOne commented Aug 16, 2019

I have the same issue as @jgeorgeson, but I was able to resolve it by changing the following:

nathysOne@752c612

@strowi
Copy link

strowi commented Aug 20, 2019

thx @nathysOne , ran into the same issue and removing the docker top fixed it.:)

@aelsabbahy
Copy link
Member

Looks good to me. I'll test/merge this after testing locally.

Travis test seems to be broken. Don't worry about the PR successful passing tests.

@aelsabbahy aelsabbahy merged commit 91fba64 into goss-org:master Nov 11, 2019
@aelsabbahy
Copy link
Member

aelsabbahy commented Nov 13, 2019

For what it's worth, this PR seems to have broken the dgoss health check for me. It always said container ERROR: the container failed to start.

I committed a fix directly to master. The commit with the fix is here if you're curious on the cause: a4a501a

@jgeorgeson
Copy link
Contributor Author

Hm, it appears to be the escaped quotes on the format string

[19:39:32]> justin@chymera in ~ 
$ docker inspect -f \"{{.State.Running}}\" 7cf3008d0e6fde1693d09b6a357858900c266f2f41b7aff4d59965e6c5cd3a59
"true"

[19:39:38]> justin@chymera in ~
$ docker inspect -f "{{.State.Running}}" 7cf3008d0e6fde1693d09b6a357858900c266f2f41b7aff4d59965e6c5cd3a59
true

[19:39:44]> justin@chymera in ~
$ if [ "true" != "$(docker inspect -f \"{{.State.Running}}\" 7cf3008d0e6fde1693d09b6a357858900c266f2f41b7aff4d59965e6c5cd3a59)" ]; then echo ended; else echo running; fi
ended

[19:40:46]> justin@chymera in ~
$ if [ "true" != "$(docker inspect -f "{{.State.Running}}" 7cf3008d0e6fde1693d09b6a357858900c266f2f41b7aff4d59965e6c5cd3a59)" ]; then echo ended; else echo running; fi
running

I just have it ingrained to wrap a command output in quotes for equality tests in case the command doesn't produce any output.

@jgeorgeson jgeorgeson deleted the health-check-test-output branch November 13, 2019 01:48
@aelsabbahy
Copy link
Member

I just have it ingrained to wrap a command output in quotes for equality tests in case the command doesn't produce any output.

Good point, fixed: 9dddd81

BenjaminHerbert pushed a commit to BenjaminHerbert/goss that referenced this pull request May 28, 2020
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

Successfully merging this pull request may close these issues.

4 participants