@@ -717,7 +717,6 @@ func TestCreateInstance_MapsRestartPolicy(t *testing.T) {
717717 svc .InstanceManager = mockMgr
718718
719719 policy := oapi .OnFailure
720- strategy := oapi .StopStart
721720 backoff := "7s"
722721 stableAfter := "2m"
723722 maxAttempts := 4
@@ -728,7 +727,6 @@ func TestCreateInstance_MapsRestartPolicy(t *testing.T) {
728727 Image : "docker.io/library/alpine:latest" ,
729728 RestartPolicy : & oapi.RestartPolicy {
730729 Policy : & policy ,
731- Strategy : & strategy ,
732730 Backoff : & backoff ,
733731 StableAfter : & stableAfter ,
734732 MaxAttempts : & maxAttempts ,
@@ -742,7 +740,6 @@ func TestCreateInstance_MapsRestartPolicy(t *testing.T) {
742740 require .NotNil (t , mockMgr .lastReq )
743741 require .NotNil (t , mockMgr .lastReq .RestartPolicy )
744742 assert .Equal (t , restartpolicy .PolicyOnFailure , mockMgr .lastReq .RestartPolicy .Policy )
745- assert .Equal (t , restartpolicy .StrategyStopStart , mockMgr .lastReq .RestartPolicy .Strategy )
746743 assert .Equal (t , "7s" , mockMgr .lastReq .RestartPolicy .Backoff )
747744 assert .Equal (t , "2m0s" , mockMgr .lastReq .RestartPolicy .StableAfter )
748745 assert .Equal (t , 4 , mockMgr .lastReq .RestartPolicy .MaxAttempts )
@@ -751,8 +748,6 @@ func TestCreateInstance_MapsRestartPolicy(t *testing.T) {
751748 require .NotNil (t , instance .RestartPolicy )
752749 require .NotNil (t , instance .RestartPolicy .Policy )
753750 assert .Equal (t , oapi .OnFailure , * instance .RestartPolicy .Policy )
754- require .NotNil (t , instance .RestartPolicy .Strategy )
755- assert .Equal (t , oapi .StopStart , * instance .RestartPolicy .Strategy )
756751}
757752
758753func TestUpdateInstance_MapsEnvPatch (t * testing.T ) {
@@ -950,7 +945,6 @@ func TestUpdateInstance_MapsRestartPolicyPatch(t *testing.T) {
950945 HypervisorType : hypervisor .TypeCloudHypervisor ,
951946 RestartPolicy : & restartpolicy.Policy {
952947 Policy : restartpolicy .PolicyAlways ,
953- Strategy : restartpolicy .StrategyStopStart ,
954948 Backoff : "5s" ,
955949 StableAfter : "10m0s" ,
956950 },
@@ -964,7 +958,6 @@ func TestUpdateInstance_MapsRestartPolicyPatch(t *testing.T) {
964958 svc .InstanceManager = mockMgr
965959
966960 policy := oapi .Always
967- strategy := oapi .StopStart
968961 resolved := & instances.Instance {
969962 StoredMetadata : instances.StoredMetadata {
970963 Id : "inst-update-restart-policy" ,
@@ -979,7 +972,7 @@ func TestUpdateInstance_MapsRestartPolicyPatch(t *testing.T) {
979972 resp , err := svc .UpdateInstance (mw .WithResolvedInstance (ctx (), resolved .Id , resolved ), oapi.UpdateInstanceRequestObject {
980973 Id : resolved .Id ,
981974 Body : & oapi.UpdateInstanceRequest {
982- RestartPolicy : & oapi.RestartPolicy {Policy : & policy , Strategy : & strategy },
975+ RestartPolicy : & oapi.RestartPolicy {Policy : & policy },
983976 },
984977 })
985978 require .NoError (t , err )
@@ -990,12 +983,9 @@ func TestUpdateInstance_MapsRestartPolicyPatch(t *testing.T) {
990983 assert .True (t , mockMgr .lastReq .RestartPolicySet )
991984 require .NotNil (t , mockMgr .lastReq .RestartPolicy )
992985 assert .Equal (t , restartpolicy .PolicyAlways , mockMgr .lastReq .RestartPolicy .Policy )
993- assert .Equal (t , restartpolicy .StrategyStopStart , mockMgr .lastReq .RestartPolicy .Strategy )
994986
995987 instance := oapi .Instance (updated )
996988 require .NotNil (t , instance .RestartPolicy )
997- require .NotNil (t , instance .RestartPolicy .Strategy )
998- assert .Equal (t , oapi .StopStart , * instance .RestartPolicy .Strategy )
999989 require .NotNil (t , instance .RestartStatus )
1000990 require .NotNil (t , instance .RestartStatus .BlockedReason )
1001991 assert .Equal (t , oapi .ManualStop , * instance .RestartStatus .BlockedReason )
@@ -1040,46 +1030,6 @@ func TestUpdateInstance_RejectsInvalidRestartPolicy(t *testing.T) {
10401030 assert .Nil (t , mockMgr .lastReq )
10411031}
10421032
1043- func TestUpdateInstance_RejectsUnsupportedRestartStrategy (t * testing.T ) {
1044- t .Parallel ()
1045- svc := newTestService (t )
1046-
1047- origMgr := svc .InstanceManager
1048- mockMgr := & captureUpdateManager {Manager : origMgr }
1049- svc .InstanceManager = mockMgr
1050-
1051- now := time .Now ()
1052- resolved := & instances.Instance {
1053- StoredMetadata : instances.StoredMetadata {
1054- Id : "inst-update-restart-policy" ,
1055- Name : "inst-update-restart-policy" ,
1056- Image : "docker.io/library/alpine:latest" ,
1057- CreatedAt : now ,
1058- HypervisorType : hypervisor .TypeCloudHypervisor ,
1059- },
1060- State : instances .StateStopped ,
1061- }
1062- policy := oapi .OnFailure
1063- strategy := oapi .DeleteCreate
1064-
1065- resp , err := svc .UpdateInstance (mw .WithResolvedInstance (ctx (), resolved .Id , resolved ), oapi.UpdateInstanceRequestObject {
1066- Id : resolved .Id ,
1067- Body : & oapi.UpdateInstanceRequest {
1068- RestartPolicy : & oapi.RestartPolicy {
1069- Policy : & policy ,
1070- Strategy : & strategy ,
1071- },
1072- },
1073- })
1074- require .NoError (t , err )
1075-
1076- badReq , ok := resp .(oapi.UpdateInstance400JSONResponse )
1077- require .True (t , ok , "expected 400 response" )
1078- assert .Equal (t , "invalid_restart_policy" , badReq .Code )
1079- assert .Contains (t , badReq .Message , "delete_create is not supported yet" )
1080- assert .Nil (t , mockMgr .lastReq )
1081- }
1082-
10831033func TestUpdateInstance_RejectsZeroAutoStandbyIgnoreDestinationPort (t * testing.T ) {
10841034 t .Parallel ()
10851035 svc := newTestService (t )
0 commit comments