Skip to content

Commit

Permalink
update WaitForNodesUP
Browse files Browse the repository at this point in the history
  • Loading branch information
karol-kokoszka committed Oct 25, 2024
1 parent c4565ac commit 8130d5f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
2 changes: 1 addition & 1 deletion pkg/service/cluster/service_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func TestValidateHostConnectivityIntegration(t *testing.T) {
func callValidateHostConnectivityWithTimeout(ctx context.Context, s *cluster.Service, timeout time.Duration,
c *cluster.Cluster) error {

callCtx, cancel := context.WithTimeout(ctx, timeout)
callCtx, cancel := context.WithCancel(ctx)
defer cancel()

done := make(chan error)
Expand Down
25 changes: 11 additions & 14 deletions pkg/service/healthcheck/service_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ package healthcheck
import (
"bytes"
"context"
"fmt"
"io"
"net"
"net/http"
Expand All @@ -23,6 +22,7 @@ import (
"github.com/scylladb/scylla-manager/v3/pkg/metrics"
"github.com/scylladb/scylla-manager/v3/pkg/service/cluster"
"github.com/scylladb/scylla-manager/v3/pkg/service/configcache"
"go.uber.org/multierr"
"go.uber.org/zap/zapcore"

"github.com/scylladb/scylla-manager/v3/pkg/schema/table"
Expand Down Expand Up @@ -555,31 +555,28 @@ func tryStartAgent(t *testing.T, hosts []string) {
func ensureNodesAreUP(t *testing.T, hosts []string, timeout time.Duration) error {
t.Helper()

done := make(chan struct{})
errorsChan := make(chan error, len(hosts))
wg := sync.WaitGroup{}
for _, host := range hosts {
wg.Add(1)

go func(h string) {
defer wg.Done()

err := WaitForNodeUP(h, timeout)
err := WaitForNodeUPOrTimeout(h, timeout)
if err != nil {
t.Log(err)
errorsChan <- err
}
}(host)
}

go func() {
wg.Wait()
close(done)
}()

select {
case <-done:
return nil
case <-time.After(timeout):
return fmt.Errorf("cannot reach UP status for all nodes %v", hosts)
wg.Wait()
var allErrors error
for err := range errorsChan {
allErrors = multierr.Combine(allErrors, err)
}

return allErrors
}

const pingPath = "/storage_service/scylla_release_version"
Expand Down
4 changes: 2 additions & 2 deletions pkg/testutils/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ func StartService(h, service string) error {
return nil
}

// WaitForNodeUP waits until nodetool status report UN status for the given node.
// WaitForNodeUPOrTimeout waits until nodetool status report UN status for the given node.
// The nodetool status CLI is executed on the same node.
func WaitForNodeUP(h string, timeout time.Duration) error {
func WaitForNodeUPOrTimeout(h string, timeout time.Duration) error {
nodeIsReady := make(chan struct{})
done := make(chan struct{})
go func() {
Expand Down

0 comments on commit 8130d5f

Please sign in to comment.