@@ -185,7 +185,7 @@ func (s *AppInstallControllerTestSuite) TestRunAppPreflights() {
185185 opts : RunAppPreflightOptions {
186186 PreflightBinaryPath : "/usr/bin/preflight" ,
187187 },
188- currentState : states .StateSucceeded ,
188+ currentState : states .StateInfrastructureInstalled ,
189189 expectedState : states .StateAppPreflightsSucceeded ,
190190 setupMocks : func (apm * apppreflightmanager.MockAppPreflightManager , arm * appreleasemanager.MockAppReleaseManager , acm * appconfig.MockAppConfigManager ) {
191191 mock .InOrder (
@@ -263,7 +263,7 @@ func (s *AppInstallControllerTestSuite) TestRunAppPreflights() {
263263 opts : RunAppPreflightOptions {
264264 PreflightBinaryPath : "/usr/bin/preflight" ,
265265 },
266- currentState : states .StateSucceeded ,
266+ currentState : states .StateInfrastructureInstalled ,
267267 expectedState : states .StateAppPreflightsFailed ,
268268 setupMocks : func (apm * apppreflightmanager.MockAppPreflightManager , arm * appreleasemanager.MockAppReleaseManager , acm * appconfig.MockAppConfigManager ) {
269269 mock .InOrder (
@@ -289,7 +289,7 @@ func (s *AppInstallControllerTestSuite) TestRunAppPreflights() {
289289 opts : RunAppPreflightOptions {
290290 PreflightBinaryPath : "/usr/bin/preflight" ,
291291 },
292- currentState : states .StateSucceeded ,
292+ currentState : states .StateInfrastructureInstalled ,
293293 expectedState : states .StateAppPreflightsExecutionFailed ,
294294 setupMocks : func (apm * apppreflightmanager.MockAppPreflightManager , arm * appreleasemanager.MockAppReleaseManager , acm * appconfig.MockAppConfigManager ) {
295295 mock .InOrder (
@@ -308,7 +308,7 @@ func (s *AppInstallControllerTestSuite) TestRunAppPreflights() {
308308 opts : RunAppPreflightOptions {
309309 PreflightBinaryPath : "/usr/bin/preflight" ,
310310 },
311- currentState : states .StateSucceeded ,
311+ currentState : states .StateInfrastructureInstalled ,
312312 expectedState : states .StateAppPreflightsSucceeded ,
313313 setupMocks : func (apm * apppreflightmanager.MockAppPreflightManager , arm * appreleasemanager.MockAppReleaseManager , acm * appconfig.MockAppConfigManager ) {
314314 mock .InOrder (
@@ -327,7 +327,7 @@ func (s *AppInstallControllerTestSuite) TestRunAppPreflights() {
327327 opts : RunAppPreflightOptions {
328328 PreflightBinaryPath : "/usr/bin/preflight" ,
329329 },
330- currentState : states .StateSucceeded ,
330+ currentState : states .StateInfrastructureInstalled ,
331331 expectedState : states .StateAppPreflightsSucceeded ,
332332 setupMocks : func (apm * apppreflightmanager.MockAppPreflightManager , arm * appreleasemanager.MockAppReleaseManager , acm * appconfig.MockAppConfigManager ) {
333333 mock .InOrder (
@@ -353,8 +353,8 @@ func (s *AppInstallControllerTestSuite) TestRunAppPreflights() {
353353 opts : RunAppPreflightOptions {
354354 PreflightBinaryPath : "/usr/bin/preflight" ,
355355 },
356- currentState : states .StateSucceeded ,
357- expectedState : states .StateSucceeded ,
356+ currentState : states .StateInfrastructureInstalled ,
357+ expectedState : states .StateInfrastructureInstalled ,
358358 setupMocks : func (apm * apppreflightmanager.MockAppPreflightManager , arm * appreleasemanager.MockAppReleaseManager , acm * appconfig.MockAppConfigManager ) {
359359 mock .InOrder (
360360 acm .On ("GetConfigValues" ).Return (types.AppConfigValues {"test-item" : types.AppConfigValue {Value : "test-value" }}, nil ),
@@ -368,7 +368,7 @@ func (s *AppInstallControllerTestSuite) TestRunAppPreflights() {
368368 opts : RunAppPreflightOptions {
369369 PreflightBinaryPath : "/usr/bin/preflight" ,
370370 },
371- currentState : states .StateSucceeded ,
371+ currentState : states .StateInfrastructureInstalled ,
372372 expectedState : states .StateAppPreflightsExecutionFailed ,
373373 setupMocks : func (apm * apppreflightmanager.MockAppPreflightManager , arm * appreleasemanager.MockAppReleaseManager , acm * appconfig.MockAppConfigManager ) {
374374 mock .InOrder (
@@ -501,11 +501,12 @@ func (s *AppInstallControllerTestSuite) TestGetAppInstallStatus() {
501501
502502func (s * AppInstallControllerTestSuite ) TestInstallApp () {
503503 tests := []struct {
504- name string
505- currentState statemachine.State
506- expectedState statemachine.State
507- setupMocks func (* appconfig.MockAppConfigManager , * appinstallmanager.MockAppInstallManager )
508- expectedErr bool
504+ name string
505+ ignoreAppPreflights bool
506+ currentState statemachine.State
507+ expectedState statemachine.State
508+ setupMocks func (* appconfig.MockAppConfigManager , * appinstallmanager.MockAppInstallManager )
509+ expectedErr bool
509510 }{
510511 {
511512 name : "invalid state transition from succeeded state" ,
@@ -574,6 +575,37 @@ func (s *AppInstallControllerTestSuite) TestInstallApp() {
574575 },
575576 expectedErr : true ,
576577 },
578+ {
579+ name : "successful app installation with failed preflights - ignored" ,
580+ ignoreAppPreflights : true ,
581+ currentState : states .StateAppPreflightsFailed ,
582+ expectedState : states .StateSucceeded ,
583+ setupMocks : func (acm * appconfig.MockAppConfigManager , aim * appinstallmanager.MockAppInstallManager ) {
584+ mock .InOrder (
585+ acm .On ("GetKotsadmConfigValues" ).Return (kotsv1beta1.ConfigValues {
586+ Spec : kotsv1beta1.ConfigValuesSpec {
587+ Values : map [string ]kotsv1beta1.ConfigValue {
588+ "test-key" : {Value : "test-value" },
589+ },
590+ },
591+ }, nil ),
592+ aim .On ("Install" , mock .Anything , mock .MatchedBy (func (cv kotsv1beta1.ConfigValues ) bool {
593+ return cv .Spec .Values ["test-key" ].Value == "test-value"
594+ })).Return (nil ),
595+ )
596+ },
597+ expectedErr : false ,
598+ },
599+ {
600+ name : "failed app installation with failed preflights - not ignored" ,
601+ ignoreAppPreflights : false ,
602+ currentState : states .StateAppPreflightsFailed ,
603+ expectedState : states .StateAppPreflightsFailed ,
604+ setupMocks : func (acm * appconfig.MockAppConfigManager , aim * appinstallmanager.MockAppInstallManager ) {
605+ // No mocks needed as method should return early with error
606+ },
607+ expectedErr : true ,
608+ },
577609 }
578610
579611 for _ , tt := range tests {
@@ -596,7 +628,7 @@ func (s *AppInstallControllerTestSuite) TestInstallApp() {
596628 require .NoError (t , err , "failed to create install controller" )
597629
598630 tt .setupMocks (appConfigManager , appInstallManager )
599- err = controller .InstallApp (t .Context ())
631+ err = controller .InstallApp (t .Context (), tt . ignoreAppPreflights )
600632
601633 if tt .expectedErr {
602634 assert .Error (t , err )
0 commit comments