t.Logf("wrote %s to etcd",resource.Mapping.Resource.GroupVersion().String())
// Ensure everyone gets a watch event with the right version
forwatchResource,watcher:=rangewatches{
select{
caseevent,ok:=<-watcher.ResultChan():
if!ok{
t.Fatalf("watch of %s closed in response to persisting %s",watchResource.GroupVersion().String(),resource.Mapping.Resource.GroupVersion().String())
}
ifevent.Type!=watch.Modified{
eventJSON,_:=json.Marshal(event)
t.Errorf("unexpected watch event sent to watch of %s in response to persisting %s: %s",watchResource.GroupVersion().String(),resource.Mapping.Resource.GroupVersion().String(),string(eventJSON))
t.Errorf("unexpected group version object sent to watch of %s in response to persisting %s: %#v",watchResource.GroupVersion().String(),resource.Mapping.Resource.GroupVersion().String(),event.Object)
continue
}
t.Logf(" received event for %s",watchResource.GroupVersion().String())
case<-time.After(30*time.Second):
t.Errorf("timed out waiting for watch event for %s in response to persisting %s",watchResource.GroupVersion().String(),resource.Mapping.Resource.GroupVersion().String())
continue
}
}
// Ensure everyone can do a direct get and gets the right version
forclientResource,client:=rangeclients{
obj,err:=client.Get(name,metav1.GetOptions{})
iferr!=nil{
t.Errorf("error looking up %s after persisting %s",clientResource.GroupVersion().String(),resource.Mapping.Resource.GroupVersion().String())
t.Errorf("unexpected group version retrieved from %s after persisting %s: %#v",clientResource.GroupVersion().String(),resource.Mapping.Resource.GroupVersion().String(),obj)
continue
}
t.Logf(" fetched object for %s",clientResource.GroupVersion().String())