From efe5e4fc6d289ddf8bfb592fd27571a5ef823bfa Mon Sep 17 00:00:00 2001 From: jonjohnsonjr Date: Tue, 24 Jul 2018 18:41:34 -0700 Subject: [PATCH] Add more service status propagation tests (#1627) * Add more service status propagation tests This breaks out recovery from the TypicalServiceFlow into the happy path, route recovery, and configuration recovery. Fixes #1224 * Add failure recovery for route and config Since they are likely to fail together, we test that we can recover from both route and config failing then becoming ready. --- .../serving/v1alpha1/service_types_test.go | 118 +++++++++++++++++- 1 file changed, 115 insertions(+), 3 deletions(-) diff --git a/pkg/apis/serving/v1alpha1/service_types_test.go b/pkg/apis/serving/v1alpha1/service_types_test.go index 9a5f5203aaa4..f779cea4913d 100644 --- a/pkg/apis/serving/v1alpha1/service_types_test.go +++ b/pkg/apis/serving/v1alpha1/service_types_test.go @@ -188,7 +188,7 @@ func TestServiceConditions(t *testing.T) { } } -func TestTypicalServiceFlow(t *testing.T) { +func TestServiceHappyPath(t *testing.T) { svc := &Service{} svc.Status.InitializeConditions() checkConditionOngoingService(svc.Status, ServiceConditionReady, t) @@ -239,8 +239,27 @@ func TestTypicalServiceFlow(t *testing.T) { checkConditionSucceededService(svc.Status, ServiceConditionReady, t) checkConditionSucceededService(svc.Status, ServiceConditionConfigurationsReady, t) checkConditionSucceededService(svc.Status, ServiceConditionRoutesReady, t) +} - // Failure causes us to become unready immediately (config still ok). +func TestFailureRecovery(t *testing.T) { + svc := &Service{} + svc.Status.InitializeConditions() + checkConditionOngoingService(svc.Status, ServiceConditionReady, t) + checkConditionOngoingService(svc.Status, ServiceConditionConfigurationsReady, t) + checkConditionOngoingService(svc.Status, ServiceConditionRoutesReady, t) + + // Config failure causes us to become unready immediately (route still ok). + svc.Status.PropagateConfigurationStatus(ConfigurationStatus{ + Conditions: []ConfigurationCondition{{ + Type: ConfigurationConditionReady, + Status: corev1.ConditionFalse, + }}, + }) + checkConditionFailedService(svc.Status, ServiceConditionReady, t) + checkConditionFailedService(svc.Status, ServiceConditionConfigurationsReady, t) + checkConditionOngoingService(svc.Status, ServiceConditionRoutesReady, t) + + // Route failure causes route to become failed (config and service still failed). svc.Status.PropagateRouteStatus(RouteStatus{ Conditions: []RouteCondition{{ Type: RouteConditionReady, @@ -248,10 +267,21 @@ func TestTypicalServiceFlow(t *testing.T) { }}, }) checkConditionFailedService(svc.Status, ServiceConditionReady, t) + checkConditionFailedService(svc.Status, ServiceConditionConfigurationsReady, t) + checkConditionFailedService(svc.Status, ServiceConditionRoutesReady, t) + + // Fix Configuration moves our ConfigurationsReady condition (route and service still failed). + svc.Status.PropagateConfigurationStatus(ConfigurationStatus{ + Conditions: []ConfigurationCondition{{ + Type: ConfigurationConditionReady, + Status: corev1.ConditionTrue, + }}, + }) + checkConditionFailedService(svc.Status, ServiceConditionReady, t) checkConditionSucceededService(svc.Status, ServiceConditionConfigurationsReady, t) checkConditionFailedService(svc.Status, ServiceConditionRoutesReady, t) - // Fixed the glitch. + // Fix route, should make everything ready. svc.Status.PropagateRouteStatus(RouteStatus{ Conditions: []RouteCondition{{ Type: RouteConditionReady, @@ -282,6 +312,47 @@ func TestConfigurationFailurePropagation(t *testing.T) { checkConditionOngoingService(svc.Status, ServiceConditionRoutesReady, t) } +func TestConfigurationFailureRecovery(t *testing.T) { + svc := &Service{} + svc.Status.InitializeConditions() + checkConditionOngoingService(svc.Status, ServiceConditionReady, t) + checkConditionOngoingService(svc.Status, ServiceConditionConfigurationsReady, t) + checkConditionOngoingService(svc.Status, ServiceConditionRoutesReady, t) + + // Done from Route moves our RoutesReady condition + svc.Status.PropagateRouteStatus(RouteStatus{ + Conditions: []RouteCondition{{ + Type: RouteConditionReady, + Status: corev1.ConditionTrue, + }}, + }) + checkConditionOngoingService(svc.Status, ServiceConditionReady, t) + checkConditionOngoingService(svc.Status, ServiceConditionConfigurationsReady, t) + checkConditionSucceededService(svc.Status, ServiceConditionRoutesReady, t) + + // Failure causes us to become unready immediately (route still ok). + svc.Status.PropagateConfigurationStatus(ConfigurationStatus{ + Conditions: []ConfigurationCondition{{ + Type: ConfigurationConditionReady, + Status: corev1.ConditionFalse, + }}, + }) + checkConditionFailedService(svc.Status, ServiceConditionReady, t) + checkConditionFailedService(svc.Status, ServiceConditionConfigurationsReady, t) + checkConditionSucceededService(svc.Status, ServiceConditionRoutesReady, t) + + // Fixed the glitch. + svc.Status.PropagateConfigurationStatus(ConfigurationStatus{ + Conditions: []ConfigurationCondition{{ + Type: ConfigurationConditionReady, + Status: corev1.ConditionTrue, + }}, + }) + checkConditionSucceededService(svc.Status, ServiceConditionReady, t) + checkConditionSucceededService(svc.Status, ServiceConditionConfigurationsReady, t) + checkConditionSucceededService(svc.Status, ServiceConditionRoutesReady, t) +} + func TestConfigurationUnknownPropagation(t *testing.T) { svc := &Service{} svc.Status.InitializeConditions() @@ -355,6 +426,47 @@ func TestRouteFailurePropagation(t *testing.T) { checkConditionFailedService(svc.Status, ServiceConditionRoutesReady, t) } +func TestRouteFailureRecovery(t *testing.T) { + svc := &Service{} + svc.Status.InitializeConditions() + checkConditionOngoingService(svc.Status, ServiceConditionReady, t) + checkConditionOngoingService(svc.Status, ServiceConditionConfigurationsReady, t) + checkConditionOngoingService(svc.Status, ServiceConditionRoutesReady, t) + + // Done from Configuration moves our ConfigurationsReady condition + svc.Status.PropagateConfigurationStatus(ConfigurationStatus{ + Conditions: []ConfigurationCondition{{ + Type: ConfigurationConditionReady, + Status: corev1.ConditionTrue, + }}, + }) + checkConditionOngoingService(svc.Status, ServiceConditionReady, t) + checkConditionSucceededService(svc.Status, ServiceConditionConfigurationsReady, t) + checkConditionOngoingService(svc.Status, ServiceConditionRoutesReady, t) + + // Failure causes us to become unready immediately (config still ok). + svc.Status.PropagateRouteStatus(RouteStatus{ + Conditions: []RouteCondition{{ + Type: RouteConditionReady, + Status: corev1.ConditionFalse, + }}, + }) + checkConditionFailedService(svc.Status, ServiceConditionReady, t) + checkConditionSucceededService(svc.Status, ServiceConditionConfigurationsReady, t) + checkConditionFailedService(svc.Status, ServiceConditionRoutesReady, t) + + // Fixed the glitch. + svc.Status.PropagateRouteStatus(RouteStatus{ + Conditions: []RouteCondition{{ + Type: RouteConditionReady, + Status: corev1.ConditionTrue, + }}, + }) + checkConditionSucceededService(svc.Status, ServiceConditionReady, t) + checkConditionSucceededService(svc.Status, ServiceConditionConfigurationsReady, t) + checkConditionSucceededService(svc.Status, ServiceConditionRoutesReady, t) +} + func TestRouteUnknownPropagation(t *testing.T) { svc := &Service{} svc.Status.InitializeConditions()