mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-28 09:56:31 +02:00
fix go get, improve redis test (#2450)
* add pomerium.go to fix go get * try to make redis test less flaky
This commit is contained in:
parent
33f7e8487a
commit
3f8617cd93
2 changed files with 23 additions and 18 deletions
|
@ -128,7 +128,7 @@ func TestChangeSignal(t *testing.T) {
|
|||
ctx, clearTimeout := context.WithTimeout(ctx, time.Second*30)
|
||||
defer clearTimeout()
|
||||
|
||||
ready := make(chan struct{})
|
||||
done := make(chan struct{})
|
||||
var eg errgroup.Group
|
||||
eg.Go(func() error {
|
||||
backend, err := New(rawURL)
|
||||
|
@ -140,24 +140,18 @@ func TestChangeSignal(t *testing.T) {
|
|||
ch := backend.onChange.Bind()
|
||||
defer backend.onChange.Unbind(ch)
|
||||
|
||||
// signal the second backend that we're ready to receive a change
|
||||
close(ready)
|
||||
|
||||
select {
|
||||
case <-ch:
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
}
|
||||
|
||||
// signal the second backend that we've received the change
|
||||
close(done)
|
||||
|
||||
return nil
|
||||
})
|
||||
eg.Go(func() error {
|
||||
// wait for the first backend to be bound to the on change handler
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
case <-ready:
|
||||
}
|
||||
|
||||
backend, err := New(rawURL)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -165,6 +159,7 @@ func TestChangeSignal(t *testing.T) {
|
|||
defer func() { _ = backend.Close() }()
|
||||
|
||||
// put a new value to trigger a change
|
||||
for {
|
||||
_, err = backend.Put(ctx, &databroker.Record{
|
||||
Type: "TYPE",
|
||||
Id: "ID",
|
||||
|
@ -172,7 +167,15 @@ func TestChangeSignal(t *testing.T) {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
case <-done:
|
||||
return nil
|
||||
case <-time.After(time.Millisecond * 100):
|
||||
}
|
||||
}
|
||||
})
|
||||
assert.NoError(t, eg.Wait(), "expected signal to be fired when another backend triggers a change")
|
||||
return nil
|
||||
|
|
2
pomerium.go
Normal file
2
pomerium.go
Normal file
|
@ -0,0 +1,2 @@
|
|||
// Package pomerium is the root of the pomerium project.
|
||||
package pomerium
|
Loading…
Add table
Reference in a new issue