mirror of
https://github.com/containers/podman.git
synced 2025-12-12 09:50:25 +08:00
When an image has a port to expose, we need to expose it. User's input overrides the image's port information. Also, enable port information in ps so we can see which random port is assigned. Signed-off-by: baude <bbaude@redhat.com> Closes: #249 Approved by: rhatdan
60 lines
1.5 KiB
Bash
60 lines
1.5 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
load helpers
|
|
|
|
function teardown() {
|
|
cleanup_test
|
|
}
|
|
|
|
function setup() {
|
|
copy_images
|
|
}
|
|
|
|
@test "test network connection with default bridge" {
|
|
run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -dt ${ALPINE} wget www.yahoo.com
|
|
echo "$output"
|
|
[ "$status" -eq 0 ]
|
|
run ${PODMAN_BINARY} ${PODMAN_OPTIONS} wait --latest
|
|
echo "$output"
|
|
[ "$status" -eq 0 ]
|
|
}
|
|
|
|
@test "test network connection with host" {
|
|
run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -dt --network host ${ALPINE} wget www.yahoo.com
|
|
echo "$output"
|
|
[ "$status" -eq 0 ]
|
|
run ${PODMAN_BINARY} ${PODMAN_OPTIONS} wait --latest
|
|
echo "$output"
|
|
[ "$status" -eq 0 ]
|
|
}
|
|
|
|
@test "expose port 222" {
|
|
run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -dt --expose 222-223 ${ALPINE} /bin/sh
|
|
echo "$output"
|
|
[ "$status" -eq 0 ]
|
|
run bash -c "iptables -t nat -L"
|
|
echo "$output"
|
|
[ "$status" -eq 0 ]
|
|
run bash -c "iptables -t nat -L | grep 223"
|
|
echo "$output"
|
|
[ "$status" -eq 0 ]
|
|
}
|
|
|
|
@test "expose host port 80 to container port 8000" {
|
|
run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -dt -p 80:8000 ${ALPINE} /bin/sh
|
|
echo "$output"
|
|
[ "$status" -eq 0 ]
|
|
run bash -c "iptables -t nat -L | grep 8000"
|
|
echo "$output"
|
|
[ "$status" -eq 0 ]
|
|
}
|
|
|
|
@test "expose ports in image" {
|
|
run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run -dt -P docker.io/library/nginx:latest
|
|
echo "$output"
|
|
[ "$status" -eq 0 ]
|
|
run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} inspect -l | grep ': 80,'"
|
|
echo "$output"
|
|
[ "$status" -eq 0 ]
|
|
}
|