Merge pull request #3609 from jayjun/init
Start long running containers with --init with tests
This commit is contained in:
@@ -98,16 +98,16 @@ scheduler-docker-local-scheduler-deploy() {
|
|||||||
START_CMD=$(fn-scheduler-docker-local-extract-start-cmd "$APP" "$PROC_TYPE" "$START_CMD" "$DOKKU_HEROKUISH" "$DOKKU_PORT")
|
START_CMD=$(fn-scheduler-docker-local-extract-start-cmd "$APP" "$PROC_TYPE" "$START_CMD" "$DOKKU_HEROKUISH" "$DOKKU_PORT")
|
||||||
if [[ "$DOKKU_NETWORK_BIND_ALL" == "false" ]]; then
|
if [[ "$DOKKU_NETWORK_BIND_ALL" == "false" ]]; then
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
cid=$("$DOCKER_BIN" container run --label=com.dokku.container-type=deploy "${DOCKER_RUN_LABEL_ARGS[@]}" $DOKKU_GLOBAL_RUN_ARGS --detach --env PORT=$DOKKU_PORT "${ARG_ARRAY[@]}" $IMAGE $START_CMD)
|
cid=$("$DOCKER_BIN" container run --label=com.dokku.container-type=deploy "${DOCKER_RUN_LABEL_ARGS[@]}" $DOKKU_GLOBAL_RUN_ARGS --init --detach --env PORT=$DOKKU_PORT "${ARG_ARRAY[@]}" $IMAGE $START_CMD)
|
||||||
else
|
else
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
cid=$("$DOCKER_BIN" container run --label=com.dokku.container-type=deploy "${DOCKER_RUN_LABEL_ARGS[@]}" $DOKKU_GLOBAL_RUN_ARGS --detach $DOKKU_DOCKER_PORT_ARGS --env PORT=$DOKKU_PORT "${ARG_ARRAY[@]}" $IMAGE $START_CMD)
|
cid=$("$DOCKER_BIN" container run --label=com.dokku.container-type=deploy "${DOCKER_RUN_LABEL_ARGS[@]}" $DOKKU_GLOBAL_RUN_ARGS --init --detach $DOKKU_DOCKER_PORT_ARGS --env PORT=$DOKKU_PORT "${ARG_ARRAY[@]}" $IMAGE $START_CMD)
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
START_CMD=$(fn-scheduler-docker-local-extract-start-cmd "$APP" "$PROC_TYPE" "$START_CMD" "$DOKKU_HEROKUISH")
|
START_CMD=$(fn-scheduler-docker-local-extract-start-cmd "$APP" "$PROC_TYPE" "$START_CMD" "$DOKKU_HEROKUISH")
|
||||||
|
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
cid=$("$DOCKER_BIN" container run --label=com.dokku.container-type=deploy "${DOCKER_RUN_LABEL_ARGS[@]}" $DOKKU_GLOBAL_RUN_ARGS --detach "${ARG_ARRAY[@]}" $IMAGE $START_CMD)
|
cid=$("$DOCKER_BIN" container run --label=com.dokku.container-type=deploy "${DOCKER_RUN_LABEL_ARGS[@]}" $DOKKU_GLOBAL_RUN_ARGS --init --detach "${ARG_ARRAY[@]}" $IMAGE $START_CMD)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ipaddr=$(plugn trigger network-get-ipaddr "$APP" "$PROC_TYPE" "$cid")
|
ipaddr=$(plugn trigger network-get-ipaddr "$APP" "$PROC_TYPE" "$cid")
|
||||||
|
|||||||
1
tests/apps/zombies-buildpack/CHECKS
Normal file
1
tests/apps/zombies-buildpack/CHECKS
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/ go
|
||||||
1
tests/apps/zombies-buildpack/Procfile
Normal file
1
tests/apps/zombies-buildpack/Procfile
Normal file
@@ -0,0 +1 @@
|
|||||||
|
web: bin/web
|
||||||
4
tests/apps/zombies-buildpack/go.mod
Normal file
4
tests/apps/zombies-buildpack/go.mod
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
module dokku.me/web
|
||||||
|
|
||||||
|
// +heroku goVersion go1.12
|
||||||
|
go 1.12
|
||||||
27
tests/apps/zombies-buildpack/web.go
Normal file
27
tests/apps/zombies-buildpack/web.go
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// spawn an orphaned zombie
|
||||||
|
err := exec.Command("/bin/bash", "-c", "/bin/false &").Run()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
http.HandleFunc("/", hello)
|
||||||
|
fmt.Println("listening...")
|
||||||
|
err = http.ListenAndServe(":"+os.Getenv("PORT"), nil)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func hello(res http.ResponseWriter, req *http.Request) {
|
||||||
|
fmt.Fprintln(res, "go")
|
||||||
|
}
|
||||||
1
tests/apps/zombies-dockerfile-no-tini/CHECKS
Normal file
1
tests/apps/zombies-dockerfile-no-tini/CHECKS
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/ go
|
||||||
6
tests/apps/zombies-dockerfile-no-tini/Dockerfile
Normal file
6
tests/apps/zombies-dockerfile-no-tini/Dockerfile
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
FROM golang:1.12
|
||||||
|
|
||||||
|
ADD . /go/src/github.com/dokku/apps/web
|
||||||
|
WORKDIR /go/src/github.com/dokku/apps/web
|
||||||
|
|
||||||
|
RUN go install -v ./...
|
||||||
1
tests/apps/zombies-dockerfile-no-tini/Procfile
Normal file
1
tests/apps/zombies-dockerfile-no-tini/Procfile
Normal file
@@ -0,0 +1 @@
|
|||||||
|
web: /go/bin/web
|
||||||
3
tests/apps/zombies-dockerfile-no-tini/go.mod
Normal file
3
tests/apps/zombies-dockerfile-no-tini/go.mod
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module dokku.me/web
|
||||||
|
|
||||||
|
go 1.12
|
||||||
27
tests/apps/zombies-dockerfile-no-tini/web.go
Normal file
27
tests/apps/zombies-dockerfile-no-tini/web.go
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// spawn an orphaned zombie
|
||||||
|
err := exec.Command("/bin/bash", "-c", "/bin/false &").Run()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
http.HandleFunc("/", hello)
|
||||||
|
fmt.Println("listening...")
|
||||||
|
err = http.ListenAndServe(":"+os.Getenv("PORT"), nil)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func hello(res http.ResponseWriter, req *http.Request) {
|
||||||
|
fmt.Fprintln(res, "go")
|
||||||
|
}
|
||||||
1
tests/apps/zombies-dockerfile-tini/CHECKS
Normal file
1
tests/apps/zombies-dockerfile-tini/CHECKS
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/ go
|
||||||
11
tests/apps/zombies-dockerfile-tini/Dockerfile
Normal file
11
tests/apps/zombies-dockerfile-tini/Dockerfile
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
FROM golang:1.12
|
||||||
|
|
||||||
|
ADD . /go/src/github.com/dokku/apps/web
|
||||||
|
WORKDIR /go/src/github.com/dokku/apps/web
|
||||||
|
|
||||||
|
RUN go install -v ./...
|
||||||
|
|
||||||
|
ENV TINI_VERSION v0.18.0
|
||||||
|
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
|
||||||
|
RUN chmod +x /tini
|
||||||
|
ENTRYPOINT ["/tini", "--"]
|
||||||
1
tests/apps/zombies-dockerfile-tini/Procfile
Normal file
1
tests/apps/zombies-dockerfile-tini/Procfile
Normal file
@@ -0,0 +1 @@
|
|||||||
|
web: /go/bin/web
|
||||||
3
tests/apps/zombies-dockerfile-tini/go.mod
Normal file
3
tests/apps/zombies-dockerfile-tini/go.mod
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module dokku.me/web
|
||||||
|
|
||||||
|
go 1.12
|
||||||
27
tests/apps/zombies-dockerfile-tini/web.go
Normal file
27
tests/apps/zombies-dockerfile-tini/web.go
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// spawn an orphaned zombie
|
||||||
|
err := exec.Command("/bin/bash", "-c", "/bin/false &").Run()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
http.HandleFunc("/", hello)
|
||||||
|
fmt.Println("listening...")
|
||||||
|
err = http.ListenAndServe(":"+os.Getenv("PORT"), nil)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func hello(res http.ResponseWriter, req *http.Request) {
|
||||||
|
fmt.Fprintln(res, "go")
|
||||||
|
}
|
||||||
20
tests/unit/50_init_1.bats
Normal file
20
tests/unit/50_init_1.bats
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
global_setup
|
||||||
|
create_app
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
destroy_app
|
||||||
|
global_teardown
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(init) buildpack" {
|
||||||
|
deploy_app zombies-buildpack
|
||||||
|
run ps ax
|
||||||
|
echo "output: $output"
|
||||||
|
assert_output_contains "<defunct>" "0"
|
||||||
|
}
|
||||||
20
tests/unit/50_init_2.bats
Normal file
20
tests/unit/50_init_2.bats
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
global_setup
|
||||||
|
create_app
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
destroy_app
|
||||||
|
global_teardown
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(init) dockerfile no tini" {
|
||||||
|
deploy_app zombies-dockerfile-no-tini
|
||||||
|
run ps auxf
|
||||||
|
echo "output: $output"
|
||||||
|
assert_output_contains "<defunct>" "0"
|
||||||
|
}
|
||||||
20
tests/unit/50_init_3.bats
Normal file
20
tests/unit/50_init_3.bats
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
global_setup
|
||||||
|
create_app
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
destroy_app
|
||||||
|
global_teardown
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "(init) dockerfile with tini" {
|
||||||
|
deploy_app zombies-dockerfile-tini
|
||||||
|
run ps ax
|
||||||
|
echo "output: $output"
|
||||||
|
assert_output_contains "<defunct>" "0"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user