@@ -990,3 +990,38 @@ func TestRCSyncExpectations(t *testing.T) {
990
990
manager .syncReplicationController (getKey (controllerSpec , t ))
991
991
validateSyncReplication (t , & fakePodControl , 0 , 0 )
992
992
}
993
+
994
+ func TestDeleteControllerAndExpectations (t * testing.T ) {
995
+ client := client .NewOrDie (& client.Config {Host : "" , Version : testapi .Version ()})
996
+ manager := NewReplicationManager (client , 10 )
997
+
998
+ rc := newReplicationController (1 )
999
+ manager .controllerStore .Store .Add (rc )
1000
+
1001
+ fakePodControl := FakePodControl {}
1002
+ manager .podControl = & fakePodControl
1003
+
1004
+ // This should set expectations for the rc
1005
+ manager .syncReplicationController (getKey (rc , t ))
1006
+ validateSyncReplication (t , & fakePodControl , 1 , 0 )
1007
+ fakePodControl .clear ()
1008
+
1009
+ // This is to simulate a concurrent addPod, that has a handle on the expectations
1010
+ // as the controller deletes it.
1011
+ podExp , exists , err := manager .expectations .GetExpectations (rc )
1012
+ if ! exists || err != nil {
1013
+ t .Errorf ("No expectations found for rc" )
1014
+ }
1015
+ manager .controllerStore .Delete (rc )
1016
+ manager .syncReplicationController (getKey (rc , t ))
1017
+
1018
+ if _ , exists , err = manager .expectations .GetExpectations (rc ); exists {
1019
+ t .Errorf ("Found expectaions, expected none since the rc has been deleted." )
1020
+ }
1021
+
1022
+ // This should have no effect, since we've deleted the rc.
1023
+ podExp .Seen (1 , 0 )
1024
+ manager .podStore .Store .Replace (make ([]interface {}, 0 ))
1025
+ manager .syncReplicationController (getKey (rc , t ))
1026
+ validateSyncReplication (t , & fakePodControl , 0 , 0 )
1027
+ }
0 commit comments