How to use GetClient method of client Package

Best Testkube code snippet using client.GetClient

basic_test.go

Source:basic_test.go Github

copy

Full Screen

...14 AfterEach(func() {15 sc.Kill()16 })17 It("should handle entry put and get.", func() {18 sc.GetClient(0).Put(MakePutFreshEntry("k0", []byte("v0")))19 res := sc.GetClient(0).Get("k0")20 Expect(res).NotTo(BeNil())21 Expect(GetEntryValues(res)).To(ConsistOf([][]byte{22 []byte("v0"),23 }))24 })25 It("should handle entry put, get, and update.", func() {26 sc.GetClient(0).Put(MakePutFreshEntry("k0", []byte("v0")))27 entry := sc.GetClient(0).Get("k0").EntryList[0]28 entry.Value = []byte("v0-1")29 sc.GetClient(0).Put(MakePutFromEntry("k0", entry))30 res := sc.GetClient(0).Get("k0")31 Expect(res).NotTo(BeNil())32 Expect(GetEntryValues(res)).To(ConsistOf([][]byte{33 []byte("v0-1"),34 }))35 })36 It("should handle non-existent entry(key) get.", func() {37 res := sc.GetClient(0).Get("k0")38 Expect(res).NotTo(BeNil())39 Expect(GetEntryValues(res)).To(ConsistOf([][]byte{}))40 })41 It("should ignore put with ancestor context.", func() {42 // Spec: If the context that the Node has already stored associated with the43 // specified key is causally descended from the context provided to Put, i.e44 // newContext < oldContext, Put will fail and the existing value will remain.45 sc.GetClient(0).Put(MakePutFreshEntry("k0", []byte("v0")))46 entry := sc.GetClient(0).Get("k0").EntryList[0]47 entry.Value = []byte("v0-1")48 sc.GetClient(0).Put(MakePutFromEntry("k0", entry))49 // Put a new value with the same key but new context50 sc.GetClient(0).Put(MakePutFreshEntry("k0", []byte("v1")))51 res := sc.GetClient(0).Get("k0")52 Expect(res).NotTo(BeNil())53 Expect(GetEntryValues(res)).To(ConsistOf([][]byte{54 []byte("v0-1"),55 }))56 })57 It("should ignore put with equal context.", func() {58 sc.GetClient(0).Put(MakePutFreshEntry("k0", []byte("v0")))59 entry := sc.GetClient(0).Get("k0").EntryList[0]60 entry.Value = []byte("v0-1")61 sc.GetClient(0).Put(MakePutFromEntry("k0", entry))62 // Put a new value with the same key but context from previous get63 entry.Value = []byte("v0-2")64 sc.GetClient(0).Put(MakePutFromEntry("k0", entry))65 res := sc.GetClient(0).Get("k0")66 Expect(res).NotTo(BeNil())67 Expect(GetEntryValues(res)).To(ConsistOf([][]byte{68 []byte("v0-1"),69 }))70 })71 })72 Describe("Two servers", func() {73 var sc ServerCoordinator74 BeforeEach(func() {75 // StartingPort: 8000, R-Value: 1, W-Value: 1, ClusterSize: 176 sc = NewServerCoordinator(8000+config.GinkgoConfig.ParallelNode*100, 1, 1, 2)77 })78 AfterEach(func() {79 sc.Kill()80 })81 It("should handle entry put and get without interfering each other (same key).", func() {82 sc.GetClient(0).Put(MakePutFreshEntry("k0", []byte("v0-s0")))83 sc.GetClient(1).Put(MakePutFreshEntry("k0", []byte("v0-s1")))84 res0 := sc.GetClient(0).Get("k0")85 Expect(res0).NotTo(BeNil())86 Expect(GetEntryValues(res0)).To(ConsistOf([][]byte{87 []byte("v0-s0"),88 }))89 res1 := sc.GetClient(1).Get("k0")90 Expect(res1).NotTo(BeNil())91 Expect(GetEntryValues(res1)).To(ConsistOf([][]byte{92 []byte("v0-s1"),93 }))94 })95 It("should handle entry put and get without interfering each other (different keys).", func() {96 sc.GetClient(0).Put(MakePutFreshEntry("k0", []byte("v0-s0")))97 sc.GetClient(1).Put(MakePutFreshEntry("k1", []byte("v1-s1")))98 res0 := sc.GetClient(0).Get("k0")99 Expect(res0).NotTo(BeNil())100 Expect(GetEntryValues(res0)).To(ConsistOf([][]byte{101 []byte("v0-s0"),102 }))103 res1 := sc.GetClient(1).Get("k1")104 Expect(res1).NotTo(BeNil())105 Expect(GetEntryValues(res1)).To(ConsistOf([][]byte{106 []byte("v1-s1"),107 }))108 })109 It("should handle entry put, get, and update without interfering each other.", func() {110 sc.GetClient(0).Put(MakePutFreshEntry("k0", []byte("v0-s0")))111 sc.GetClient(1).Put(MakePutFreshEntry("k1", []byte("v1-s1")))112 // Update entry with key "k0" on server-0113 entry := sc.GetClient(0).Get("k0").EntryList[0]114 entry.Value = []byte("v0-s0-1")115 sc.GetClient(0).Put(MakePutFromEntry("k0", entry))116 res0 := sc.GetClient(0).Get("k0")117 Expect(res0).NotTo(BeNil())118 Expect(GetEntryValues(res0)).To(ConsistOf([][]byte{119 []byte("v0-s0-1"),120 }))121 res1 := sc.GetClient(1).Get("k1")122 Expect(res1).NotTo(BeNil())123 Expect(GetEntryValues(res1)).To(ConsistOf([][]byte{124 []byte("v1-s1"),125 }))126 })127 Context("when put and get conflict entries", func() {128 It("should handle put and get conflict entries.", func() {129 sc.GetClient(0).Put(MakePutFreshEntry("k0", []byte("v0-s0")))130 sc.GetClient(1).Put(MakePutFreshEntry("k0", []byte("v0-s1")))131 // Get entry from server-0, update it, and put it back to server-0132 entry := sc.GetClient(0).Get("k0").EntryList[0]133 entry.Value = []byte("v0-s0-1")134 sc.GetClient(0).Put(MakePutFromEntry("k0", entry))135 // Get entry from server-1, update it, and put to server-0136 entry = sc.GetClient(1).Get("k0").EntryList[0]137 entry.Value = []byte("v0-s1-1")138 sc.GetClient(0).Put(MakePutFromEntry("k0", entry))139 res0 := sc.GetClient(0).Get("k0")140 Expect(res0).NotTo(BeNil())141 Expect(GetEntryValues(res0)).To(ConsistOf([][]byte{142 []byte("v0-s0-1"), // Original value143 []byte("v0-s1-1"), // Conflict value144 }))145 })146 It("should handle put and get conflict entries with same value.", func() {147 sc.GetClient(0).Put(MakePutFreshEntry("k0", []byte("v0-s0")))148 sc.GetClient(1).Put(MakePutFreshEntry("k0", []byte("v0-s1")))149 // Get entry from server-0, update it, and put it back to server-0150 entry := sc.GetClient(0).Get("k0").EntryList[0]151 entry.Value = []byte("v0-s0-1")152 sc.GetClient(0).Put(MakePutFromEntry("k0", entry))153 // Get entry from server-1, update it, and put to server-0154 entry = sc.GetClient(1).Get("k0").EntryList[0]155 entry.Value = []byte("v0-s0-1")156 sc.GetClient(0).Put(MakePutFromEntry("k0", entry))157 res0 := sc.GetClient(0).Get("k0")158 Expect(res0).NotTo(BeNil())159 Expect(GetEntryValues(res0)).To(ConsistOf([][]byte{160 []byte("v0-s0-1"), // Original value161 []byte("v0-s0-1"), // Duplicated value with different context162 }))163 })164 It("should handle put and get conflict entry with same context.", func() {165 // Reference:166 // - https://piazza.com/class/kfqynl4r6a0317?cid=969167 sc.GetClient(0).Put(MakePutFreshEntry("k0", []byte("v0-s0")))168 // Get entry from server-0, update it, and put it back to server-0169 entry := sc.GetClient(0).Get("k0").EntryList[0]170 entry.Value = []byte("v0-s0-1")171 sc.GetClient(0).Put(MakePutFromEntry("k0", entry))172 // Update the same entry previously get, and put it to server-0 again173 entry.Value = []byte("v0-s0-2")174 sc.GetClient(0).Put(MakePutFromEntry("k0", entry))175 res0 := sc.GetClient(0).Get("k0")176 Expect(res0).NotTo(BeNil())177 Expect(GetEntryValues(res0)).To(ConsistOf([][]byte{178 []byte("v0-s0-1"), // Should only keep the original value179 }))180 })181 It("should resolve conflicts by keeping entries with descendant context (1).", func() {182 sc.GetClient(0).Put(MakePutFreshEntry("k0", []byte("v0-s0")))183 sc.GetClient(1).Put(MakePutFreshEntry("k0", []byte("v0-s1")))184 // Get entry from server-0, update it, and put it back to server-0185 entry := sc.GetClient(0).Get("k0").EntryList[0]186 entry.Value = []byte("v0-s0-1")187 sc.GetClient(0).Put(MakePutFromEntry("k0", entry))188 // Get entry from server-1, update it, and put to server-0189 entry = sc.GetClient(1).Get("k0").EntryList[0]190 entry.Value = []byte("v0-s1-1")191 sc.GetClient(0).Put(MakePutFromEntry("k0", entry))192 // The result from server-0 here should have multiple conflict entries193 // Put the entry to server-0 with new value and combined context194 res0 := sc.GetClient(0).Get("k0")195 entry = res0.EntryList[0]196 entry.Context.Clock.Combine(GetEntryContextClocks(res0))197 entry.Value = []byte("v0-s0-2")198 sc.GetClient(0).Put(MakePutFromEntry("k0", entry))199 res0 = sc.GetClient(0).Get("k0")200 Expect(res0).NotTo(BeNil())201 Expect(GetEntryValues(res0)).To(ConsistOf([][]byte{202 []byte("v0-s0-2"),203 }))204 })205 It("should resolve conflicts by keeping entries with descendant context (2).", func() {206 sc.GetClient(0).Put(MakePutFreshEntry("k0", []byte("v0-s0")))207 sc.GetClient(1).Put(MakePutFreshEntry("k0", []byte("v0-s1")))208 // Get entry from server-0, update it, and put it back to server-0209 entry := sc.GetClient(0).Get("k0").EntryList[0]210 entry.Value = []byte("v0-s0-1")211 sc.GetClient(0).Put(MakePutFromEntry("k0", entry))212 // Get entry from server-1, update it, and put to server-0213 entry = sc.GetClient(1).Get("k0").EntryList[0]214 entry.Value = []byte("v0-s1-1")215 sc.GetClient(0).Put(MakePutFromEntry("k0", entry))216 // Get entry from server-1, update it, and put it back to server-1217 entry = sc.GetClient(1).Get("k0").EntryList[0]218 entry.Value = []byte("v0-s1-2")219 sc.GetClient(1).Put(MakePutFromEntry("k0", entry))220 // Get the entries from server-0 and server-1, combine their contexts, and put to server-0 with new value221 res0 := sc.GetClient(0).Get("k0")222 res1 := sc.GetClient(1).Get("k0")223 entry = res0.EntryList[0]224 entry.Context.Clock.Combine(GetEntryContextClocks(res0))225 entry.Context.Clock.Combine(GetEntryContextClocks(res1))226 entry.Value = []byte("v0-s0-3")227 sc.GetClient(0).Put(MakePutFromEntry("k0", entry))228 res0 = sc.GetClient(0).Get("k0")229 Expect(res0).NotTo(BeNil())230 Expect(GetEntryValues(res0)).To(ConsistOf([][]byte{231 []byte("v0-s0-3"),232 }))233 })234 })235 })236 Describe("Three servers", func() {237 var sc ServerCoordinator238 BeforeEach(func() {239 sc = NewServerCoordinator(8000+config.GinkgoConfig.ParallelNode*100, 1, 1, 3)240 })241 AfterEach(func() {242 sc.Kill()243 })244 It("should handle entry put and get without interfering each other (same key).", func() {245 sc.GetClient(0).Put(MakePutFreshEntry("k0", []byte("v0-s0")))246 sc.GetClient(1).Put(MakePutFreshEntry("k0", []byte("v0-s1")))247 sc.GetClient(2).Put(MakePutFreshEntry("k0", []byte("v0-s2")))248 res0 := sc.GetClient(0).Get("k0")249 Expect(res0).NotTo(BeNil())250 Expect(GetEntryValues(res0)).To(ConsistOf([][]byte{251 []byte("v0-s0"),252 }))253 res1 := sc.GetClient(1).Get("k0")254 Expect(res1).NotTo(BeNil())255 Expect(GetEntryValues(res1)).To(ConsistOf([][]byte{256 []byte("v0-s1"),257 }))258 res2 := sc.GetClient(2).Get("k0")259 Expect(res2).NotTo(BeNil())260 Expect(GetEntryValues(res2)).To(ConsistOf([][]byte{261 []byte("v0-s2"),262 }))263 })264 It("should handle entry put and get without interfering each other (different keys).", func() {265 sc.GetClient(0).Put(MakePutFreshEntry("k0", []byte("v0-s0")))266 sc.GetClient(1).Put(MakePutFreshEntry("k1", []byte("v1-s1")))267 sc.GetClient(2).Put(MakePutFreshEntry("k2", []byte("v2-s2")))268 res0 := sc.GetClient(0).Get("k0")269 Expect(res0).NotTo(BeNil())270 Expect(GetEntryValues(res0)).To(ConsistOf([][]byte{271 []byte("v0-s0"),272 }))273 res1 := sc.GetClient(1).Get("k1")274 Expect(res1).NotTo(BeNil())275 Expect(GetEntryValues(res1)).To(ConsistOf([][]byte{276 []byte("v1-s1"),277 }))278 res2 := sc.GetClient(2).Get("k2")279 Expect(res2).NotTo(BeNil())280 Expect(GetEntryValues(res2)).To(ConsistOf([][]byte{281 []byte("v2-s2"),282 }))283 })284 It("should handle entry put, get, and update without interfering each other.", func() {285 sc.GetClient(0).Put(MakePutFreshEntry("k0", []byte("v0-s0")))286 sc.GetClient(1).Put(MakePutFreshEntry("k1", []byte("v1-s1")))287 sc.GetClient(2).Put(MakePutFreshEntry("k2", []byte("v2-s2")))288 // Update entry with key "k0" on server-0289 entry := sc.GetClient(0).Get("k0").EntryList[0]290 entry.Value = []byte("v0-s0-1")291 sc.GetClient(0).Put(MakePutFromEntry("k0", entry))292 res0 := sc.GetClient(0).Get("k0")293 Expect(res0).NotTo(BeNil())294 Expect(GetEntryValues(res0)).To(ConsistOf([][]byte{295 []byte("v0-s0-1"),296 }))297 res1 := sc.GetClient(1).Get("k1")298 Expect(res1).NotTo(BeNil())299 Expect(GetEntryValues(res1)).To(ConsistOf([][]byte{300 []byte("v1-s1"),301 }))302 res2 := sc.GetClient(2).Get("k2")303 Expect(res2).NotTo(BeNil())304 Expect(GetEntryValues(res2)).To(ConsistOf([][]byte{305 []byte("v2-s2"),306 }))307 })308 Context("when put and get conflict entries", func() {309 It("should handle put and get conflict entries.", func() {310 sc.GetClient(0).Put(MakePutFreshEntry("k0", []byte("v0-s0")))311 sc.GetClient(1).Put(MakePutFreshEntry("k0", []byte("v0-s1")))312 sc.GetClient(2).Put(MakePutFreshEntry("k0", []byte("v0-s2")))313 // Get entry from server-0, update it, and put it back to server-0314 entry := sc.GetClient(0).Get("k0").EntryList[0]315 entry.Value = []byte("v0-s0-1")316 sc.GetClient(0).Put(MakePutFromEntry("k0", entry))317 // Get entry from server-1, update it, and put to server-0318 entry = sc.GetClient(1).Get("k0").EntryList[0]319 entry.Value = []byte("v0-s1-1")320 sc.GetClient(0).Put(MakePutFromEntry("k0", entry))321 // Get entry from server-2, update it, and put to server-0322 entry = sc.GetClient(2).Get("k0").EntryList[0]323 entry.Value = []byte("v0-s2-1")324 sc.GetClient(0).Put(MakePutFromEntry("k0", entry))325 res0 := sc.GetClient(0).Get("k0")326 Expect(res0).NotTo(BeNil())327 Expect(GetEntryValues(res0)).To(ConsistOf([][]byte{328 []byte("v0-s0-1"), // Original value329 []byte("v0-s1-1"), // Conflict value330 []byte("v0-s2-1"), // Conflict value331 }))332 })333 It("should handle put and get conflict entries with same value.", func() {334 sc.GetClient(0).Put(MakePutFreshEntry("k0", []byte("v0-s0")))335 sc.GetClient(1).Put(MakePutFreshEntry("k0", []byte("v0-s1")))336 sc.GetClient(2).Put(MakePutFreshEntry("k0", []byte("v0-s2")))337 // Get entry from server-0, update it, and put it back to server-0338 entry := sc.GetClient(0).Get("k0").EntryList[0]339 entry.Value = []byte("v0-s0-1")340 sc.GetClient(0).Put(MakePutFromEntry("k0", entry))341 // Get entry from server-1, update it, and put to server-0342 entry = sc.GetClient(1).Get("k0").EntryList[0]343 entry.Value = []byte("v0-s0-1")344 sc.GetClient(0).Put(MakePutFromEntry("k0", entry))345 // Get entry from server-2, update it, and put to server-0346 entry = sc.GetClient(2).Get("k0").EntryList[0]347 entry.Value = []byte("v0-s0-1")348 sc.GetClient(0).Put(MakePutFromEntry("k0", entry))349 res0 := sc.GetClient(0).Get("k0")350 Expect(res0).NotTo(BeNil())351 Expect(GetEntryValues(res0)).To(ConsistOf([][]byte{352 []byte("v0-s0-1"), // Original value353 []byte("v0-s0-1"), // Duplicated value with different context354 []byte("v0-s0-1"), // Duplicated value with different context355 }))356 })357 It("should resolve conflicts by keeping entries with descendant context (1).", func() {358 sc.GetClient(0).Put(MakePutFreshEntry("k0", []byte("v0-s0")))359 sc.GetClient(1).Put(MakePutFreshEntry("k0", []byte("v0-s1")))360 sc.GetClient(2).Put(MakePutFreshEntry("k0", []byte("v0-s2")))361 // Get entry from server-0, update it, and put it back to server-0362 entry := sc.GetClient(0).Get("k0").EntryList[0]363 entry.Value = []byte("v0-s0-1")364 sc.GetClient(0).Put(MakePutFromEntry("k0", entry))365 // Get entry from server-1, update it, and put to server-0366 entry = sc.GetClient(1).Get("k0").EntryList[0]367 entry.Value = []byte("v0-s1-1")368 sc.GetClient(0).Put(MakePutFromEntry("k0", entry))369 // Get entry from server-2, update it, and put to server-0370 entry = sc.GetClient(1).Get("k0").EntryList[0]371 entry.Value = []byte("v0-s2-1")372 sc.GetClient(0).Put(MakePutFromEntry("k0", entry))373 // The result from server-0 here should have multiple conflict entries374 // Put the entry to server-0 with new value and combined context375 res0 := sc.GetClient(0).Get("k0")376 entry = res0.EntryList[0]377 entry.Context.Clock.Combine(GetEntryContextClocks(res0))378 entry.Value = []byte("v0-s0-2")379 sc.GetClient(0).Put(MakePutFromEntry("k0", entry))380 res0 = sc.GetClient(0).Get("k0")381 Expect(res0).NotTo(BeNil())382 Expect(GetEntryValues(res0)).To(ConsistOf([][]byte{383 []byte("v0-s0-2"),384 }))385 })386 It("should resolve conflicts by keeping entries with descendant context (2).", func() {387 sc.GetClient(0).Put(MakePutFreshEntry("k0", []byte("v0-s0")))388 sc.GetClient(1).Put(MakePutFreshEntry("k0", []byte("v0-s1")))389 sc.GetClient(2).Put(MakePutFreshEntry("k0", []byte("v0-s2")))390 // Get entry from server-0, update it, and put it back to server-0391 entry := sc.GetClient(0).Get("k0").EntryList[0]392 entry.Value = []byte("v0-s0-1")393 sc.GetClient(0).Put(MakePutFromEntry("k0", entry))394 // Get entry from server-1, update it, and put to server-0395 entry = sc.GetClient(1).Get("k0").EntryList[0]396 entry.Value = []byte("v0-s1-1")397 sc.GetClient(0).Put(MakePutFromEntry("k0", entry))398 // Get entry from server-1, update it, and put it back to server-1399 entry = sc.GetClient(1).Get("k0").EntryList[0]400 entry.Value = []byte("v0-s1-2")401 sc.GetClient(1).Put(MakePutFromEntry("k0", entry))402 // Get entry from server-2, update it, and put to server-0403 entry = sc.GetClient(2).Get("k0").EntryList[0]404 entry.Value = []byte("v0-s2-1")405 sc.GetClient(0).Put(MakePutFromEntry("k0", entry))406 // Get entry from server-2, update it, and put it back to server-2407 entry = sc.GetClient(2).Get("k0").EntryList[0]408 entry.Value = []byte("v0-s2-2")409 sc.GetClient(1).Put(MakePutFromEntry("k0", entry))410 // Get the entries from server-0 ,server-1, and server-2, combine their contexts, and put to server-0 with new value411 res0 := sc.GetClient(0).Get("k0")412 res1 := sc.GetClient(1).Get("k0")413 res2 := sc.GetClient(2).Get("k0")414 entry = res0.EntryList[0]415 entry.Context.Clock.Combine(GetEntryContextClocks(res0))416 entry.Context.Clock.Combine(GetEntryContextClocks(res1))417 entry.Context.Clock.Combine(GetEntryContextClocks(res2))418 entry.Value = []byte("v0-s0-3")419 sc.GetClient(0).Put(MakePutFromEntry("k0", entry))420 res0 = sc.GetClient(0).Get("k0")421 Expect(res0).NotTo(BeNil())422 Expect(GetEntryValues(res0)).To(ConsistOf([][]byte{423 []byte("v0-s0-3"),424 }))425 })426 })427 })428})...

Full Screen

Full Screen

gossip_test.go

Source:gossip_test.go Github

copy

Full Screen

...14 AfterEach(func() {15 sc.Kill()16 })17 It("should replicate entry to other server.", func() {18 sc.GetClient(0).Put(MakePutFreshEntry("k0", []byte("v0")))19 sc.GetClient(0).Gossip()20 res := sc.GetClient(1).Get("k0")21 Expect(res).NotTo(BeNil())22 Expect(GetEntryValues(res)).To(ConsistOf([][]byte{23 []byte("v0"),24 }))25 })26 It("should work when there are no local entries.", func() {27 sc.GetClient(1).Put(MakePutFreshEntry("k0", []byte("v0")))28 sc.GetClient(0).Gossip()29 res := sc.GetClient(1).Get("k0")30 Expect(res).NotTo(BeNil())31 Expect(GetEntryValues(res)).To(ConsistOf([][]byte{32 []byte("v0"),33 }))34 })35 It("should not replicate remote entries to local.", func() {36 sc.GetClient(1).Put(MakePutFreshEntry("k0", []byte("v0")))37 sc.GetClient(0).Gossip()38 res := sc.GetClient(0).Get("k0")39 Expect(res).NotTo(BeNil())40 Expect(GetEntryValues(res)).To(ConsistOf([][]byte{}))41 })42 It("should replicate entries with different keys to other server.", func() {43 sc.GetClient(0).Put(MakePutFreshEntry("k0", []byte("v0")))44 sc.GetClient(0).Put(MakePutFreshEntry("k1", []byte("v1")))45 sc.GetClient(0).Gossip()46 res := sc.GetClient(1).Get("k0")47 Expect(res).NotTo(BeNil())48 Expect(GetEntryValues(res)).To(ConsistOf([][]byte{49 []byte("v0"),50 }))51 res = sc.GetClient(1).Get("k1")52 Expect(res).NotTo(BeNil())53 Expect(GetEntryValues(res)).To(ConsistOf([][]byte{54 []byte("v1"),55 }))56 })57 It("should replicate conflict entries to other server.", func() {58 // Unsafe: create context (vector clock) on client side59 sc.GetClient(0).Put(MakePutFromVectorClockMapAndValue(60 "k0",61 map[string]uint64{sc.GetID(0): 1, sc.GetID(2): 2},62 []byte("v0-0"),63 ))64 sc.GetClient(0).Put(MakePutFromVectorClockMapAndValue(65 "k0",66 map[string]uint64{sc.GetID(0): 2, sc.GetID(2): 1},67 []byte("v0-1"),68 ))69 sc.GetClient(0).Gossip()70 res := sc.GetClient(1).Get("k0")71 Expect(res).NotTo(BeNil())72 Expect(GetEntryValues(res)).To(ConsistOf([][]byte{73 []byte("v0-0"),74 []byte("v0-1"),75 }))76 })77 Context("when there are conflict entries in remote server", func() {78 It("should replicate entries and keep conflict remote entries.", func() {79 sc.GetClient(0).Put(MakePutFreshEntry("k0", []byte("v0-0")))80 sc.GetClient(1).Put(MakePutFreshEntry("k0", []byte("v0-1")))81 sc.GetClient(0).Gossip()82 res := sc.GetClient(1).Get("k0")83 Expect(res).NotTo(BeNil())84 Expect(GetEntryValues(res)).To(ConsistOf([][]byte{85 []byte("v0-0"),86 []byte("v0-1"),87 }))88 })89 It("should replicate entries and keep conflict remote entries (2).", func() {90 // Unsafe: create context (vector clock) on client side91 sc.GetClient(0).Put(MakePutFromVectorClockMapAndValue(92 "k0",93 map[string]uint64{sc.GetID(0): 1, sc.GetID(2): 2},94 []byte("v0-0"),95 ))96 sc.GetClient(0).Put(MakePutFromVectorClockMapAndValue(97 "k0",98 map[string]uint64{sc.GetID(0): 2, sc.GetID(2): 1},99 []byte("v0-1"),100 ))101 sc.GetClient(1).Put(MakePutFreshEntry("k0", []byte("v0-2")))102 sc.GetClient(0).Gossip()103 res := sc.GetClient(1).Get("k0")104 Expect(res).NotTo(BeNil())105 Expect(GetEntryValues(res)).To(ConsistOf([][]byte{106 []byte("v0-0"),107 []byte("v0-1"),108 []byte("v0-2"),109 }))110 })111 It("should not replicate local ancestor entries.", func() {112 // Unsafe: create context (vector clock) on client side113 sc.GetClient(0).Put(MakePutFromVectorClockMapAndValue(114 "k0",115 map[string]uint64{},116 []byte("v0-0"),117 ))118 sc.GetClient(1).Put(MakePutFromVectorClockMapAndValue(119 "k0",120 map[string]uint64{sc.GetID(0): 1},121 []byte("v0-1"),122 ))123 sc.GetClient(0).Gossip()124 res := sc.GetClient(1).Get("k0")125 Expect(res).NotTo(BeNil())126 Expect(GetEntryValues(res)).To(ConsistOf([][]byte{127 []byte("v0-1"),128 }))129 })130 It("should not replicate local ancestor entries (2).", func() {131 // Unsafe: create context (vector clock) on client side132 sc.GetClient(0).Put(MakePutFromVectorClockMapAndValue(133 "k0",134 map[string]uint64{sc.GetID(0): 1, sc.GetID(1): 1},135 []byte("v0-0"),136 ))137 sc.GetClient(1).Put(MakePutFromVectorClockMapAndValue(138 "k0",139 map[string]uint64{sc.GetID(0): 2, sc.GetID(1): 2},140 []byte("v0-1"),141 ))142 sc.GetClient(0).Gossip()143 res := sc.GetClient(1).Get("k0")144 Expect(res).NotTo(BeNil())145 Expect(GetEntryValues(res)).To(ConsistOf([][]byte{146 []byte("v0-1"),147 }))148 })149 It("should replicate entries and remove remote descendant entries.", func() {150 // Unsafe: create context (vector clock) on client side151 sc.GetClient(0).Put(MakePutFromVectorClockMapAndValue(152 "k0",153 map[string]uint64{sc.GetID(1): 1},154 []byte("v0-0"),155 ))156 sc.GetClient(1).Put(MakePutFromVectorClockMapAndValue(157 "k0",158 map[string]uint64{},159 []byte("v0-1"),160 ))161 sc.GetClient(0).Gossip()162 res := sc.GetClient(1).Get("k0")163 Expect(res).NotTo(BeNil())164 Expect(GetEntryValues(res)).To(ConsistOf([][]byte{165 []byte("v0-0"),166 }))167 })168 It("should replicate entries and remove remote descendant entries (2).", func() {169 // Unsafe: create context (vector clock) on client side170 sc.GetClient(0).Put(MakePutFromVectorClockMapAndValue(171 "k0",172 map[string]uint64{sc.GetID(0): 2, sc.GetID(1): 3},173 []byte("v0-0"),174 ))175 sc.GetClient(1).Put(MakePutFromVectorClockMapAndValue(176 "k0",177 map[string]uint64{sc.GetID(0): 1},178 []byte("v0-1"),179 ))180 sc.GetClient(0).Gossip()181 res := sc.GetClient(1).Get("k0")182 Expect(res).NotTo(BeNil())183 Expect(GetEntryValues(res)).To(ConsistOf([][]byte{184 []byte("v0-0"),185 }))186 })187 })188 })189 Describe("R=1, W=1, ClusterSize=3", func() {190 BeforeEach(func() {191 // StartingPort: 8000, R-Value: 1, W-Value: 1, ClusterSize: 3192 sc = NewServerCoordinator(8000+config.GinkgoConfig.ParallelNode*100, 1, 1, 3)193 })194 AfterEach(func() {195 sc.Kill()196 })197 It("should replicate entry to other server.", func() {198 sc.GetClient(0).Put(MakePutFreshEntry("k0", []byte("v0")))199 sc.GetClient(0).Gossip()200 res1 := sc.GetClient(1).Get("k0")201 Expect(res1).NotTo(BeNil())202 Expect(GetEntryValues(res1)).To(ConsistOf([][]byte{203 []byte("v0"),204 }))205 res2 := sc.GetClient(2).Get("k0")206 Expect(res2).NotTo(BeNil())207 Expect(GetEntryValues(res2)).To(ConsistOf([][]byte{208 []byte("v0"),209 }))210 })211 It("should replicate entries with different keys to other server.", func() {212 sc.GetClient(0).Put(MakePutFreshEntry("k0", []byte("v0")))213 sc.GetClient(0).Put(MakePutFreshEntry("k1", []byte("v1")))214 sc.GetClient(0).Gossip()215 res1 := sc.GetClient(1).Get("k0")216 Expect(res1).NotTo(BeNil())217 Expect(GetEntryValues(res1)).To(ConsistOf([][]byte{218 []byte("v0"),219 }))220 res1 = sc.GetClient(1).Get("k1")221 Expect(res1).NotTo(BeNil())222 Expect(GetEntryValues(res1)).To(ConsistOf([][]byte{223 []byte("v1"),224 }))225 res2 := sc.GetClient(2).Get("k0")226 Expect(res2).NotTo(BeNil())227 Expect(GetEntryValues(res2)).To(ConsistOf([][]byte{228 []byte("v0"),229 }))230 res2 = sc.GetClient(2).Get("k1")231 Expect(res2).NotTo(BeNil())232 Expect(GetEntryValues(res2)).To(ConsistOf([][]byte{233 []byte("v1"),234 }))235 })236 It("should replicate conflict entries to other server.", func() {237 // Unsafe: create context (vector clock) on client side238 sc.GetClient(0).Put(MakePutFromVectorClockMapAndValue(239 "k0",240 map[string]uint64{sc.GetID(0): 1, sc.GetID(2): 2},241 []byte("v0-0"),242 ))243 sc.GetClient(0).Put(MakePutFromVectorClockMapAndValue(244 "k0",245 map[string]uint64{sc.GetID(0): 2, sc.GetID(2): 1},246 []byte("v0-1"),247 ))248 sc.GetClient(0).Gossip()249 res1 := sc.GetClient(1).Get("k0")250 Expect(res1).NotTo(BeNil())251 Expect(GetEntryValues(res1)).To(ConsistOf([][]byte{252 []byte("v0-0"),253 []byte("v0-1"),254 }))255 res2 := sc.GetClient(2).Get("k0")256 Expect(res2).NotTo(BeNil())257 Expect(GetEntryValues(res2)).To(ConsistOf([][]byte{258 []byte("v0-0"),259 []byte("v0-1"),260 }))261 })262 Context("when there are conflict entries in remote server", func() {263 It("should replicate entries and keep conflict remote entries.", func() {264 sc.GetClient(0).Put(MakePutFreshEntry("k0", []byte("v0-0")))265 sc.GetClient(1).Put(MakePutFreshEntry("k0", []byte("v0-1")))266 sc.GetClient(0).Gossip()267 res1 := sc.GetClient(1).Get("k0")268 Expect(res1).NotTo(BeNil())269 Expect(GetEntryValues(res1)).To(ConsistOf([][]byte{270 []byte("v0-0"),271 []byte("v0-1"),272 }))273 res2 := sc.GetClient(2).Get("k0")274 Expect(res2).NotTo(BeNil())275 Expect(GetEntryValues(res2)).To(ConsistOf([][]byte{276 []byte("v0-0"),277 }))278 })279 It("should replicate entries and keep conflict remote entries (2).", func() {280 // Unsafe: create context (vector clock) on client side281 sc.GetClient(0).Put(MakePutFromVectorClockMapAndValue(282 "k0",283 map[string]uint64{sc.GetID(0): 1, sc.GetID(2): 2},284 []byte("v0-0"),285 ))286 sc.GetClient(0).Put(MakePutFromVectorClockMapAndValue(287 "k0",288 map[string]uint64{sc.GetID(0): 2, sc.GetID(2): 1},289 []byte("v0-1"),290 ))291 sc.GetClient(1).Put(MakePutFreshEntry("k0", []byte("v0-2")))292 sc.GetClient(0).Gossip()293 res1 := sc.GetClient(1).Get("k0")294 Expect(res1).NotTo(BeNil())295 Expect(GetEntryValues(res1)).To(ConsistOf([][]byte{296 []byte("v0-0"),297 []byte("v0-1"),298 []byte("v0-2"),299 }))300 res2 := sc.GetClient(0).Get("k0")301 Expect(res2).NotTo(BeNil())302 Expect(GetEntryValues(res2)).To(ConsistOf([][]byte{303 []byte("v0-0"),304 []byte("v0-1"),305 }))306 })307 It("should not replicate local ancestor entries.", func() {308 // Unsafe: create context (vector clock) on client side309 sc.GetClient(0).Put(MakePutFromVectorClockMapAndValue(310 "k0",311 map[string]uint64{},312 []byte("v0-0"),313 ))314 sc.GetClient(1).Put(MakePutFromVectorClockMapAndValue(315 "k0",316 map[string]uint64{sc.GetID(0): 1},317 []byte("v0-1"),318 ))319 sc.GetClient(0).Gossip()320 res1 := sc.GetClient(1).Get("k0")321 Expect(res1).NotTo(BeNil())322 Expect(GetEntryValues(res1)).To(ConsistOf([][]byte{323 []byte("v0-1"),324 }))325 res2 := sc.GetClient(2).Get("k0")326 Expect(res2).NotTo(BeNil())327 Expect(GetEntryValues(res2)).To(ConsistOf([][]byte{328 []byte("v0-0"),329 }))330 })331 It("should not replicate local ancestor entries (2).", func() {332 // Unsafe: create context (vector clock) on client side333 sc.GetClient(0).Put(MakePutFromVectorClockMapAndValue(334 "k0",335 map[string]uint64{sc.GetID(0): 1, sc.GetID(1): 1},336 []byte("v0-0"),337 ))338 sc.GetClient(1).Put(MakePutFromVectorClockMapAndValue(339 "k0",340 map[string]uint64{sc.GetID(0): 2, sc.GetID(1): 2},341 []byte("v0-1"),342 ))343 sc.GetClient(0).Gossip()344 res1 := sc.GetClient(1).Get("k0")345 Expect(res1).NotTo(BeNil())346 Expect(GetEntryValues(res1)).To(ConsistOf([][]byte{347 []byte("v0-1"),348 }))349 res2 := sc.GetClient(2).Get("k0")350 Expect(res2).NotTo(BeNil())351 Expect(GetEntryValues(res2)).To(ConsistOf([][]byte{352 []byte("v0-0"),353 }))354 })355 It("should replicate entries and remove remote descendant entries.", func() {356 // Unsafe: create context (vector clock) on client side357 sc.GetClient(0).Put(MakePutFromVectorClockMapAndValue(358 "k0",359 map[string]uint64{sc.GetID(1): 1},360 []byte("v0-0"),361 ))362 sc.GetClient(1).Put(MakePutFromVectorClockMapAndValue(363 "k0",364 map[string]uint64{},365 []byte("v0-1"),366 ))367 sc.GetClient(0).Gossip()368 res1 := sc.GetClient(1).Get("k0")369 Expect(res1).NotTo(BeNil())370 Expect(GetEntryValues(res1)).To(ConsistOf([][]byte{371 []byte("v0-0"),372 }))373 res2 := sc.GetClient(2).Get("k0")374 Expect(res2).NotTo(BeNil())375 Expect(GetEntryValues(res2)).To(ConsistOf([][]byte{376 []byte("v0-0"),377 }))378 })379 It("should replicate entries and remove remote descendant entries (2).", func() {380 // Unsafe: create context (vector clock) on client side381 sc.GetClient(0).Put(MakePutFromVectorClockMapAndValue(382 "k0",383 map[string]uint64{sc.GetID(0): 2, sc.GetID(1): 3},384 []byte("v0-0"),385 ))386 sc.GetClient(1).Put(MakePutFromVectorClockMapAndValue(387 "k0",388 map[string]uint64{sc.GetID(0): 1},389 []byte("v0-1"),390 ))391 sc.GetClient(0).Gossip()392 res1 := sc.GetClient(1).Get("k0")393 Expect(res1).NotTo(BeNil())394 Expect(GetEntryValues(res1)).To(ConsistOf([][]byte{395 []byte("v0-0"),396 }))397 res2 := sc.GetClient(2).Get("k0")398 Expect(res2).NotTo(BeNil())399 Expect(GetEntryValues(res2)).To(ConsistOf([][]byte{400 []byte("v0-0"),401 }))402 })403 })404 })405 Describe("R=2, W=2, ClusterSize=3", func() {406 BeforeEach(func() {407 // StartingPort: 8000, R-Value: 2, W-Value: 2, ClusterSize: 3408 sc = NewServerCoordinator(8000+config.GinkgoConfig.ParallelNode*100, 2, 2, 3)409 })410 AfterEach(func() {411 sc.Kill()412 })413 It("should replicate entry to other server.", func() {414 sc.GetClient(0).Put(MakePutFreshEntry("k0", []byte("v0")))415 sc.GetClient(0).Gossip()416 res1 := sc.GetClient(1).Get("k0")417 Expect(res1).NotTo(BeNil())418 Expect(GetEntryValues(res1)).To(ConsistOf([][]byte{419 []byte("v0"),420 }))421 res2 := sc.GetClient(2).Get("k0")422 Expect(res2).NotTo(BeNil())423 Expect(GetEntryValues(res2)).To(ConsistOf([][]byte{424 []byte("v0"),425 }))426 })427 It("should replicate entries with different keys to other server.", func() {428 sc.GetClient(0).Put(MakePutFreshEntry("k0", []byte("v0")))429 sc.GetClient(0).Put(MakePutFreshEntry("k1", []byte("v1")))430 sc.GetClient(0).Gossip()431 res1 := sc.GetClient(1).Get("k0")432 Expect(res1).NotTo(BeNil())433 Expect(GetEntryValues(res1)).To(ConsistOf([][]byte{434 []byte("v0"),435 }))436 res1 = sc.GetClient(1).Get("k1")437 Expect(res1).NotTo(BeNil())438 Expect(GetEntryValues(res1)).To(ConsistOf([][]byte{439 []byte("v1"),440 }))441 res2 := sc.GetClient(2).Get("k0")442 Expect(res2).NotTo(BeNil())443 Expect(GetEntryValues(res2)).To(ConsistOf([][]byte{444 []byte("v0"),445 }))446 res2 = sc.GetClient(2).Get("k1")447 Expect(res2).NotTo(BeNil())448 Expect(GetEntryValues(res2)).To(ConsistOf([][]byte{449 []byte("v1"),450 }))451 })452 It("should replicate conflict entries to other server.", func() {453 // Unsafe: create context (vector clock) on client side454 sc.GetClient(0).Put(MakePutFromVectorClockMapAndValue(455 "k0",456 map[string]uint64{sc.GetID(0): 1, sc.GetID(2): 2},457 []byte("v0-0"),458 ))459 sc.GetClient(0).Put(MakePutFromVectorClockMapAndValue(460 "k0",461 map[string]uint64{sc.GetID(0): 2, sc.GetID(2): 1},462 []byte("v0-1"),463 ))464 sc.GetClient(0).Gossip()465 res1 := sc.GetClient(1).Get("k0")466 Expect(res1).NotTo(BeNil())467 Expect(GetEntryValues(res1)).To(ConsistOf([][]byte{468 []byte("v0-0"),469 []byte("v0-1"),470 }))471 res2 := sc.GetClient(2).Get("k0")472 Expect(res2).NotTo(BeNil())473 Expect(GetEntryValues(res2)).To(ConsistOf([][]byte{474 []byte("v0-0"),475 []byte("v0-1"),476 }))477 })478 Context("when there are conflict entries in remote server", func() {479 It("should replicate entries and keep conflict remote entries.", func() {480 sc.GetClient(0).Put(MakePutFreshEntry("k0", []byte("v0-0")))481 sc.GetClient(2).Put(MakePutFreshEntry("k0", []byte("v0-1")))482 sc.GetClient(0).Gossip()483 res2 := sc.GetClient(2).Get("k0")484 Expect(res2).NotTo(BeNil())485 Expect(GetEntryValues(res2)).To(ConsistOf([][]byte{486 []byte("v0-0"),487 []byte("v0-1"),488 }))489 res1 := sc.GetClient(1).Get("k0")490 Expect(res1).NotTo(BeNil())491 Expect(GetEntryValues(res1)).To(ConsistOf([][]byte{492 []byte("v0-0"),493 []byte("v0-1"),494 }))495 })496 It("should replicate entries and keep conflict remote entries (2).", func() {497 sc.GetClient(0).Put(MakePutFromVectorClockMapAndValue(498 "k0",499 map[string]uint64{sc.GetID(0): 1, sc.GetID(2): 2},500 []byte("v0-0"),501 ))502 sc.GetClient(0).Put(MakePutFromVectorClockMapAndValue(503 "k0",504 map[string]uint64{sc.GetID(0): 2, sc.GetID(2): 1},505 []byte("v0-1"),506 ))507 sc.GetClient(1).Put(MakePutFreshEntry("k0", []byte("v0-2")))508 sc.GetClient(0).Gossip()509 res1 := sc.GetClient(1).Get("k0")510 Expect(res1).NotTo(BeNil())511 Expect(GetEntryValues(res1)).To(ConsistOf([][]byte{512 []byte("v0-0"),513 []byte("v0-1"),514 []byte("v0-2"),515 }))516 res2 := sc.GetClient(2).Get("k0")517 Expect(res2).NotTo(BeNil())518 Expect(GetEntryValues(res2)).To(ConsistOf([][]byte{519 []byte("v0-0"),520 []byte("v0-1"),521 []byte("v0-2"),522 }))523 })524 It("should remove remote descendant entries", func() {525 sc.GetClient(0).Put(MakePutFromVectorClockMapAndValue(526 "k0",527 map[string]uint64{},528 []byte("v0-0"),529 ))530 sc.GetClient(1).Put(MakePutFromVectorClockMapAndValue(531 "k0",532 map[string]uint64{sc.GetID(0): 1},533 []byte("v0-1"),534 ))535 sc.GetClient(0).Gossip()536 sc.GetClient(2).Put(MakePutFromVectorClockMapAndValue(537 "k0",538 map[string]uint64{sc.GetID(0): 1},539 []byte("v0-2"),540 ))541 res0 := sc.GetClient(0).Get("k0")542 Expect(res0).NotTo(BeNil())543 Expect(GetEntryValues(res0)).To(ConsistOf([][]byte{544 []byte("v0-1"),545 []byte("v0-2"),546 }))547 res1 := sc.GetClient(1).Get("k0")548 Expect(res1).NotTo(BeNil())549 Expect(GetEntryValues(res1)).To(ConsistOf([][]byte{550 []byte("v0-1"),551 []byte("v0-2"),552 }))553 })554 })555 })556})...

Full Screen

Full Screen

e2e_test.go

Source:e2e_test.go Github

copy

Full Screen

...9 Describe("R-Value: 1, W-Value: 5, ClusterSize: 9", func() {10 var sc ServerCoordinator11 BeforeEach(func() {12 sc = NewServerCoordinator(8000+config.GinkgoConfig.ParallelNode*100, 1, 5, 9)13 sc.GetClient(3).ForceCrash()14 sc.GetClient(4).ForceCrash()15 sc.GetClient(5).ForceCrash()16 sc.GetClient(6).ForceCrash()17 sc.GetClient(7).ForceCrash()18 sc.GetClient(8).ForceCrash()19 })20 AfterEach(func() {21 sc.Kill()22 })23 It("should put as many as possible and return false when availble servers < (W - 1).", func() {24 Expect(sc.GetClient(0).Put(MakePutFreshEntry("k1", []byte("v1")))).To(BeFalse())25 sc.GetClient(3).ForceRestore()26 sc.GetClient(4).ForceRestore()27 sc.GetClient(5).ForceRestore()28 sc.GetClient(6).ForceRestore()29 sc.GetClient(7).ForceRestore()30 sc.GetClient(8).ForceRestore()31 res0 := sc.GetClient(0).Get("k1")32 Expect(res0).NotTo(BeNil())33 Expect(GetEntryValues(res0)).To(ConsistOf([][]byte{34 []byte("v1"),35 }))36 res1 := sc.GetClient(1).Get("k1")37 Expect(res1).NotTo(BeNil())38 Expect(GetEntryValues(res1)).To(ConsistOf([][]byte{39 []byte("v1"),40 }))41 res2 := sc.GetClient(2).Get("k1")42 Expect(res2).NotTo(BeNil())43 Expect(GetEntryValues(res2)).To(ConsistOf([][]byte{44 []byte("v1"),45 }))46 res3 := sc.GetClient(3).Get("k1")47 Expect(res3).NotTo(BeNil())48 Expect(GetEntryValues(res3)).To(ConsistOf([][]byte{}))49 res4 := sc.GetClient(4).Get("k1")50 Expect(res4).NotTo(BeNil())51 Expect(GetEntryValues(res4)).To(ConsistOf([][]byte{}))52 res5 := sc.GetClient(5).Get("k1")53 Expect(res5).NotTo(BeNil())54 Expect(GetEntryValues(res5)).To(ConsistOf([][]byte{}))55 res6 := sc.GetClient(6).Get("k1")56 Expect(res6).NotTo(BeNil())57 Expect(GetEntryValues(res6)).To(ConsistOf([][]byte{}))58 res7 := sc.GetClient(7).Get("k1")59 Expect(res7).NotTo(BeNil())60 Expect(GetEntryValues(res7)).To(ConsistOf([][]byte{}))61 res8 := sc.GetClient(8).Get("k1")62 Expect(res8).NotTo(BeNil())63 Expect(GetEntryValues(res8)).To(ConsistOf([][]byte{}))64 })65 })66 Describe("R-Value: 5, W-Value: 1, ClusterSize: 9", func() {67 var sc ServerCoordinator68 BeforeEach(func() {69 sc = NewServerCoordinator(8000+config.GinkgoConfig.ParallelNode*100, 5, 1, 9)70 })71 AfterEach(func() {72 sc.Kill()73 })74 It("should get avaible servers (skip unavaible servers).", func() {75 for idx := 0; idx < 9; idx++ {76 sc.GetClient(idx).Put(MakePutFreshEntry("k0", []byte("v"+strconv.Itoa(idx))))77 }78 sc.GetClient(3).ForceCrash()79 sc.GetClient(4).ForceCrash()80 res0 := sc.GetClient(0).Get("k0")81 Expect(res0).NotTo(BeNil())82 Expect(GetEntryValues(res0)).To(ConsistOf([][]byte{83 []byte("v0"),84 []byte("v1"),85 []byte("v2"),86 []byte("v5"),87 []byte("v6"),88 }))89 })90 })91 Describe("R-Value: 1, W-Value: 3, ClusterSize: 5", func() {92 var sc ServerCoordinator93 BeforeEach(func() {94 sc = NewServerCoordinator(8000+config.GinkgoConfig.ParallelNode*100, 1, 3, 5)95 })96 AfterEach(func() {97 sc.Kill()98 })99 It("should gossip avaible servers (skip unavaible servers).", func() {100 sc.GetClient(0).Put(MakePutFreshEntry("k0", []byte("v0")))101 sc.GetClient(3).ForceCrash()102 sc.GetClient(4).ForceCrash()103 sc.GetClient(0).Gossip()104 sc.GetClient(3).ForceRestore()105 sc.GetClient(4).ForceRestore()106 res0 := sc.GetClient(0).Get("k0")107 Expect(res0).NotTo(BeNil())108 Expect(GetEntryValues(res0)).To(ConsistOf([][]byte{109 []byte("v0"),110 }))111 res1 := sc.GetClient(1).Get("k0")112 Expect(res1).NotTo(BeNil())113 Expect(GetEntryValues(res1)).To(ConsistOf([][]byte{114 []byte("v0"),115 }))116 res2 := sc.GetClient(2).Get("k0")117 Expect(res2).NotTo(BeNil())118 Expect(GetEntryValues(res2)).To(ConsistOf([][]byte{119 []byte("v0"),120 }))121 res3 := sc.GetClient(3).Get("k0")122 Expect(res3).NotTo(BeNil())123 Expect(GetEntryValues(res3)).To(ConsistOf([][]byte{}))124 res4 := sc.GetClient(4).Get("k0")125 Expect(res4).NotTo(BeNil())126 Expect(GetEntryValues(res4)).To(ConsistOf([][]byte{}))127 })128 })129 Describe("R-Value: 3, W-Value: 3, ClusterSize: 5", func() {130 var sc ServerCoordinator131 BeforeEach(func() {132 sc = NewServerCoordinator(8000+config.GinkgoConfig.ParallelNode*100, 3, 3, 5)133 })134 AfterEach(func() {135 sc.Kill()136 })137 It("should restore and keep its original schedule.", func() {138 sc.GetClient(0).Put(MakePutFreshEntry("k0", []byte("v0")))139 res2 := sc.GetClient(2).Get("k0")140 Expect(res2).NotTo(BeNil())141 Expect(GetEntryValues(res2)).To(ConsistOf([][]byte{142 []byte("v0"),143 }))144 sc.GetClient(2).ForceCrash()145 sc.GetClient(1).Put(MakePutFromVectorClockMapAndValue(146 "k0",147 map[string]uint64{sc.GetID(0): 1},148 []byte("v1"),149 ))150 sc.GetClient(2).ForceRestore()151 sc.GetClient(0).ForceCrash()152 sc.GetClient(1).ForceCrash()153 sc.GetClient(3).ForceCrash()154 sc.GetClient(4).ForceCrash()155 res2 = sc.GetClient(2).Get("k0")156 Expect(res2).NotTo(BeNil())157 Expect(GetEntryValues(res2)).To(ConsistOf([][]byte{158 []byte("v0"),159 }))160 sc.GetClient(0).ForceRestore()161 sc.GetClient(1).ForceRestore()162 sc.GetClient(3).ForceRestore()163 sc.GetClient(4).ForceRestore()164 entry2 := res2.EntryList[0]165 entry2.Value = []byte("v2")166 sc.GetClient(2).Put(MakePutFromEntry("k0", entry2))167 res2 = sc.GetClient(2).Get("k0")168 Expect(res2).NotTo(BeNil())169 Expect(GetEntryValues(res2)).To(ConsistOf([][]byte{170 []byte("v1"),171 []byte("v2"),172 }))173 })174 })175})...

Full Screen

Full Screen

GetClient

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 c := client.Client{}4 c.GetClient()5 fmt.Println(c)6}7import "fmt"8type Client struct {9}10func (c Client) GetClient() {11 fmt.Println("GetClient method called")12}13{{}}14{{}}15 /usr/lib/go-1.10/src/client (from $GOROOT)16 /home/ashish/go/src/client (from $GOPATH)17{{}}

Full Screen

Full Screen

GetClient

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Hello, playground")4 client := client.GetClient()5 client.Print()6}

Full Screen

Full Screen

GetClient

Using AI Code Generation

copy

Full Screen

1import "github.com/ashishjuyal/basics-of-go/11.package/client"2func main() {3 client.GetClient()4}5import "github.com/ashishjuyal/basics-of-go/11.package/client"6func main() {7 client.GetClient()8}9 /usr/local/go/src/github.com/ashishjuyal/basics-of-go/11.package/client (from $GOROOT)10 /home/ashish/go/src/github.com/ashishjuyal/basics-of-go/11.package/client (from $GOPATH)11./3.go:6:2: imported and not used: "github.com/ashishjuyal/basics-of-go/11.package/client"12./3.go:7:2: imported and not used: "github.com/ashishjuyal/basics-of-go/11.package/client"

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Testkube automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful