Merge pull request #234 from runcom/fixies
fix filter by truncated ids (+ apparmor tests)
This commit is contained in:
commit
c4fc22af51
6 changed files with 29 additions and 14 deletions
|
@ -36,7 +36,11 @@ func (s *Server) ListContainers(ctx context.Context, req *pb.ListContainersReque
|
||||||
// Filter using container id and pod id first.
|
// Filter using container id and pod id first.
|
||||||
if filter != nil {
|
if filter != nil {
|
||||||
if filter.Id != 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 c != nil {
|
||||||
if filter.PodSandboxId != nil {
|
if filter.PodSandboxId != nil {
|
||||||
if c.Sandbox() == *filter.PodSandboxId {
|
if c.Sandbox() == *filter.PodSandboxId {
|
||||||
|
|
|
@ -39,7 +39,11 @@ func (s *Server) ListPodSandbox(ctx context.Context, req *pb.ListPodSandboxReque
|
||||||
// Filter by pod id first.
|
// Filter by pod id first.
|
||||||
if filter != nil {
|
if filter != nil {
|
||||||
if filter.Id != 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 {
|
if sb == nil {
|
||||||
podList = []*sandbox{}
|
podList = []*sandbox{}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -16,7 +16,7 @@ function teardown() {
|
||||||
|
|
||||||
# this test requires apparmor, so skip this test if apparmor is not enabled.
|
# this test requires apparmor, so skip this test if apparmor is not enabled.
|
||||||
enabled=is_apparmor_enabled
|
enabled=is_apparmor_enabled
|
||||||
if [[ "$enabled" =~ "0" ]]; then
|
if [[ "$enabled" = "0" ]]; then
|
||||||
skip "skip this test since apparmor is not enabled."
|
skip "skip this test since apparmor is not enabled."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ function teardown() {
|
||||||
|
|
||||||
# this test requires apparmor, so skip this test if apparmor is not enabled.
|
# this test requires apparmor, so skip this test if apparmor is not enabled.
|
||||||
enabled=is_apparmor_enabled
|
enabled=is_apparmor_enabled
|
||||||
if [[ "$enabled" =~ "0" ]]; then
|
if [[ "$enabled" -eq "0" ]]; then
|
||||||
skip "skip this test since apparmor is not enabled."
|
skip "skip this test since apparmor is not enabled."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ function teardown() {
|
||||||
|
|
||||||
# this test requires apparmor, so skip this test if apparmor is not enabled.
|
# this test requires apparmor, so skip this test if apparmor is not enabled.
|
||||||
enabled=is_apparmor_enabled
|
enabled=is_apparmor_enabled
|
||||||
if [[ "$enabled" =~ "0" ]]; then
|
if [[ "$enabled" -eq "0" ]]; then
|
||||||
skip "skip this test since apparmor is not enabled."
|
skip "skip this test since apparmor is not enabled."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ function teardown() {
|
||||||
|
|
||||||
# this test requires apparmor, so skip this test if apparmor is not enabled.
|
# this test requires apparmor, so skip this test if apparmor is not enabled.
|
||||||
enabled=is_apparmor_enabled
|
enabled=is_apparmor_enabled
|
||||||
if [[ "$enabled" =~ "0" ]]; then
|
if [[ "$enabled" -eq "0" ]]; then
|
||||||
skip "skip this test since apparmor is not enabled."
|
skip "skip this test since apparmor is not enabled."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -187,6 +187,11 @@ function teardown() {
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
[[ "$output" != "" ]]
|
[[ "$output" != "" ]]
|
||||||
[[ "$output" =~ "$ctr1_id" ]]
|
[[ "$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
|
run ocic ctr list --id "$ctr2_id" --pod "$pod2_id" --quiet
|
||||||
echo "$output"
|
echo "$output"
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
|
|
|
@ -161,12 +161,10 @@ function is_seccomp_enabled() {
|
||||||
out=$(cat "$BOOT_CONFIG_FILE_PATH" | grep CONFIG_SECCOMP=)
|
out=$(cat "$BOOT_CONFIG_FILE_PATH" | grep CONFIG_SECCOMP=)
|
||||||
if [[ "$out" =~ "CONFIG_SECCOMP=y" ]]; then
|
if [[ "$out" =~ "CONFIG_SECCOMP=y" ]]; then
|
||||||
echo 1
|
echo 1
|
||||||
else
|
return
|
||||||
echo 0
|
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
echo 0
|
|
||||||
fi
|
fi
|
||||||
|
echo 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function is_apparmor_enabled() {
|
function is_apparmor_enabled() {
|
||||||
|
@ -174,10 +172,8 @@ function is_apparmor_enabled() {
|
||||||
out=$(cat "$APPARMOR_PARAMETERS_FILE_PATH")
|
out=$(cat "$APPARMOR_PARAMETERS_FILE_PATH")
|
||||||
if [[ "$out" =~ "Y" ]]; then
|
if [[ "$out" =~ "Y" ]]; then
|
||||||
echo 1
|
echo 1
|
||||||
else
|
return
|
||||||
echo 0
|
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
echo 0
|
|
||||||
fi
|
fi
|
||||||
|
echo 0
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,6 +112,12 @@ function teardown() {
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
[[ "$output" != "" ]]
|
[[ "$output" != "" ]]
|
||||||
[[ "$output" =~ "$pod1_id" ]]
|
[[ "$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"
|
run ocic pod list --id "$pod2_id"
|
||||||
echo "$output"
|
echo "$output"
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
|
|
Loading…
Reference in a new issue