-
Notifications
You must be signed in to change notification settings - Fork 495
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13491 from SimonRichardson/run-action-wait-for
#13491 The wait flag allows you to specify no-time arguments for run action, which then allows you to wait forever (it prevents a timer from running). Also, passing `wait=true` is semantically the same. The problem with the last changes is it prevented the use of this and error'd out with the timeout being too small. The fix is to expose if the flag is in the forever mode. ## QA steps See: #13477 ```sh $ juju bootstrap microk8s test $ juju deploy hello-kubecon $ juju run-action hello-kubecon/0 pull-site --wait unit-hello-kubecon-0: UnitId: hello-kubecon/0 id: "55" results: result: site pulled status: completed timing: completed: 2021-11-04 15:46:58 +0000 UTC enqueued: 2021-11-04 15:46:57 +0000 UTC started: 2021-11-04 15:46:57 +0000 UTC ```
- Loading branch information
Showing
4 changed files
with
74 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright 2021 Canonical Ltd. | ||
// Licensed under the AGPLv3, see LICENCE file for details. | ||
|
||
package action | ||
|
||
import ( | ||
"time" | ||
|
||
jc "github.com/juju/testing/checkers" | ||
gc "gopkg.in/check.v1" | ||
) | ||
|
||
type WaitFlagSuite struct { | ||
} | ||
|
||
var _ = gc.Suite(&WaitFlagSuite{}) | ||
|
||
func (s *WaitFlagSuite) TestEmpty(c *gc.C) { | ||
var flag waitFlag | ||
timeout, forever := flag.Get() | ||
c.Assert(forever, gc.Equals, false) | ||
c.Assert(timeout, gc.Equals, time.Duration(0)) | ||
} | ||
|
||
func (s *WaitFlagSuite) TestForever(c *gc.C) { | ||
var flag waitFlag | ||
err := flag.Set("true") | ||
c.Assert(err, jc.ErrorIsNil) | ||
timeout, forever := flag.Get() | ||
c.Assert(forever, gc.Equals, true) | ||
c.Assert(timeout, gc.Equals, time.Duration(0)) | ||
} | ||
|
||
func (s *WaitFlagSuite) TestDuration(c *gc.C) { | ||
var flag waitFlag | ||
err := flag.Set("1ms") | ||
c.Assert(err, jc.ErrorIsNil) | ||
timeout, forever := flag.Get() | ||
c.Assert(forever, gc.Equals, false) | ||
c.Assert(timeout, gc.Equals, time.Millisecond) | ||
} |