@@ -392,6 +392,7 @@ var _ = Describe("WorkspaceController", func() {
392392 It ("pod rejection should result in a retry" , func () {
393393 ws := newWorkspace (uuid .NewString (), "default" )
394394 m := collectMetricCounts (wsMetrics , ws )
395+ su := collectSubscriberUpdates ()
395396
396397 // ### prepare block start
397398 By ("creating workspace" )
@@ -530,6 +531,8 @@ var _ = Describe("WorkspaceController", func() {
530531 starts : 1 , // this is NOT PodStarts, but merely an artifact of how we count it in the tests
531532 recreations : map [int ]int {1 : 1 },
532533 })
534+
535+ expectPhaseTransitions (su , []workspacev1.WorkspacePhase {workspacev1 .WorkspacePhasePending , workspacev1 .WorkspacePhaseCreating , workspacev1 .WorkspacePhaseInitializing , workspacev1 .WorkspacePhaseRunning })
533536 // ### validate end
534537 })
535538 })
@@ -1042,3 +1045,35 @@ func expectMetricsDelta(initial metricCounts, cur metricCounts, expectedDelta me
10421045 Expect (cur .restores - initial .restores ).To (Equal (expectedDelta .restores ), "expected metric count delta for restores" )
10431046 Expect (cur .restoreFailures - initial .restoreFailures ).To (Equal (expectedDelta .restoreFailures ), "expected metric count delta for restoreFailures" )
10441047}
1048+
1049+ type subscriberUpdates struct {
1050+ phaseTransitions []workspacev1.WorkspacePhase
1051+ }
1052+
1053+ func collectSubscriberUpdates () * subscriberUpdates {
1054+ su := subscriberUpdates {}
1055+ recordPhaseTransition := func (su * subscriberUpdates , ws * workspacev1.Workspace ) {
1056+ phase := ws .Status .Phase
1057+
1058+ var lastPhase workspacev1.WorkspacePhase
1059+ lenPhases := len (su .phaseTransitions )
1060+ if lenPhases > 0 {
1061+ lastPhase = su .phaseTransitions [lenPhases - 1 ]
1062+ }
1063+
1064+ if lastPhase != phase {
1065+ su .phaseTransitions = append (su .phaseTransitions , phase )
1066+ }
1067+ }
1068+
1069+ RegisterSubscriber (func (ws * workspacev1.Workspace ) {
1070+ recordPhaseTransition (& su , ws )
1071+ })
1072+ return & su
1073+ }
1074+
1075+ func expectPhaseTransitions (su * subscriberUpdates , expectation []workspacev1.WorkspacePhase ) {
1076+ GinkgoHelper ()
1077+ By ("checking recorded phase transitions" )
1078+ Expect (su .phaseTransitions ).To (HaveExactElements (expectation ), "expected list of recorded phase transitions" )
1079+ }
0 commit comments