Skip to content

Commit

Permalink
test/e2e: new container_runtime property for libvirt
Browse files Browse the repository at this point in the history
Commit a0247ae introduced a new parameter (CONTAINER_RUNTIME) for docker
provider, allowing users to specify the container runtime used. Some tests will
take decisions based on that property, for example, whether nydus snapshotter
messages should be inspected or not. This added the handler for that property
for libvirt, so that peer-pods be tested with cri-o too.

Fixes confidential-containers#1981
Signed-off-by: Wainer dos Santos Moschetta <[email protected]>
  • Loading branch information
wainersm committed Sep 27, 2024
1 parent 71b2c67 commit 1a91d70
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 27 deletions.
1 change: 1 addition & 0 deletions src/cloud-api-adaptor/test/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ Use the properties on the table below for Libvirt:
|Property|Description|Default|
|---|---|---|
|container_runtime|Test cluster configured container runtime. Either **containerd** or **crio** |containerd|
|libvirt_network|Libvirt Network|"default"|
|libvirt_storage|Libvirt storage pool|"default"|
|libvirt_vol_name|Volume name|"podvm-base.qcow2"|
Expand Down
62 changes: 35 additions & 27 deletions src/cloud-api-adaptor/test/provisioner/libvirt/provision_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,17 @@ import (

// LibvirtProvisioner implements the CloudProvisioner interface for Libvirt.
type LibvirtProvisioner struct {
conn *libvirt.Connect // Libvirt connection
network string // Network name
ssh_key_file string // SSH key file used to connect to Libvirt
storage string // Storage pool name
uri string // Libvirt URI
wd string // libvirt's directory path on this repository
volumeName string // Podvm volume name
clusterName string // Cluster name
kbs_image string // KBS Service OCI Image URL
kbs_image_tag string // KBS Service OCI Image Tag
conn *libvirt.Connect // Libvirt connection
containerRuntime string // Either containerd or crio
network string // Network name
ssh_key_file string // SSH key file used to connect to Libvirt
storage string // Storage pool name
uri string // Libvirt URI
wd string // libvirt's directory path on this repository
volumeName string // Podvm volume name
clusterName string // Cluster name
kbs_image string // KBS Service OCI Image URL
kbs_image_tag string // KBS Service OCI Image Tag
}

// LibvirtInstallOverlay implements the InstallOverlay interface
Expand Down Expand Up @@ -77,6 +78,11 @@ func NewLibvirtProvisioner(properties map[string]string) (pv.CloudProvisioner, e
return nil, err
}

container_runtime := pv.DEFAULT_CONTAINER_RUNTIME
if properties["container_runtime"] != "" {
container_runtime = properties["container_runtime"]
}

clusterName := "peer-pods"
if properties["cluster_name"] != "" {
clusterName = properties["cluster_name"]
Expand All @@ -94,16 +100,17 @@ func NewLibvirtProvisioner(properties map[string]string) (pv.CloudProvisioner, e

// TODO: Check network and storage are not nil?
return &LibvirtProvisioner{
conn: conn,
network: network,
ssh_key_file: ssh_key_file,
storage: storage,
uri: uri,
wd: wd,
volumeName: vol_name,
clusterName: clusterName,
kbs_image: kbs_image,
kbs_image_tag: kbs_image_tag,
conn: conn,
containerRuntime: container_runtime,
network: network,
ssh_key_file: ssh_key_file,
storage: storage,
uri: uri,
wd: wd,
volumeName: vol_name,
clusterName: clusterName,
kbs_image: kbs_image,
kbs_image_tag: kbs_image_tag,
}, nil
}

Expand Down Expand Up @@ -203,13 +210,14 @@ func (l *LibvirtProvisioner) DeleteVPC(ctx context.Context, cfg *envconf.Config)

func (l *LibvirtProvisioner) GetProperties(ctx context.Context, cfg *envconf.Config) map[string]string {
return map[string]string{
"network": l.network,
"podvm_volume": l.volumeName,
"ssh_key_file": l.ssh_key_file,
"storage": l.storage,
"uri": l.uri,
"KBS_IMAGE": l.kbs_image,
"KBS_IMAGE_TAG": l.kbs_image_tag,
"CONTAINER_RUNTIME": l.containerRuntime,
"network": l.network,
"podvm_volume": l.volumeName,
"ssh_key_file": l.ssh_key_file,
"storage": l.storage,
"uri": l.uri,
"KBS_IMAGE": l.kbs_image,
"KBS_IMAGE_TAG": l.kbs_image_tag,
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/cloud-api-adaptor/test/provisioner/provision.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ type CloudProvisioner interface {
UploadPodvm(imagePath string, ctx context.Context, cfg *envconf.Config) error
}

const DEFAULT_CONTAINER_RUNTIME = "containerd"

type NewProvisionerFunc func(properties map[string]string) (CloudProvisioner, error)

// KbsInstallOverlay implements the InstallOverlay interface
Expand Down

0 comments on commit 1a91d70

Please sign in to comment.