Skip to content

How we can test daemons? #78

Open
Open
@dzavalkinolx

Description

@dzavalkinolx

I have a very simple container with nginx which serves static content. I want to verify that nginx starts with proper virtual host configuration and returns index.html with all headers properly set. Since this PR is merged
With #43 merged entrypoint is empty and my nginx is not started. I was trying to start nginx as a daemon or as a detached process but I can't see how to do it. Seems like all processes started in setup stage are killed?

With this code I see that no nginx is running

- name: "nginx is running and returns index.html page"
  setup: [["apk", "--no-cache", "add", "curl"], ["nginx"]]
  command: "ps"
  args: ["aux"]
  expectedOutput: ["nginx"]

Test result:

    --- FAIL: TestAll/Command_Test:_nginx_is_running_and_returns_index.html_page (3.90s)
        docker_driver.go:85: stdout: PID   USER     TIME   COMMAND
                    1 root       0:00 ps aux
        utils.go:33: Expected string 'nginx' not found in output!

I also tried to run nginx not as daemon but detached ["nginx", "-g", "daemon off", "&"] - test result is the same. If I run nginx in foreground with ["nginx", "-g", "daemon off", "&"] then setup commands is hanging. I think you should fix logic of the setup command to allow it spawn daemons, detached processes or maybe don't wait for it to finish before running main command (for foreground commands).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions