Exemplo n.º 1
0
// Imitate preparers by copying data from /intent tree to /reality tree
// to simulate deployment
func imitatePreparers(server *testutil.TestServer, quitCh <-chan struct{}) {
	// testutil.Server calls t.Fatalf() if a key doesn't exist, so put some
	// dummy data into /intent and /reality for the test pod so we don't
	// accidentally fail tests by merely testing a key
	dummyManifest := []byte("id: wrong_manifest")
	for _, node := range testNodes {
		intentKey := fmt.Sprintf("intent/%s/%s", node, testPodId)
		server.SetKV(intentKey, dummyManifest)
		realityKey := fmt.Sprintf("reality/%s/%s", node, testPodId)
		server.SetKV(realityKey, dummyManifest)
	}

	// Now do the actual copies
	go func() {
		for {
			select {
			case <-quitCh:
				return
			default:
				for _, node := range testNodes {
					intentKey := fmt.Sprintf("intent/%s/%s", node, testPodId)
					realityKey := fmt.Sprintf("reality/%s/%s", node, testPodId)
					intentBytes := server.GetKV(intentKey)
					if !bytes.Equal(intentBytes, dummyManifest) {
						server.SetKV(realityKey, intentBytes)
					}
				}
			}
		}
	}()
}
Exemplo n.º 2
0
// Adds preparer manifest to reality tree to fool replication library into
// thinking it is installed on the test nodes
func setupPreparers(server *testutil.TestServer) {
	for _, node := range testNodes {
		key := fmt.Sprintf("reality/%s/p2-preparer", node)
		server.SetKV(key, []byte(testPreparerManifest))
	}
}