@@ -2471,6 +2471,25 @@ func TestGetBookmarkAfterResourceVersionLockedFunc(t *testing.T) {
2471
2471
}
2472
2472
2473
2473
func TestWatchStreamSeparation (t * testing.T ) {
2474
+ server , etcdStorage := newEtcdTestStorage (t , etcd3testing .PathPrefix ())
2475
+ t .Cleanup (func () {
2476
+ server .Terminate (t )
2477
+ })
2478
+ setupOpts := & setupOptions {}
2479
+ withDefaults (setupOpts )
2480
+ config := Config {
2481
+ Storage : etcdStorage ,
2482
+ Versioner : storage.APIObjectVersioner {},
2483
+ GroupResource : schema.GroupResource {Resource : "pods" },
2484
+ ResourcePrefix : setupOpts .resourcePrefix ,
2485
+ KeyFunc : setupOpts .keyFunc ,
2486
+ GetAttrsFunc : GetPodAttrs ,
2487
+ NewFunc : newPod ,
2488
+ NewListFunc : newPodList ,
2489
+ IndexerFuncs : setupOpts .indexerFuncs ,
2490
+ Codec : codecs .LegacyCodec (examplev1 .SchemeGroupVersion ),
2491
+ Clock : setupOpts .clock ,
2492
+ }
2474
2493
tcs := []struct {
2475
2494
name string
2476
2495
separateCacheWatchRPC bool
@@ -2508,8 +2527,10 @@ func TestWatchStreamSeparation(t *testing.T) {
2508
2527
for _ , tc := range tcs {
2509
2528
t .Run (tc .name , func (t * testing.T ) {
2510
2529
featuregatetesting .SetFeatureGateDuringTest (t , utilfeature .DefaultFeatureGate , features .SeparateCacheWatchRPC , tc .separateCacheWatchRPC )
2511
- _ , cacher , _ , terminate := testSetupWithEtcdServer (t )
2512
- t .Cleanup (terminate )
2530
+ cacher , err := NewCacherFromConfig (config )
2531
+ if err != nil {
2532
+ t .Fatalf ("Failed to initialize cacher: %v" , err )
2533
+ }
2513
2534
2514
2535
if ! utilfeature .DefaultFeatureGate .Enabled (features .ResilientWatchCacheInitialization ) {
2515
2536
if err := cacher .ready .wait (context .TODO ()); err != nil {
@@ -2527,7 +2548,11 @@ func TestWatchStreamSeparation(t *testing.T) {
2527
2548
waitForEtcdBookmark := watchAndWaitForBookmark (t , waitContext , cacher .storage )
2528
2549
2529
2550
var out example.Pod
2530
- err := cacher .Create (context .Background (), "foo" , & example.Pod {}, & out , 0 )
2551
+ err = cacher .Create (context .Background (), "foo" , & example.Pod {}, & out , 0 )
2552
+ if err != nil {
2553
+ t .Fatal (err )
2554
+ }
2555
+ err = cacher .Delete (context .Background (), "foo" , & out , nil , storage .ValidateAllObjectFunc , & example.Pod {})
2531
2556
if err != nil {
2532
2557
t .Fatal (err )
2533
2558
}
0 commit comments