コード例 #1
0
ファイル: scheduler_bench_test.go プロジェクト: tsandall/opa
func setupNodes(ctx context.Context, store *storage.Storage, txn storage.Transaction, n int) {
	tmpl, err := template.New("node").Parse(nodeTemplate)
	if err != nil {
		panic(err)
	}
	if err := store.Write(ctx, txn, storage.AddOp, storage.MustParsePath("/nodes"), map[string]interface{}{}); err != nil {
		panic(err)
	}
	for i := 0; i < n; i++ {
		input := nodeTemplateInput{
			Name: fmt.Sprintf("node%v", i),
		}
		v := runTemplate(tmpl, input)
		path := storage.MustParsePath(fmt.Sprintf("/nodes/%v", input.Name))
		if err := store.Write(ctx, txn, storage.AddOp, path, v); err != nil {
			panic(err)
		}
	}
}