Skip to content

Commit

Permalink
Merge pull request #529 from jhernand/remove_unreliable_leadership_fl…
Browse files Browse the repository at this point in the history
…ag_tests

Remove unreliable leadership flag tests
  • Loading branch information
jhernand authored Dec 20, 2021
2 parents ab625c3 + 6d8e69c commit accb14a
Showing 1 changed file with 0 additions and 61 deletions.
61 changes: 0 additions & 61 deletions leadership/flag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package leadership
import (
"context"
"database/sql"
"fmt"
"time"

. "github.com/onsi/ginkgo" // nolint
Expand Down Expand Up @@ -386,66 +385,6 @@ var _ = Describe("Flag behaviour", func() {
})
})

When("Multiple processes try to hold it", func() {
var flags []*Flag

BeforeEach(func() {
var err error

// Create the objects:
flags = make([]*Flag, 10)
for i := range flags {
flags[i], err = NewFlag().
Logger(logger).
Handle(dbHandle).
Name("my_flag").
Process(fmt.Sprintf("my_process_%d", i)).
Interval(100 * time.Millisecond).
Jitter(0).
Build(ctx)
Expect(err).ToNot(HaveOccurred())
}
})

AfterEach(func() {
var err error

// Close the objects:
for _, flag := range flags {
err = flag.Close()
Expect(err).ToNot(HaveOccurred())
}
})

It("Is never raised by more than one process", func() {
time.Sleep(100 * time.Millisecond)
for i := 0; i < 100; i++ {
count := 0
for _, flag := range flags {
if flag.Raised() {
count++
}
}
Expect(count).To(BeNumerically("<=", 1))
time.Sleep(10 * time.Millisecond)
}
})

It("Is always raised by at least one process", func() {
time.Sleep(100 * time.Millisecond)
for i := 0; i < 100; i++ {
count := 0
for _, flag := range flags {
if flag.Raised() {
count++
}
}
Expect(count).To(Equal(1))
time.Sleep(10 * time.Millisecond)
}
})
})

When("Current holder closes the flag", func() {
It("Is raised by another process", func() {
var err error
Expand Down

0 comments on commit accb14a

Please sign in to comment.