Implement http.#Wait to wait for a URL to be ready. It creates a dependency in the Cue tree
Signed-off-by: guillaume <guillaume.derouville@gmail.com>
This commit is contained in:
@@ -2,13 +2,47 @@ package http
|
||||
|
||||
import (
|
||||
"alpha.dagger.io/alpine"
|
||||
"alpha.dagger.io/dagger"
|
||||
"alpha.dagger.io/docker"
|
||||
"alpha.dagger.io/os"
|
||||
"alpha.dagger.io/random"
|
||||
)
|
||||
|
||||
|
||||
TestDockersocket: dagger.#Stream & dagger.#Input
|
||||
|
||||
TestSuffix: random.#String & {
|
||||
seed: ""
|
||||
}
|
||||
|
||||
TestRun: docker.#Run & {
|
||||
name: "daggerci-test-wait-\(TestSuffix.out)"
|
||||
ref: "nginx"
|
||||
socket: TestDockersocket
|
||||
ports: ["8080:80"]
|
||||
}
|
||||
|
||||
// Waits for TestRun to finish initializing
|
||||
Testhealth: #Wait & {
|
||||
url: "http://localhost:8080/"
|
||||
}
|
||||
|
||||
TestWait: {
|
||||
query: os.#Container & {
|
||||
image: alpine.#Image & {
|
||||
package: bash: "=~5.1"
|
||||
package: curl: true
|
||||
}
|
||||
command: #"""
|
||||
test "$(curl -L --fail --silent --show-error --write-out "%{http_code}" "$URL" -o /dev/null)" = "200"
|
||||
"""#
|
||||
env: URL: Testhealth.url
|
||||
}
|
||||
}
|
||||
|
||||
TestRequest: {
|
||||
req: #Get & {
|
||||
url: "https://api.github.com/"
|
||||
request: header: Accept: "application/json"
|
||||
url: Testhealth.url
|
||||
}
|
||||
|
||||
testRaw: os.#Container & {
|
||||
@@ -24,9 +58,8 @@ TestRequest: {
|
||||
shell: args: ["--noprofile", "--norc", "-eo", "pipefail", "-c"]
|
||||
command: #Command
|
||||
}
|
||||
}
|
||||
|
||||
#Command: #"""
|
||||
test "$(cat /content.json | jq -r .current_user_url)" = 'https://api.github.com/user'
|
||||
#Command: #"""
|
||||
cat /content.json | grep -q nginx >/dev/null
|
||||
test "$STATUS" = "200"
|
||||
"""#
|
||||
}
|
Reference in New Issue
Block a user