New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[1.20] oci: add support for capping memory and disk usage from exec sync output #5951
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package oci_test | ||
|
||
import ( | ||
"context" | ||
"io/ioutil" | ||
|
||
"github.com/cri-o/cri-o/internal/oci" | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
const ( | ||
shortTimeout int64 = 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. deadcode: (at-me in a reply with Was this a good recommendation? |
||
mediumTimeout int64 = 3 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. deadcode: (at-me in a reply with Was this a good recommendation? |
||
longTimeout int64 = 15 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. deadcode: (at-me in a reply with Was this a good recommendation? |
||
) | ||
|
||
// The actual test suite | ||
var _ = t.Describe("Oci", func() { | ||
Context("TruncateAndReadFile", func() { | ||
tests := []struct { | ||
title string | ||
contents []byte | ||
expected []byte | ||
fail bool | ||
size int64 | ||
}{ | ||
{ | ||
title: "should read file if size is smaller than limit", | ||
contents: []byte("abcd"), | ||
expected: []byte("abcd"), | ||
size: 5, | ||
}, | ||
{ | ||
title: "should read only size if size is same as limit", | ||
contents: []byte("abcd"), | ||
expected: []byte("abcd"), | ||
size: 4, | ||
}, | ||
{ | ||
title: "should read only size if size is larger than limit", | ||
contents: []byte("abcd"), | ||
expected: []byte("abc"), | ||
size: 3, | ||
}, | ||
} | ||
for _, test := range tests { | ||
test := test | ||
It(test.title, func() { | ||
fileName := t.MustTempFile("to-read") | ||
Expect(ioutil.WriteFile(fileName, test.contents, 0644)).To(BeNil()) | ||
found, err := oci.TruncateAndReadFile(context.Background(), fileName, test.size) | ||
Expect(err).To(BeNil()) | ||
Expect(found).To(Equal(test.expected)) | ||
}) | ||
} | ||
}) | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gofumpt: File is not
gofumpt
-ed(at-me in a reply with
help
orignore
)Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]