@@ -31,6 +31,9 @@ var _ = ginkgo.Describe("ManifestWork Clients Test - Resync", func() {
3131 var clusterName string
3232 var workNamePrefix string
3333
34+ var work1UID , work2UID string
35+ var work1Name , work2Name string
36+
3437 ginkgo .BeforeEach (func () {
3538 ctx , cancel = context .WithCancel (context .Background ())
3639 sourceID = fmt .Sprintf ("mw-resync-%s" , rand .String (5 ))
@@ -45,17 +48,17 @@ var _ = ginkgo.Describe("ManifestWork Clients Test - Resync", func() {
4548 <- time .After (time .Second )
4649
4750 // add two works in the agent cache
48- work1Name : = fmt .Sprintf ("%s-1" , workNamePrefix )
49- work1UID : = utils .UID (sourceID , common .ManifestWorkGR .String (), clusterName , work1Name )
51+ work1Name = fmt .Sprintf ("%s-1" , workNamePrefix )
52+ work1UID = utils .UID (sourceID , common .ManifestWorkGR .String (), clusterName , work1Name )
5053 work1 := util .NewManifestWorkWithStatus (clusterName , work1Name )
5154 work1 .UID = apitypes .UID (work1UID )
5255 work1 .Generation = 1
5356 work1 .Labels = map [string ]string {common .CloudEventsOriginalSourceLabelKey : sourceID }
5457 work1 .Annotations = map [string ]string {common .CloudEventsDataTypeAnnotationKey : payload .ManifestBundleEventDataType .String ()}
5558 gomega .Expect (watchStore .Add (work1 )).ToNot (gomega .HaveOccurred ())
5659
57- work2Name : = fmt .Sprintf ("%s-2" , workNamePrefix )
58- work2UID : = utils .UID (sourceID , common .ManifestWorkGR .String (), clusterName , work2Name )
60+ work2Name = fmt .Sprintf ("%s-2" , workNamePrefix )
61+ work2UID = utils .UID (sourceID , common .ManifestWorkGR .String (), clusterName , work2Name )
5962 work2 := util .NewManifestWorkWithStatus (clusterName , work2Name )
6063 work2 .UID = apitypes .UID (work2UID )
6164 work2 .Generation = 1
@@ -77,12 +80,17 @@ var _ = ginkgo.Describe("ManifestWork Clients Test - Resync", func() {
7780 mqttOptions := util .NewMQTTSourceOptionsWithSourceBroadcast (mqttBrokerHost , sourceID )
7881
7982 // simulate a source client restart, recover two existed works
83+ ginkgo .By ("start the source client with two works" )
84+ work1 := util .NewManifestWork (clusterName , work1Name , true )
85+ work1 .UID = apitypes .UID (work1UID )
86+ work2 := util .NewManifestWork (clusterName , work2Name , true )
87+ work2 .UID = apitypes .UID (work2UID )
8088 sourceClientHolder , _ , err := source .StartManifestWorkSourceClient (
8189 ctx ,
8290 sourceID ,
8391 mqttOptions ,
84- util . NewManifestWork ( clusterName , fmt . Sprintf ( "%s-1" , workNamePrefix ), true ) ,
85- util . NewManifestWork ( clusterName , fmt . Sprintf ( "%s-2" , workNamePrefix ), true ) ,
92+ work1 ,
93+ work2 ,
8694 )
8795 gomega .Expect (err ).ToNot (gomega .HaveOccurred ())
8896
0 commit comments