Skip to content

Conversation

@eofff
Copy link
Contributor

@eofff eofff commented Dec 19, 2025

Description

Exclude power state checks from complex test. Write new e2e power state test.

Why do we need it, and what problem does it solve?

What is the expected result?

Checklist

  • The code is covered by unit tests.
  • e2e tests passed.
  • Documentation updated according to the changes.
  • Changes were tested in the Kubernetes cluster manually.

Changelog entries

section: vm
type: chore
summary: Exclude power state checks from complex test. Write new e2e power state test.
impact_level: low

@eofff eofff added this to the v1.4.0 milestone Dec 19, 2025
@eofff eofff marked this pull request as ready for review December 19, 2025 10:01
@eofff eofff requested review from Isteb4k and fl64 as code owners December 19, 2025 10:01
@eofff eofff force-pushed the test/power-state-check branch from 19e556f to 5435a88 Compare December 19, 2025 13:10
@eofff eofff requested a review from hardcoretime December 24, 2025 08:13
Valeriy Khorunzhin added 2 commits December 24, 2025 11:20
add
Signed-off-by: Valeriy Khorunzhin <valeriy.khorunzhin@flant.com>
fix
Signed-off-by: Valeriy Khorunzhin <valeriy.khorunzhin@flant.com>
@eofff eofff force-pushed the test/power-state-check branch from 5435a88 to f37fa61 Compare December 24, 2025 08:20
func StopVirtualMachineFromOS(f *framework.Framework, vm *v1alpha2.VirtualMachine) {
GinkgoHelper()

_, err := f.SSHCommand(vm.Name, vm.Namespace, "nohup sh -c \"sleep 5 && sudo init 0\" > /dev/null 2>&1 &")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that the solution does not work on Alpine OS. If this is a common solution, it should work on other operating systems.

_, err := f.SSHCommand(vm.Name, vm.Namespace, "nohup sh -c \"sleep 5 && sudo init 0\" > /dev/null 2>&1 &")
Expect(err).To(SatisfyAny(
Not(HaveOccurred()),
MatchError(MatchError(ContainSubstring("unexpected EOF"))),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this error expected here?

_, err := f.SSHCommand(vm.Name, vm.Namespace, "nohup sh -c \"sleep 5 && sudo reboot\" > /dev/null 2>&1 &")
Expect(err).To(SatisfyAny(
Not(HaveOccurred()),
MatchError(MatchError(ContainSubstring("unexpected EOF"))),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this error expected here?

Expect(err).NotTo(HaveOccurred())
}

func RebootVirtualMachineByPodDeletion(f *framework.Framework, vm *v1alpha2.VirtualMachine) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it work with length and indexes, instead of an active pod?


opts := []vmopbuilder.Option{
vmopbuilder.WithGenerateName("vmop-e2e-"),
vmopbuilder.WithGenerateName("vmop-start-"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be in the same style as reboot, with a prefix. You can create the prefix constants in one place.

Comment on lines +46 to +54
var namespaceName string
switch runPolicy {
case v1alpha2.AlwaysOnPolicy:
namespaceName = "power-aon"
case v1alpha2.AlwaysOnUnlessStoppedManually:
namespaceName = "power-aon-usm"
case v1alpha2.ManualPolicy:
namespaceName = "power-manual"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var namespaceName string
switch runPolicy {
case v1alpha2.AlwaysOnPolicy:
namespaceName = "power-aon"
case v1alpha2.AlwaysOnUnlessStoppedManually:
namespaceName = "power-aon-usm"
case v1alpha2.ManualPolicy:
namespaceName = "power-manual"
var namespaceSuffix string
switch runPolicy {
case v1alpha2.AlwaysOnPolicy:
namespaceSuffix = "always-on"
case v1alpha2.AlwaysOnUnlessStoppedManually:
namespaceSuffix = "unless-stopped-manually"
case v1alpha2.ManualPolicy:
namespaceSuffix = "manual"


util.UntilObjectPhase(string(v1alpha2.MachineRunning), framework.LongTimeout, t.VM)
util.UntilObjectPhase(string(v1alpha2.BlockDeviceAttachmentPhaseAttached), framework.MiddleTimeout, t.VMBDA)
util.UntilVMAgentReady(crclient.ObjectKeyFromObject(t.VM), framework.ShortTimeout)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary in this test case?

Comment on lines +276 to +295
t.VMOPStop = vmopbuilder.New(
vmopbuilder.WithGenerateName("vmop-stop-"),
vmopbuilder.WithNamespace(t.VM.Namespace),
vmopbuilder.WithType(v1alpha2.VMOPTypeStop),
vmopbuilder.WithVirtualMachine(t.VM.Name),
)

t.VMOPStart = vmopbuilder.New(
vmopbuilder.WithGenerateName("vmop-start-"),
vmopbuilder.WithNamespace(t.VM.Namespace),
vmopbuilder.WithType(v1alpha2.VMOPTypeStart),
vmopbuilder.WithVirtualMachine(t.VM.Name),
)

t.VMOPRestart = vmopbuilder.New(
vmopbuilder.WithGenerateName("vmop-restart-"),
vmopbuilder.WithNamespace(t.VM.Namespace),
vmopbuilder.WithType(v1alpha2.VMOPTypeRestart),
vmopbuilder.WithVirtualMachine(t.VM.Name),
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you use the functions from the util.go file?

Comment on lines +120 to +125
if t.VM.Spec.RunPolicy == v1alpha2.AlwaysOnPolicy {
return // No need to start VM if it's AlwaysOn policy
}

util.StartVirtualMachine(f, t.VM)
util.UntilVMAgentReady(crclient.ObjectKeyFromObject(t.VM), framework.MiddleTimeout)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if t.VM.Spec.RunPolicy == v1alpha2.AlwaysOnPolicy {
return // No need to start VM if it's AlwaysOn policy
}
util.StartVirtualMachine(f, t.VM)
util.UntilVMAgentReady(crclient.ObjectKeyFromObject(t.VM), framework.MiddleTimeout)
if t.VM.Spec.RunPolicy != v1alpha2.AlwaysOnPolicy {
util.StartVirtualMachine(f, t.VM)
util.UntilObjectPhase(string(v1alpha2.MachineRunning), framework.ShortTimeout, t.VM)
}

})

By("Check VM can reach external network", func() {
network.CheckExternalConnectivity(f, t.VM.Name, network.ExternalHost, network.HTTPStatusOk)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you excluding "CheckCiliumAgents"?

@eofff eofff marked this pull request as draft December 30, 2025 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants