MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / TestLogKeyConcurrency

Function TestLogKeyConcurrency

base/log_keys_test.go:124–163  ·  view source on GitHub ↗

This test has no assertions, but will flag any data races when run under `-race`.

(t *testing.T)

Source from the content-addressed store, hash-verified

122
123// This test has no assertions, but will flag any data races when run under `-race`.
124func TestLogKeyConcurrency(t *testing.T) {
125 var logKey LogKeyMask
126 stop := make(chan struct{})
127
128 go func() {
129 for {
130 select {
131 default:
132 logKey.Enable(KeyDCP)
133 case <-stop:
134 return
135 }
136 }
137 }()
138
139 go func() {
140 for {
141 select {
142 default:
143 logKey.Disable(KeyDCP)
144 case <-stop:
145 return
146 }
147 }
148 }()
149
150 go func() {
151 for {
152 select {
153 default:
154 logKey.Enabled(KeyDCP)
155 case <-stop:
156 return
157 }
158 }
159 }()
160
161 time.Sleep(time.Millisecond * 100)
162 close(stop)
163}
164
165func BenchmarkLogKeyEnabled(b *testing.B) {
166 logKeys := logKeyMask(KeyCRUD, KeyDCP, KeyReplicate)

Callers

nothing calls this directly

Calls 3

EnableMethod · 0.95
DisableMethod · 0.95
EnabledMethod · 0.95

Tested by

no test coverage detected