Skip to content

Commit

Permalink
tests: Add AlpineExtended image to the tests
Browse files Browse the repository at this point in the history
The new image includes cloud-init.
The next commits will use this image and configure the Alpine networking
using cloud-init network-data instead of configuring it via the console.

This commit includes the following -
- Adding the new image to the local registry.
- Introduce libvmi factory - "NewAlpineExtended"
- Introduce libvmi network Options - "WithMasqueradeNetworking"

Signed-off-by: Alona Kaplan <[email protected]>
  • Loading branch information
AlonaKaplan committed Apr 27, 2022
1 parent 0a5de61 commit 1d75424
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 3 deletions.
1 change: 1 addition & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ container_bundle(
"$(container_prefix)/$(image_prefix)alpine-ext-kernel-boot-demo:$(container_tag)": "//containerimages:alpine-ext-kernel-boot-demo-container",
# Customized container-disk images
"$(container_prefix)/$(image_prefix)fedora-with-test-tooling-container-disk:$(container_tag)": "//containerimages:fedora-with-test-tooling",
"$(container_prefix)/$(image_prefix)alpine-with-test-tooling-container-disk:$(container_tag)": "//containerimages:alpine-with-test-tooling",
"$(container_prefix)/$(image_prefix)fedora-realtime-container-disk:$(container_tag)": "//containerimages:fedora-realtime",
# testing images
"$(container_prefix)/$(image_prefix)disks-images-provider:$(container_tag)": "//images/disks-images-provider:disks-images-provider-image",
Expand Down
8 changes: 8 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,14 @@ container_pull(
repository = "kubevirtci/fedora-with-test-tooling",
)

container_pull(
name = "alpine_with_test_tooling",
digest = "sha256:48181a73ecc9c076ad30d8e31202e46a6c4ff4aff7a17b098b8864f2b8f099df",
registry = "quay.io",
repository = "kubevirtci/alpine-with-test-tooling-container-disk",
tag = "2204130933-caa3837",
)

container_pull(
name = "fedora_with_test_tooling_aarch64",
digest = "sha256:9b1371260c05086a24ac9effdbedca9759c885ea8db93de7f0339df3bcd5a5c3",
Expand Down
11 changes: 11 additions & 0 deletions containerimages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,17 @@ container_image(
visibility = ["//visibility:public"],
)

container_image(
name = "alpine-with-test-tooling",
architecture = select({
"@io_bazel_rules_go//go/platform:linux_arm64": "arm64",
"//conditions:default": "amd64",
}),
base = "@alpine_with_test_tooling//image",
mode = "444",
visibility = ["//visibility:public"],
)

container_image(
name = "alpine-ext-kernel-boot-demo-container",
architecture = select({
Expand Down
4 changes: 2 additions & 2 deletions tests/console/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func LoginToAlpine(vmi *v1.VirtualMachineInstance) error {
// Do not login, if we already logged in
b := append([]expect.Batcher{
&expect.BSnd{S: "\n"},
&expect.BExp{R: "localhost:~\\# "},
&expect.BExp{R: fmt.Sprintf(`(localhost|%s):~\\# `, vmi.Name)},
})
_, err = expecter.ExpectBatch(b, 5*time.Second)
if err == nil {
Expand All @@ -94,7 +94,7 @@ func LoginToAlpine(vmi *v1.VirtualMachineInstance) error {

b = append([]expect.Batcher{
&expect.BSnd{S: "\n"},
&expect.BExp{R: "localhost login:"},
&expect.BExp{R: fmt.Sprintf(`(localhost|%s) login: `, vmi.Name)},
&expect.BSnd{S: "root\n"},
&expect.BExp{R: PromptExpression}})
res, err := expecter.ExpectBatch(b, 180*time.Second)
Expand Down
3 changes: 2 additions & 1 deletion tests/containerdisk/containerdisk.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const (
ContainerDiskCirrosCustomLocation ContainerDisk = "cirros-custom"
ContainerDiskCirros ContainerDisk = "cirros"
ContainerDiskAlpine ContainerDisk = "alpine"
ContainerDiskAlpineTestTooling ContainerDisk = "alpine-with-test-tooling"
ContainerDiskFedoraTestTooling ContainerDisk = "fedora-with-test-tooling"
ContainerDiskVirtio ContainerDisk = "virtio-container-disk"
ContainerDiskEmpty ContainerDisk = "empty"
Expand Down Expand Up @@ -62,7 +63,7 @@ func ContainerDiskFromRegistryFor(registry string, name ContainerDisk) string {
return fmt.Sprintf("%s/%s-container-disk-demo:%s", registry, name, flags.KubeVirtUtilityVersionTag)
case ContainerDiskVirtio:
return fmt.Sprintf("%s/virtio-container-disk:%s", registry, flags.KubeVirtUtilityVersionTag)
case ContainerDiskFedoraTestTooling, ContainerDiskFedoraRealtime:
case ContainerDiskFedoraTestTooling, ContainerDiskFedoraRealtime, ContainerDiskAlpineTestTooling:
return fmt.Sprintf("%s/%s-container-disk:%s", registry, name, flags.KubeVirtUtilityVersionTag)
}
panic(fmt.Sprintf("Unsupported registry disk %s", name))
Expand Down
1 change: 1 addition & 0 deletions tests/libvmi/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ go_library(
"//staging/src/kubevirt.io/api/core/v1:go_default_library",
"//staging/src/kubevirt.io/client-go/kubecli:go_default_library",
"//tests/containerdisk:go_default_library",
"//tests/libnet:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
Expand Down
11 changes: 11 additions & 0 deletions tests/libvmi/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,14 @@ func NewAlpine(opts ...Option) *kvirtv1.VirtualMachineInstance {
alpineOpts = append(alpineOpts, opts...)
return New(RandName(DefaultVmiName), alpineOpts...)
}

func NewAlpineWithTestTooling(opts ...Option) *kvirtv1.VirtualMachineInstance {
alpineOpts := []Option{
WithContainerImage(cd.ContainerDiskFor(cd.ContainerDiskAlpineTestTooling)),
WithResourceMemory("128Mi"),
WithRng(),
WithTerminationGracePeriod(DefaultTestGracePeriod),
}
alpineOpts = append(alpineOpts, opts...)
return New(RandName(DefaultVmiName), alpineOpts...)
}
11 changes: 11 additions & 0 deletions tests/libvmi/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ package libvmi

import (
kvirtv1 "kubevirt.io/api/core/v1"

"kubevirt.io/kubevirt/tests/libnet"
)

const DefaultInterfaceName = "default"
Expand All @@ -41,6 +43,15 @@ func WithNetwork(network *kvirtv1.Network) Option {
}
}

func WithMasqueradeNetworking() []Option {
networkData, _ := libnet.CreateDefaultCloudInitNetworkData()
return []Option{
WithInterface(InterfaceDeviceWithMasqueradeBinding()),
WithNetwork(kvirtv1.DefaultPodNetwork()),
WithCloudInitNoCloudNetworkData(networkData, false),
}
}

// InterfaceDeviceWithMasqueradeBinding returns an Interface named "default" with masquerade binding.
func InterfaceDeviceWithMasqueradeBinding(ports ...kvirtv1.Port) kvirtv1.Interface {
return kvirtv1.Interface{
Expand Down

0 comments on commit 1d75424

Please sign in to comment.