tests: check orphaned processes are reaped

This commit is contained in:
Tan Jay Jun
2019-09-07 16:47:31 +08:00
committed by Jose Diaz-Gonzalez
parent 10d2fdea92
commit 26e3232f2c
17 changed files with 174 additions and 0 deletions

View File

@@ -0,0 +1 @@
/ go

View File

@@ -0,0 +1 @@
web: bin/web

View File

@@ -0,0 +1,4 @@
module dokku.me/web
// +heroku goVersion go1.12
go 1.12

View 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")
}

View File

@@ -0,0 +1 @@
/ go

View 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 ./...

View File

@@ -0,0 +1 @@
web: /go/bin/web

View File

@@ -0,0 +1,3 @@
module dokku.me/web
go 1.12

View 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")
}

View File

@@ -0,0 +1 @@
/ go

View 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", "--"]

View File

@@ -0,0 +1 @@
web: /go/bin/web

View File

@@ -0,0 +1,3 @@
module dokku.me/web
go 1.12

View 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
View 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
View 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 ax
echo "output: $output"
assert_output_contains "<defunct>" "0"
}

20
tests/unit/50_init_3.bats Normal file
View 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"
}