commit
ba232900fc
13 changed files with 64 additions and 9 deletions
4
Makefile
4
Makefile
|
@ -1,4 +1,4 @@
|
|||
EPOCH_TEST_COMMIT ?= 7fc874e05e74faa81e7c423b6514fc5c474c6b34
|
||||
EPOCH_TEST_COMMIT ?= 78aae
|
||||
PROJECT := github.com/kubernetes-incubator/cri-o
|
||||
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
|
||||
GIT_BRANCH_CLEAN := $(shell echo $(GIT_BRANCH) | sed -e "s/[^[:alnum:]]/-/g")
|
||||
|
@ -52,7 +52,7 @@ dbuild: ocidimage
|
|||
docker rm ${OCID_INSTANCE}
|
||||
|
||||
integration: ocidimage
|
||||
docker run -e TESTFLAGS -t --privileged --rm -v ${CURDIR}:/go/src/${PROJECT} ${OCID_IMAGE} make localintegration
|
||||
docker run -e TESTFLAGS -e TRAVIS -t --privileged --rm -v ${CURDIR}:/go/src/${PROJECT} ${OCID_IMAGE} make localintegration
|
||||
|
||||
localintegration: binaries
|
||||
./test/test_runner.sh ${TESTFLAGS}
|
||||
|
|
|
@ -74,7 +74,7 @@ var stopPodSandboxCommand = cli.Command{
|
|||
|
||||
err = StopPodSandbox(client, context.String("id"))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Stopping the pod sandbox failed: %v", err)
|
||||
return fmt.Errorf("stopping the pod sandbox failed: %v", err)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
|
|
@ -313,6 +313,7 @@ func (s *Server) RemovePodSandbox(ctx context.Context, req *pb.RemovePodSandboxR
|
|||
}
|
||||
|
||||
s.releasePodName(sb.name)
|
||||
s.removeSandbox(sandboxID)
|
||||
|
||||
return &pb.RemovePodSandboxResponse{}, nil
|
||||
}
|
||||
|
@ -380,6 +381,11 @@ func (s *Server) ListPodSandbox(context.Context, *pb.ListPodSandboxRequest) (*pb
|
|||
for _, sb := range s.state.sandboxes {
|
||||
podInfraContainerName := sb.name + "-infra"
|
||||
podInfraContainer := sb.getContainer(podInfraContainerName)
|
||||
if podInfraContainer == nil {
|
||||
// this can't really happen, but if it does because of a bug
|
||||
// it's better not to panic
|
||||
continue
|
||||
}
|
||||
if err := s.runtime.UpdateStatus(podInfraContainer); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -179,6 +179,12 @@ func (s *Server) hasSandbox(id string) bool {
|
|||
return ok
|
||||
}
|
||||
|
||||
func (s *Server) removeSandbox(id string) {
|
||||
s.stateLock.Lock()
|
||||
delete(s.state.sandboxes, id)
|
||||
s.stateLock.Unlock()
|
||||
}
|
||||
|
||||
func (s *Server) addContainer(c *oci.Container) {
|
||||
s.stateLock.Lock()
|
||||
sandbox := s.state.sandboxes[c.Sandbox()]
|
||||
|
|
|
@ -59,7 +59,6 @@ function setup() {
|
|||
|
||||
# teardown is called at the end of every test.
|
||||
function teardown() {
|
||||
stop_ocid
|
||||
cleanup_test
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
INTEGRATION_ROOT=$(dirname "$(readlink -f "$BASH_SOURCE")")
|
||||
|
||||
# Test data path.
|
||||
TESTDATA="${INTEGRATION_ROOT}/../testdata"
|
||||
TESTDATA="${INTEGRATION_ROOT}/testdata"
|
||||
|
||||
# Root directory of the repository.
|
||||
OCID_ROOT=${OCID_ROOT:-$(cd "$INTEGRATION_ROOT/../.."; pwd -P)}
|
||||
|
@ -70,16 +70,30 @@ function wait_until_reachable() {
|
|||
|
||||
# Start ocid.
|
||||
function start_ocid() {
|
||||
"$OCID_BINARY" --debug --socket "$TESTDIR/ocid.sock" --runtime "$RUNC_BINARY" --root "$TESTDIR/ocid" & OCID_PID=$!
|
||||
"$OCID_BINARY" --debug --socket "$TESTDIR/ocid.sock" --runtime "$RUNC_BINARY" --root "$TESTDIR/ocid" --sandboxdir "$TESTDIR/sandboxes" --containerdir "$TESTDIR/ocid/containers" & OCID_PID=$!
|
||||
wait_until_reachable
|
||||
}
|
||||
|
||||
function cleanup_pods() {
|
||||
run ocic pod list
|
||||
if [ "$status" -eq 0 ]; then
|
||||
printf '%s\n' "$output" | while IFS= read -r line
|
||||
do
|
||||
pod=$(echo "$line" | sed -e 's/ID: //g')
|
||||
ocic pod stop --id "$pod"
|
||||
sleep 1
|
||||
ocic pod remove --id "$pod"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
# Stop ocid.
|
||||
function stop_ocid() {
|
||||
kill "$OCID_PID"
|
||||
if [ "$OCID_PID" != "" ]; then
|
||||
kill "$OCID_PID" >/dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
function cleanup_test() {
|
||||
rm -rf "$TESTDIR"
|
||||
# TODO(runcom): runc list and kill/delete everything!
|
||||
}
|
||||
|
|
30
test/pod.bats
Normal file
30
test/pod.bats
Normal file
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env bats
|
||||
|
||||
load helpers
|
||||
|
||||
function teardown() {
|
||||
cleanup_test
|
||||
}
|
||||
|
||||
# PR#59
|
||||
@test "pod release name on remove" {
|
||||
# this test requires docker, thus it can't yet be run in a container
|
||||
if [ "$TRAVIS" = "true" ]; then # instead of $TRAVIS, add a function is_containerized to skip here
|
||||
skip "cannot yet run this test in a container, use sudo make localintegration"
|
||||
fi
|
||||
|
||||
start_ocid
|
||||
run ocic pod create --config "$TESTDATA"/sandbox_config.json
|
||||
[ "$status" -eq 0 ]
|
||||
echo "$output"
|
||||
id="$output"
|
||||
run ocic pod stop --id "$id"
|
||||
[ "$status" -eq 0 ]
|
||||
sleep 1 # FIXME: there's a race between container kill and delete below
|
||||
run ocic pod remove --id "$id"
|
||||
[ "$status" -eq 0 ]
|
||||
run ocic pod create --config "$TESTDATA"/sandbox_config.json
|
||||
[ "$status" -eq 0 ]
|
||||
stop_ocid
|
||||
cleanup_pods
|
||||
}
|
|
@ -3,7 +3,6 @@
|
|||
load helpers
|
||||
|
||||
function teardown() {
|
||||
stop_ocid
|
||||
cleanup_test
|
||||
}
|
||||
|
||||
|
@ -11,4 +10,5 @@ function teardown() {
|
|||
start_ocid
|
||||
ocic runtimeversion
|
||||
[ "$status" -eq 0 ]
|
||||
stop_ocid
|
||||
}
|
||||
|
|
0
testdata/README.md → test/testdata/README.md
vendored
0
testdata/README.md → test/testdata/README.md
vendored
Loading…
Reference in a new issue