Files
kata-containers/src/runtime/virtcontainers/remote_test.go
Yohei Ueda 57d4dd8e57 runtime: Support the remote hypervisor type
This patch adds the support of the remote hypervisor type.
Shim opens a Unix domain socket specified in the config file,
and sends TTPRC requests to a external process to control
sandbox VMs.

Fixes #4482

Co-authored-by: Pradipta Banerjee <pradipta.banerjee@gmail.com>
Co-authored-by: stevenhorsman <steven@uk.ibm.com>
Signed-off-by: Yohei Ueda <yohei@jp.ibm.com>
(based on commit f9278f22c3)
2023-11-17 13:32:49 +00:00

46 lines
1.0 KiB
Go

// Copyright (c) 2023 IBM Corporation
// SPDX-License-Identifier: Apache-2.0
package virtcontainers
import (
"testing"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"
"github.com/stretchr/testify/assert"
)
func newRemoteConfig() HypervisorConfig {
return HypervisorConfig{
RemoteHypervisorSocket: "/run/peerpod/hypervisor.sock",
RemoteHypervisorTimeout: 600,
DisableGuestSeLinux: true,
EnableAnnotations: []string{},
}
}
func TestRemoteHypervisorGenerateSocket(t *testing.T) {
assert := assert.New(t)
remoteHypervisor := remoteHypervisor{
config: newRemoteConfig(),
}
id := "sandboxId"
// No socketPath should error
_, err := remoteHypervisor.GenerateSocket(id)
assert.Error(err)
socketPath := "socketPath"
remoteHypervisor.agentSocketPath = socketPath
result, err := remoteHypervisor.GenerateSocket(id)
assert.NoError(err)
expected := types.RemoteSock{
SandboxID: id,
TunnelSocketPath: socketPath,
}
assert.Equal(result, expected)
}