1 parent
efd71f7420
commit
e6f7efc50a
4 files changed
+93
-5
No files matched your search
@@ -264,6 +264,9 @@ t version-kiri-component "Kiri=" $D version --format '{{range .Server.Components
|
||||
for c in version cmd keepalive close follow follow-created timestamps exec endpoints copy-after-start; do
|
||||
t "testcontainers-$c" "ok $c" python3 "$(dirname "$0")/testcontainers-api.py" "$SOCK" "$c"
|
||||
done
|
||||
# buildx's bootstrap asks the same way: a chunked copy into the new BuildKit
|
||||
# container, then its start on that connection, which must get an answer (#83).
|
||||
t buildx-copy-then-start "ok buildx-bootstrap" python3 "$(dirname "$0")/testcontainers-api.py" "$SOCK" buildx-bootstrap
|
||||
# A request that asks for the close is answered, then closed: Docker.DotNet
|
||||
# reads a 204 to the end of the stream and hung until its timeout (#520, #479).
|
||||
# curl knows a 204 has no body and would not notice, so the probe sends the
|
||||
|
||||
@@ -116,3 +116,5 @@ dockerfw-internet #247 with Docker on the same Linux host its FORWARD policy dro
|
||||
dockerfw-rules #247 Kiri's rules in Docker's DOCKER-USER chain, for IPv4 and IPv6, added when Docker's firewall appears while the engine runs
|
||||
dockerfw-docker-kept-apart #247 letting Kiri's containers through Docker's firewall must not let them into a container on Docker's own bridge
|
||||
import-dir-mtime #676 every directory of an image layer had the time Kiri unpacked it, not the layer's
|
||||
buildx-copy-then-start #83 buildx's bootstrap failed with "connection reset by peer": the engine answered the copy into the new BuildKit container, then closed the connection without saying so, and the start sent next on it was lost
|
||||
buildx-bootstrap-loop #83 about one buildx docker-container bootstrap in six failed at the BuildKit container's start with "connection reset by peer", leaving it created
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 52.
|
@@ -28,6 +28,10 @@
|
||||
# without having looked.
|
||||
# churn-beside-df create, start, exec, rm and volume churn beside system
|
||||
# df loops: no command over its limit, none failed
|
||||
# buildx-bootstrap-loop
|
||||
# buildx docker-container builders made, bootstrapped
|
||||
# and removed: every first bootstrap starts its BuildKit
|
||||
# container (#83; skipped without buildx)
|
||||
#
|
||||
# The engine is found as tests/e2e.sh finds it (DOCKER_CONTEXT, default
|
||||
# kiri); images come from KIRI_TEST_REGISTRY (tests/lib/images.sh). It only
|
||||
@@ -372,6 +376,41 @@ if selected churn-beside-df; then
|
||||
"$cmds commands, $over over their limit, $errs failed${which:+ ($which)}; ${per}$dfm"
|
||||
fi
|
||||
|
||||
# (e) buildx's docker-container builder made, bootstrapped and removed, round
|
||||
# after round, each with a fresh name: every first bootstrap must start its
|
||||
# BuildKit container, with no retry. Kiri 0.1.18 closed the connection after
|
||||
# the copy into the container without saying so, and the start sent next on
|
||||
# it failed with "connection reset by peer" in about one round in six (#83).
|
||||
if selected buildx-bootstrap-loop; then
|
||||
N=$((20 * ROUNDS)) LIM=120
|
||||
case_start buildx-bootstrap-loop "$N buildx create, bootstrap, rm rounds; $LIM s a bootstrap"
|
||||
if ! docker buildx version >/dev/null 2>&1; then
|
||||
SKIP=$((SKIP + 1)); echo " skip: buildx not installed"
|
||||
else
|
||||
BK=$(kiri_image_remote moby/buildkit:buildx-stable-1)
|
||||
: > "$WORK/e.log"; e_bad=0
|
||||
for i in $(seq "$N"); do
|
||||
b=$P-bx-$i
|
||||
TM_OUT=$WORK/e.out tm 30 docker buildx create --name "$b" --driver docker-container --driver-opt default-load=true --driver-opt "image=$BK" "$DOCKER_CONTEXT" >/dev/null
|
||||
: > "$WORK/e.out"
|
||||
read -r rc ms to <<<"$(TM_OUT=$WORK/e.out tm $LIM docker buildx inspect "$b" --bootstrap)"
|
||||
st=$(lim 20 "$D" container inspect "buildx_buildkit_${b}0" --format '{{.State.Status}}' 2>&1)
|
||||
echo "$rc $ms $to $st" >> "$WORK/e.log"
|
||||
if [ "$rc" != 0 ] || [ "$st" != running ]; then
|
||||
e_bad=$((e_bad + 1))
|
||||
[ "$e_bad" -le 3 ] && echo " round $i: exit $rc, container $st: $(grep -i error "$WORK/e.out" | tail -1 | sed "s/$b/NAME/g")"
|
||||
fi
|
||||
tm 60 docker buildx rm -f "$b" >/dev/null
|
||||
lim 20 "$D" rm -f "buildx_buildkit_${b}0" >/dev/null 2>&1
|
||||
# A wedged engine: three bootstraps over their limit say enough.
|
||||
[ "$(awk '$3 == 1' "$WORK/e.log" | wc -l)" -ge 3 ] && { echo " stopped after 3 bootstraps over $LIM s"; break; }
|
||||
done
|
||||
ran=$(wc -l < "$WORK/e.log" | tr -d ' ')
|
||||
check buildx-bootstrap-loop "$([ "$ran" = "$N" ] && [ "$e_bad" = 0 ] && echo 1)" \
|
||||
"$ran bootstraps, $e_bad failed or left the container not running; bootstrap $(stats "$WORK/e.log" 2)"
|
||||
fi
|
||||
fi
|
||||
|
||||
printf '\n%d passed, %d failed, %d skipped in %d s\n' "$PASS" "$FAIL" "$SKIP" $((SECONDS - T_START))
|
||||
for f in "${FAILED[@]+"${FAILED[@]}"}"; do echo " failed: $f"; done
|
||||
[ "$FAIL" -eq 0 ]
|
||||
@@ -2,7 +2,10 @@
|
||||
"""What Testcontainers (docker-java, .NET, Go) needs of the engine API, asked
|
||||
the way those clients ask: raw HTTP/1.1 on one kept-alive connection.
|
||||
|
||||
tests/testcontainers-api.py SOCKET [version|cmd|keepalive|close|follow|follow-created|timestamps|exec|endpoints|copy-after-start ...]
|
||||
tests/testcontainers-api.py SOCKET [version|cmd|keepalive|close|follow|follow-created|timestamps|exec|endpoints|copy-after-start|buildx-bootstrap ...]
|
||||
|
||||
buildx-bootstrap is not Testcontainers' but buildx's docker-container driver,
|
||||
which asks the same way (Go's client, one pooled connection).
|
||||
|
||||
Prints one line per check, "ok <name>" or "FAIL <name>: why", and exits 1 if
|
||||
any failed. The containers it makes (tc-api-*) are left running.
|
||||
@@ -47,11 +50,15 @@ class Conn:
|
||||
out, self.buf = self.buf[:n], self.buf[n:]
|
||||
return out
|
||||
|
||||
def send(self, method, path, body=None, ctype="application/json", extra=""):
|
||||
def send(self, method, path, body=None, ctype="application/json", extra="", chunked=False):
|
||||
if isinstance(body, (dict, list)):
|
||||
body = json.dumps(body).encode()
|
||||
head = f"{method} /v1.32{path} HTTP/1.1\r\nHost: localhost:2375\r\nAccept: application/json\r\n{extra}"
|
||||
if body is not None:
|
||||
if body is not None and chunked:
|
||||
# As Go's client sends a body of unknown length (an archive).
|
||||
head += f"Content-Type: {ctype}\r\nTransfer-Encoding: chunked\r\n"
|
||||
body = (b"%x\r\n%s\r\n" % (len(body), body) if body else b"") + b"0\r\n\r\n"
|
||||
elif body is not None:
|
||||
head += f"Content-Type: {ctype}\r\nContent-Length: {len(body)}\r\n"
|
||||
self.s.sendall(head.encode() + b"\r\n" + (body or b""))
|
||||
|
||||
@@ -76,8 +83,8 @@ class Conn:
|
||||
self.take(2)
|
||||
yield data
|
||||
|
||||
def request(self, method, path, body=None, ctype="application/json"):
|
||||
self.send(method, path, body, ctype)
|
||||
def request(self, method, path, body=None, ctype="application/json", chunked=False):
|
||||
self.send(method, path, body, ctype, chunked=chunked)
|
||||
status, headers = self.head()
|
||||
if headers.get("transfer-encoding") == "chunked":
|
||||
data = b"".join(self.chunks())
|
||||
@@ -404,10 +411,47 @@ def check_copy_after_start():
|
||||
return "a file uploaded straight after /start is there, 3 of 3"
|
||||
|
||||
|
||||
def check_buildx_bootstrap(rounds=20):
|
||||
# buildx's docker-container driver makes its BuildKit container, copies
|
||||
# /etc/buildkit into it (a chunked PUT /archive) and starts it at once,
|
||||
# on the same pooled connection. Kiri 0.1.18 answered the copy and then
|
||||
# closed the connection without saying so: the start went into a closing
|
||||
# socket and buildx failed with "connection reset by peer", in about one
|
||||
# bootstrap in six (#83). Asked raw, the lost start shows every time.
|
||||
buf = io.BytesIO()
|
||||
with tarfile.open(fileobj=buf, mode="w") as tar:
|
||||
d = tarfile.TarInfo("buildkit")
|
||||
d.type, d.mode = tarfile.DIRTYPE, 0o755
|
||||
tar.addfile(d)
|
||||
conf = b"# buildkitd.toml\n"
|
||||
f = tarfile.TarInfo("buildkit/buildkitd.toml")
|
||||
f.size = len(conf)
|
||||
tar.addfile(f, io.BytesIO(conf))
|
||||
lost = []
|
||||
for run in range(rounds):
|
||||
c = Conn()
|
||||
name = f"tc-api-buildx-{run}"
|
||||
fresh(c, name, ["sleep", "600"])
|
||||
status, headers, data = c.request("PUT", f"/containers/{name}/archive?noOverwriteDirNonDir=true&path=%2Fetc", buf.getvalue(), "application/x-tar", chunked=True)
|
||||
assert status == 200, f"archive {status} {data[:200]!r}"
|
||||
closing = headers.get("connection", "").lower() == "close"
|
||||
try:
|
||||
status, _, data = c.request("POST", f"/containers/{name}/start")
|
||||
assert status == 204, f"start {status} {data[:200]!r}"
|
||||
except (EOFError, BrokenPipeError, ConnectionResetError) as e:
|
||||
lost.append(f"{run + 1}: {type(e).__name__}" + ("" if closing else ", no Connection: close sent"))
|
||||
c.s.close()
|
||||
if run < rounds - 1:
|
||||
Conn().request("DELETE", f"/containers/{name}?force=1")
|
||||
assert not lost, f"the start after the copy lost its connection in {len(lost)} of {rounds} rounds ({'; '.join(lost[:3])})"
|
||||
return f"copy then start on one connection, {rounds} of {rounds}"
|
||||
|
||||
|
||||
CHECKS = {
|
||||
"version": check_version, "cmd": check_cmd, "keepalive": check_keepalive, "close": check_close,
|
||||
"follow": check_follow, "follow-created": check_follow_created, "timestamps": check_timestamps,
|
||||
"exec": check_exec, "endpoints": check_endpoints, "copy-after-start": check_copy_after_start,
|
||||
"buildx-bootstrap": check_buildx_bootstrap,
|
||||
}
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in new issue
Block a user