@@ -720,6 +720,53 @@ var _ = Describe("ensureSSHKey", func() {
720720 )
721721})
722722
723+ var _ = Describe ("actionPreparing" , func () {
724+ It ("continues when Robot omits rescue availability from the server response" , func () {
725+ host := helpers .BareMetalHost (
726+ "test-host" ,
727+ "default" ,
728+ helpers .WithSSHSpecInclPorts (22 , 22 ),
729+ )
730+
731+ robotMock := robotmock.Client {}
732+ robotMock .On ("GetBMServer" , mock .Anything ).Return (& models.Server {
733+ ServerNumber : 1 ,
734+ ServerIP : "1.2.3.4" ,
735+ ServerIPv6Net : "2a01:4f9:3051:12ce::" ,
736+ Rescue : false ,
737+ }, nil )
738+ robotMock .On ("ListSSHKeys" ).Return ([]models.Key {}, nil )
739+ robotMock .On ("SetSSHKey" , mock .Anything , mock .Anything ).Return (
740+ & models.Key {Name : rescueSSHKeyName , Fingerprint : sshFingerprint },
741+ nil ,
742+ )
743+ robotMock .On ("GetReboot" , mock .Anything ).Return (& models.Reset {Type : []string {"sw" , "hw" }}, nil )
744+ robotMock .On ("DeleteBootRescue" , mock .Anything ).Return (& models.Rescue {Active : false }, nil )
745+ robotMock .On ("SetBootRescue" , mock .Anything , sshFingerprint ).Return (& models.Rescue {Active : true }, nil )
746+ robotMock .On ("RebootBMServer" , mock .Anything , infrav1 .RebootTypeSoftware ).Return (& models.ResetPost {}, nil )
747+
748+ sshMock := & sshmock.Client {}
749+ sshMock .On ("GetHostName" ).Return (sshclient.Output {})
750+
751+ service := newTestService (
752+ host ,
753+ & robotMock ,
754+ bmmock .NewSSHFactory (sshMock , sshMock , sshMock ),
755+ helpers .GetDefaultSSHSecret (osSSHKeyName , "default" ),
756+ helpers .GetDefaultSSHSecret (rescueSSHKeyName , "default" ),
757+ )
758+
759+ actResult := service .actionPreparing (context .Background ())
760+
761+ Expect (actResult ).To (BeAssignableToTypeOf (actionComplete {}))
762+ Expect (host .Spec .Status .ErrorType ).To (Equal (infrav1 .ErrorTypeSoftwareRebootTriggered ))
763+ Expect (host .Spec .Status .IPv4 ).To (Equal ("1.2.3.4" ))
764+ Expect (host .Spec .Status .IPv6 ).To (Equal ("2a01:4f9:3051:12ce::1" ))
765+ Expect (robotMock .AssertCalled (GinkgoT (), "DeleteBootRescue" , mock .Anything )).To (BeTrue ())
766+ Expect (robotMock .AssertCalled (GinkgoT (), "SetBootRescue" , mock .Anything , sshFingerprint )).To (BeTrue ())
767+ })
768+ })
769+
723770var _ = Describe ("analyzeSSHOutputInstallImage" , func () {
724771 type testCaseAnalyzeSSHOutputInstallImageOutErr struct {
725772 err error
0 commit comments