Merge pull request #234 from runcom/fixies

fix filter by truncated ids (+ apparmor tests)
This commit is contained in:
Mrunal Patel 2016-12-06 09:35:18 -08:00 committed by GitHub
commit c4fc22af51
6 changed files with 29 additions and 14 deletions

View file

@ -36,7 +36,11 @@ func (s *Server) ListContainers(ctx context.Context, req *pb.ListContainersReque
// Filter using container id and pod id first.
if filter != nil {
if filter.Id != nil {
c := s.state.containers.Get(*filter.Id)
id, err := s.ctrIDIndex.Get(*filter.Id)
if err != nil {
return nil, err
}
c := s.state.containers.Get(id)
if c != nil {
if filter.PodSandboxId != nil {
if c.Sandbox() == *filter.PodSandboxId {

View file

@ -39,7 +39,11 @@ func (s *Server) ListPodSandbox(ctx context.Context, req *pb.ListPodSandboxReque
// Filter by pod id first.
if filter != nil {
if filter.Id != nil {
sb := s.getSandbox(*filter.Id)
id, err := s.podIDIndex.Get(*filter.Id)
if err != nil {
return nil, err
}
sb := s.getSandbox(id)
if sb == nil {
podList = []*sandbox{}
} else {

View file

@ -16,7 +16,7 @@ function teardown() {
# this test requires apparmor, so skip this test if apparmor is not enabled.
enabled=is_apparmor_enabled
if [[ "$enabled" =~ "0" ]]; then
if [[ "$enabled" = "0" ]]; then
skip "skip this test since apparmor is not enabled."
fi
@ -53,7 +53,7 @@ function teardown() {
# this test requires apparmor, so skip this test if apparmor is not enabled.
enabled=is_apparmor_enabled
if [[ "$enabled" =~ "0" ]]; then
if [[ "$enabled" -eq "0" ]]; then
skip "skip this test since apparmor is not enabled."
fi
@ -92,7 +92,7 @@ function teardown() {
# this test requires apparmor, so skip this test if apparmor is not enabled.
enabled=is_apparmor_enabled
if [[ "$enabled" =~ "0" ]]; then
if [[ "$enabled" -eq "0" ]]; then
skip "skip this test since apparmor is not enabled."
fi
@ -131,7 +131,7 @@ function teardown() {
# this test requires apparmor, so skip this test if apparmor is not enabled.
enabled=is_apparmor_enabled
if [[ "$enabled" =~ "0" ]]; then
if [[ "$enabled" -eq "0" ]]; then
skip "skip this test since apparmor is not enabled."
fi

View file

@ -187,6 +187,11 @@ function teardown() {
[ "$status" -eq 0 ]
[[ "$output" != "" ]]
[[ "$output" =~ "$ctr1_id" ]]
run ocic ctr list --id "${ctr1_id:0:4}" --quiet
echo "$output"
[ "$status" -eq 0 ]
[[ "$output" != "" ]]
[[ "$output" =~ "$ctr1_id" ]]
run ocic ctr list --id "$ctr2_id" --pod "$pod2_id" --quiet
echo "$output"
[ "$status" -eq 0 ]

View file

@ -161,12 +161,10 @@ function is_seccomp_enabled() {
out=$(cat "$BOOT_CONFIG_FILE_PATH" | grep CONFIG_SECCOMP=)
if [[ "$out" =~ "CONFIG_SECCOMP=y" ]]; then
echo 1
else
echo 0
return
fi
else
echo 0
fi
echo 0
}
function is_apparmor_enabled() {
@ -174,10 +172,8 @@ function is_apparmor_enabled() {
out=$(cat "$APPARMOR_PARAMETERS_FILE_PATH")
if [[ "$out" =~ "Y" ]]; then
echo 1
else
echo 0
return
fi
else
echo 0
fi
echo 0
}

View file

@ -112,6 +112,12 @@ function teardown() {
[ "$status" -eq 0 ]
[[ "$output" != "" ]]
[[ "$output" =~ "$pod1_id" ]]
# filter by truncated id should work as well
run ocic pod list --id "${pod1_id:0:4}"
echo "$output"
[ "$status" -eq 0 ]
[[ "$output" != "" ]]
[[ "$output" =~ "$pod1_id" ]]
run ocic pod list --id "$pod2_id"
echo "$output"
[ "$status" -eq 0 ]