Skip to content

Commit

Permalink
[test] Add Hyper-V socket functional tests (microsoft#1979)
Browse files Browse the repository at this point in the history
* [test] Add hvsock connection tests

Add tests for binding to and listening on hyper-v sockets from within a
uVM (as well as a hyper-v isolated containers).
Tests verify default SDDL and wildcard bind settings, as well updating
the settings for a particular service ID.

In order to test HVSocket communication, an agent is needed to run from
within the uVM (or container within that).
To accomplish that, the ability to re-exec the (functional) testing
binary is added, so that it can be shared into the uVM (or container)
and then run a separate code path that is defined within the same test
case that is running on the host.

For example, while running the test case
`TestHVSock_Container_GuestBind/default`, the functional testing binary
that is being run (i.e. `functional.test.exe`) is shared within the
running container and then run with the flag
`-run=^TestHVSock_Container_GuestBind$/^default$`. This causes the guest
to bind to the agreed-upon Service GUID, and then (after the host
connects to the same Service GUID), the guest verifies the expected VM
and service GUIDs, and then ensures communication is possible.

Signed-off-by: Hamza El-Saawy <[email protected]>

* PR: remove hvsock feature

Signed-off-by: Hamza El-Saawy <[email protected]>

---------

Signed-off-by: Hamza El-Saawy <[email protected]>
  • Loading branch information
helsaawy authored Jul 8, 2024
1 parent 6cbdf4c commit 5980d9b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions uvm/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"path/filepath"
"runtime"

"github.com/Microsoft/go-winio/pkg/guid"
"github.com/sirupsen/logrus"
"go.opencensus.io/trace"
"golang.org/x/sys/windows"
Expand Down Expand Up @@ -174,6 +175,13 @@ func (uvm *UtilityVM) ID() string {
return uvm.hcsSystem.ID()
}

// RuntimeID returns Hyper-V VM GUID.
//
// Only valid after the utility VM has been created.
func (uvm *UtilityVM) RuntimeID() guid.GUID {
return uvm.runtimeID
}

// OS returns the operating system of the utility VM.
func (uvm *UtilityVM) OS() string {
return uvm.operatingSystem
Expand Down

0 comments on commit 5980d9b

Please sign in to comment.