-
Notifications
You must be signed in to change notification settings - Fork 259
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
Added LCOW functional tests and benchmarks for uVMs and containers. #1351
Conversation
Exposed data and functionality for testing GCS: * `internal\guest\runtime\hcsv2.Container.InitProcess()` * `internal\guest\runtime\hcsv2.GetOrAddNetworkNamespace()` * `internal\guest\runtime\hcsv2.RemoveNetworkNamespace()` * `internal\guest\runtime\hcsv2.Host.SecurityPolicyEnforcer()` * `internal\guest\runtime\hcsv2.Host.Transport()` Fixed bug where `host.RemoveContainer` did not remove the network namespace for standalone and pod containers. Updated go-winio version to include bugfixes for closing hvsockets, specifically to close a socket for writing (needed by internal\cmd to signal that the stdin stream has finished). The tests themselves are broken out here: microsoft#1352 microsoft#1351 Signed-off-by: Hamza El-Saawy <[email protected]>
Exposed data and functionality for testing GCS: * `internal\guest\runtime\hcsv2.Container.InitProcess()` * `internal\guest\runtime\hcsv2.GetOrAddNetworkNamespace()` * `internal\guest\runtime\hcsv2.RemoveNetworkNamespace()` * `internal\guest\runtime\hcsv2.Host.SecurityPolicyEnforcer()` * `internal\guest\runtime\hcsv2.Host.Transport()` Fixed bug where `host.RemoveContainer` did not remove the network namespace for standalone and pod containers. Updated go-winio version to include bugfixes for closing hvsockets, specifically to close a socket for writing (needed by internal\cmd to signal that the stdin stream has finished). The tests themselves are broken out here: microsoft#1352 microsoft#1351 Signed-off-by: Hamza El-Saawy <[email protected]>
Exposed data and functionality for testing GCS: * `internal\guest\runtime\hcsv2.Container.InitProcess()` * `internal\guest\runtime\hcsv2.GetOrAddNetworkNamespace()` * `internal\guest\runtime\hcsv2.RemoveNetworkNamespace()` * `internal\guest\runtime\hcsv2.Host.SecurityPolicyEnforcer()` * `internal\guest\runtime\hcsv2.Host.Transport()` Fixed bug where `host.RemoveContainer` did not remove the network namespace for standalone and pod containers. Updated go-winio version to include bugfixes for closing hvsockets, specifically to close a socket for writing (needed by internal\cmd to signal that the stdin stream has finished). Added doc.go files to guest packages to prevent linter/compiler errors under windows. The tests themselves are broken out here: microsoft#1352 microsoft#1351 Signed-off-by: Hamza El-Saawy <[email protected]>
Exposed data and functionality for testing GCS: * `internal\guest\runtime\hcsv2.Container.InitProcess()` * `internal\guest\runtime\hcsv2.GetOrAddNetworkNamespace()` * `internal\guest\runtime\hcsv2.RemoveNetworkNamespace()` * `internal\guest\runtime\hcsv2.Host.SecurityPolicyEnforcer()` * `internal\guest\runtime\hcsv2.Host.Transport()` Fixed bug where `host.RemoveContainer` did not remove the network namespace for standalone and pod containers. Updated go-winio version to include bugfixes for closing hvsockets, specifically to close a socket for writing (needed by internal\cmd to signal that the stdin stream has finished). Added doc.go files to guest packages to prevent linter/compiler errors under windows. The tests themselves are broken out here: microsoft#1352 microsoft#1351 Signed-off-by: Hamza El-Saawy <[email protected]>
Exposed data and functionality for testing GCS: * `internal\guest\runtime\hcsv2.Container.InitProcess()` * `internal\guest\runtime\hcsv2.GetOrAddNetworkNamespace()` * `internal\guest\runtime\hcsv2.RemoveNetworkNamespace()` * `internal\guest\runtime\hcsv2.Host.SecurityPolicyEnforcer()` * `internal\guest\runtime\hcsv2.Host.Transport()` Fixed bug where `host.RemoveContainer` did not remove the network namespace for standalone and pod containers. Updated go-winio version to include bugfixes for closing hvsockets, specifically to close a socket for writing (needed by internal\cmd to signal that the stdin stream has finished). Added doc.go files to guest packages to prevent linter/compiler errors under windows. The tests themselves are broken out here: microsoft#1352 microsoft#1351 Signed-off-by: Hamza El-Saawy <[email protected]>
Exposed data and functionality for testing GCS: * `internal\guest\runtime\hcsv2.Container.InitProcess()` * `internal\guest\runtime\hcsv2.GetOrAddNetworkNamespace()` * `internal\guest\runtime\hcsv2.RemoveNetworkNamespace()` * `internal\guest\runtime\hcsv2.Host.SecurityPolicyEnforcer()` * `internal\guest\runtime\hcsv2.Host.Transport()` Fixed bug where `host.RemoveContainer` did not remove the network namespace for standalone and pod containers. Updated go-winio version to include bugfixes for closing hvsockets, specifically to close a socket for writing (needed by internal\cmd to signal that the stdin stream has finished). Added doc.go files to guest packages to prevent linter/compiler errors under windows. The tests themselves are broken out here: #1352 #1351 Signed-off-by: Hamza El-Saawy <[email protected]>
b358cef
to
5bc615a
Compare
40400b1
to
f621e11
Compare
bf77250
to
531d89d
Compare
rebased and fixed test-vendor CI issue |
24b1ac0
to
7381576
Compare
2f110e9
to
6831726
Compare
rebased to fix merge conflicts, removed branch |
rebased, updated tests |
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.
Thanks a lot for working on this Hamza! This is a ton of great work!
test/functional/lcow_bench_test.go
Outdated
b.StopTimer() | ||
b.ResetTimer() | ||
for i := 0; i < b.N; i++ { | ||
opts := defaultLCOWOptions(b, b.Name()) |
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.
Does each iteration count as a "subtest" for the benchmark? If no, wouldn't b.Name() not be unique?
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.
So its a little weird, but this is based on how the docs tell you to do it, a benchmark run of BenchmarkLCOW_UVM_Create
will include as many iterations (b.N
) the target -benchtime
criteria is met (either a set number, eg. -benchtime 1000x
or duration, eg. -benchtime 3s
)
All those iterations are accumulated under one timer, which can then be repeated via -count
So if we with
'-test.count=2' '-test.run=^#' '-test.benchmem' '-test.bench=.' '-test.benchtime=2x'
The output would look something like (I dont know why go append the 12
here):
BenchmarkLCOW_UVM_Create-12 2 84758700 ns/op 47800 B/op 363 allocs/op
BenchmarkLCOW_UVM_Create-12 2 81733600 ns/op 42584 B/op 348 allocs/op
BenchmarkLCOW_UVM_Create-12 2 83118950 ns/op 43904 B/op 385 allocs/op
benchstat then aggregates benchmarks with the same name, so we want the non-uniqueness:
LCOW_UVM_Create-12 83.2ms ± 2%
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.
how does creating a new LCOW work if the names are the same?
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.
the cleanup()
call on line 33 deletes the uvm, so the name can be reused
vm := uvm.CreateLCOW(ctx, b, defaultLCOWOptions(b, b.Name())) | ||
|
||
b.StartTimer() | ||
if err := vm.Start(ctx); err != nil { |
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.
why aren't we using the same 'uvm.Start' function here?
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.
it has a bunch of test-related overhead I dont want to profile
hcsshim/test/internal/uvm/uvm.go
Lines 17 to 28 in bf3434f
f := func() { | |
if err := vm.Close(); err != nil { | |
t.Logf("could not close vm %q: %v", vm.ID(), err) | |
} | |
} | |
if err != nil { | |
t.Helper() | |
t.Fatalf("could not start UVM: %v", err) | |
} | |
return f |
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.
That's pretty negligible code though, I wouldn't expect any of it to cause a marked slowdown
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.
Thats true, I can change it back if you think it distracts unnecessarily?
} | ||
|
||
func Wait(_ context.Context, t testing.TB, c *cmd.Cmd) int { | ||
// todo, wait on context.Done |
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.
why did we not do this in this PR?
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.
I didnt need it yet, and I didnt want to include a whole new batch of tests to see if canceling contexts work as expected
It was more of a note for when we expand the functional tests
// been waited on (usually via a WaitForProcess request) and had its exit code read | ||
// (hcsv2/process.go:(*containerProcess).Wait). | ||
// | ||
// So ... to test container kill and wait times, we need to first start and wait on the init process |
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.
So this just tests the time for the kill and wait command to return when the container init is already exited? I would think the thing we really care about is how long it takes to stop a simple program that's running.
id := strings.ReplaceAll(t.Name(), "/", "") | ||
scratch, _ := layers.ScratchSpace(ctx, t, vm, "", "", cache) | ||
spec := oci.CreateLinuxSpec(ctx, t, id, | ||
oci.DefaultLinuxSpecOpts(id, | ||
ctrdoci.WithProcessArgs(tt.args...), | ||
oci.WithWindowsLayerFolders(append(ls, scratch)))...) |
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.
This could probably all be refactored out as well
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.
Rebase and then lgtm
Split out utility functions from `test/functional` into an internal package, separate from functional tests. Updated code to use containerd instead of docker. Added new functional tests and benchmarks for LCOW uVM containers, and updated other LCOW tests as well. Not all (LCOW) functional tests were updated, and most others are now explicitly skipped. Updated `k8s.io/cri-api` to v0.22 to include `WindowsPodSandboxConfig` struct Signed-off-by: Hamza El-Saawy <[email protected]>
Signed-off-by: Hamza El-Saawy <[email protected]>
Added deprecated warning to `layers.LayerFolders`, which relies on docker. Added doc comment to functional tests to clarify overlap with other tests. Removed unnecessary parameter in `WaitForError`. Updated snapshotter logic Signed-off-by: Hamza El-Saawy <[email protected]>
Signed-off-by: Hamza El-Saawy <[email protected]>
Exposed data and functionality for testing GCS: * `internal\guest\runtime\hcsv2.Container.InitProcess()` * `internal\guest\runtime\hcsv2.GetOrAddNetworkNamespace()` * `internal\guest\runtime\hcsv2.RemoveNetworkNamespace()` * `internal\guest\runtime\hcsv2.Host.SecurityPolicyEnforcer()` * `internal\guest\runtime\hcsv2.Host.Transport()` Fixed bug where `host.RemoveContainer` did not remove the network namespace for standalone and pod containers. Updated go-winio version to include bugfixes for closing hvsockets, specifically to close a socket for writing (needed by internal\cmd to signal that the stdin stream has finished). Added doc.go files to guest packages to prevent linter/compiler errors under windows. The tests themselves are broken out here: microsoft#1352 microsoft#1351 Signed-off-by: Hamza El-Saawy <[email protected]>
This PR is broken into two commits: the first has the core changes, and the second is vendoring and switching other tests to use the new testing utilities.
Added functional tests and benchmarks for LCOW uVMs and containers and updated other LCOW tests to work.
Non-working tests are skipped.
Split out test utilities from test/functional to an internal package, and updated it o use containerd instead of docker.
Updated cri-containerd and runhcs tests to use moved code in test\internal.
Updated
k8s.io/cri-api
to v0.22 to useWindowsPodSandboxConfig
structRelies on PRs:
Signed-off-by: Hamza El-Saawy [email protected]