Skip to content

Commit

Permalink
Add more service status propagation tests (knative#1627)
Browse files Browse the repository at this point in the history
* Add more service status propagation tests

This breaks out recovery from the TypicalServiceFlow into the happy
path, route recovery, and configuration recovery.

Fixes knative#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.
  • Loading branch information
jonjohnsonjr authored and Zhimin Xiang committed Aug 2, 2018
1 parent 0405fc8 commit efe5e4f
Showing 1 changed file with 115 additions and 3 deletions.
118 changes: 115 additions & 3 deletions pkg/apis/serving/v1alpha1/service_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -239,19 +239,49 @@ 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,
Status: corev1.ConditionFalse,
}},
})
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,
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit efe5e4f

Please sign in to comment.