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

Add timeout parameter to command #20

Closed
aelsabbahy opened this issue Nov 4, 2015 · 3 comments
Closed

Add timeout parameter to command #20

aelsabbahy opened this issue Nov 4, 2015 · 3 comments

Comments

@aelsabbahy
Copy link
Member

command should have a timeout parameter, similar to dns and addr lookups #19

@aelsabbahy
Copy link
Member Author

Initial idea:

# default timeout is 10s
$ goss a command 'sleep 1;echo "hi"'
Adding Command to './goss.json':

{
    "sleep 1;echo \"hi\"": {
        "exit-status": "0",
        "stdout": [
            "hi"
        ],
        "stderr": [],
        "timeout": 10000
    }
}

# Happy path
$ goss validate
..

Total Duration: 1.011s
Count: 2, Failed: 0


$ sed -i 's/sleep 1/sleep 11/' goss.json

# Command took too long
$ goss validate
FF

Failures:
sleep 11;echo "hi": exit-status: Error: Command execution timed out (10000 milliseconds)
sleep 11;echo "hi": stdout: Error: Command execution timed out (10000 milliseconds)

Total Duration: 10.007s
Count: 2, Failed: 2

@stephanbuys how does that look?

One drawback with current implementation is that sleep 12 works when adding, but when you run goss validate it will fail unless you manually tweak the timeout to be more than 10000 milliseconds (default).

For now I think it's a minor inconvenience. In the future, I'll probably revamp the timeout to be dynamically set based on maybe 1.5 * command_execution_time_during_add and maybe change it to string format, so the JSON will support things like "10s". Or maybe something like goss add command --timeout 1m 'sleep 12'. But I'd like to hold off on that until I have a uniform answer for command, addr and dns for consistency.

@stephanbuys
Copy link

I like your last suggestion goss add command --timeout 1m 'sleep 12' - having a default timeout is probably going to surprise a whole lot of people.

@aelsabbahy
Copy link
Member Author

This has been added to v0.0.18

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

No branches or pull requests

2 participants