Skip to content

Commit

Permalink
Merge pull request #652 from wzshiming/test/flaky
Browse files Browse the repository at this point in the history
Fix compose flaky test
  • Loading branch information
wzshiming authored Jun 14, 2023
2 parents 15d3498 + 490dcb9 commit b4b7fa6
Showing 1 changed file with 43 additions and 6 deletions.
49 changes: 43 additions & 6 deletions pkg/kwokctl/runtime/compose/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import (
"sigs.k8s.io/kwok/pkg/utils/net"
"sigs.k8s.io/kwok/pkg/utils/path"
"sigs.k8s.io/kwok/pkg/utils/version"
"sigs.k8s.io/kwok/pkg/utils/wait"
)

// Cluster is an implementation of Runtime for docker.
Expand Down Expand Up @@ -560,7 +561,13 @@ func (c *Cluster) Install(ctx context.Context) error {
return err
}

err = c.createComponents(ctx)
err = wait.Poll(ctx, func(ctx context.Context) (bool, error) {
err = c.createComponents(ctx)
return err == nil, err
},
wait.WithContinueOnError(5),
wait.WithImmediate(),
)
if err != nil {
return err
}
Expand All @@ -571,7 +578,13 @@ func (c *Cluster) Install(ctx context.Context) error {
// Uninstall uninstalls the cluster.
func (c *Cluster) Uninstall(ctx context.Context) error {
if c.isSelfCompose(ctx, false) {
err := c.deleteComponents(ctx)
err := wait.Poll(ctx, func(ctx context.Context) (bool, error) {
err := c.deleteComponents(ctx)
return err == nil, err
},
wait.WithContinueOnError(5),
wait.WithImmediate(),
)
if err != nil {
return err
}
Expand All @@ -592,7 +605,13 @@ func (c *Cluster) Uninstall(ctx context.Context) error {
// Up starts the cluster.
func (c *Cluster) Up(ctx context.Context) error {
if c.isSelfCompose(ctx, false) {
err := c.startComponents(ctx)
err := wait.Poll(ctx, func(ctx context.Context) (bool, error) {
err := c.startComponents(ctx)
return err == nil, err
},
wait.WithContinueOnError(5),
wait.WithImmediate(),
)
if err != nil {
return err
}
Expand All @@ -605,7 +624,13 @@ func (c *Cluster) Up(ctx context.Context) error {
// Down stops the cluster
func (c *Cluster) Down(ctx context.Context) error {
if c.isSelfCompose(ctx, false) {
err := c.stopComponents(ctx)
err := wait.Poll(ctx, func(ctx context.Context) (bool, error) {
err := c.stopComponents(ctx)
return err == nil, err
},
wait.WithContinueOnError(5),
wait.WithImmediate(),
)
if err != nil {
return err
}
Expand All @@ -629,7 +654,13 @@ func (c *Cluster) Start(ctx context.Context) error {
}
}
}
err := c.startComponents(ctx)
err := wait.Poll(ctx, func(ctx context.Context) (bool, error) {
err := c.startComponents(ctx)
return err == nil, err
},
wait.WithContinueOnError(5),
wait.WithImmediate(),
)
if err != nil {
return err
}
Expand Down Expand Up @@ -672,7 +703,13 @@ func (c *Cluster) Stop(ctx context.Context) error {
}
}
}
err := c.stopComponents(ctx)
err := wait.Poll(ctx, func(ctx context.Context) (bool, error) {
err := c.stopComponents(ctx)
return err == nil, err
},
wait.WithContinueOnError(5),
wait.WithImmediate(),
)
if err != nil {
return err
}
Expand Down

0 comments on commit b4b7fa6

Please sign in to comment.