MCPcopy
hub / github.com/perkeep/perkeep / TestConcurrency

Function TestConcurrency

pkg/index/sqlite/sqlite_test.go:103–126  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

101}
102
103func TestConcurrency(t *testing.T) {
104 if testing.Short() {
105 t.Logf("skipping for short mode")
106 return
107 }
108 s, clean := newSorted(t)
109 defer clean()
110 const n = 100
111 ch := make(chan error)
112 for i := 0; i < n; i++ {
113 i := i
114 go func() {
115 bm := s.BeginBatch()
116 bm.Set("keyA-"+fmt.Sprint(i), fmt.Sprintf("valA=%d", i))
117 bm.Set("keyB-"+fmt.Sprint(i), fmt.Sprintf("valB=%d", i))
118 ch <- s.CommitBatch(bm)
119 }()
120 }
121 for i := 0; i < n; i++ {
122 if err := <-ch; err != nil {
123 t.Errorf("%d: %v", i, err)
124 }
125 }
126}
127
128func numFDs(t *testing.T) int {
129 lsofPath, err := exec.LookPath("lsof")

Callers

nothing calls this directly

Calls 5

newSortedFunction · 0.85
LogfMethod · 0.80
BeginBatchMethod · 0.65
SetMethod · 0.65
CommitBatchMethod · 0.65

Tested by

no test coverage detected