Skip to content

Commit

Permalink
Check new state implementation
Browse files Browse the repository at this point in the history
We want to use check-new option to check options after transition, thus
 the next state after initial

Signed-off-by: Petr Fedchenkov <[email protected]>
  • Loading branch information
giggsoff committed Oct 20, 2023
1 parent 523cad4 commit 13844e3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
11 changes: 10 additions & 1 deletion tests/app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type appState struct {
// This test wait for the app's state with a timewait.
var (
timewait = flag.Duration("timewait", 10*time.Minute, "Timewait for items waiting")
_ = flag.Bool("check-new", false, "Check only new info messages")
checkNew = flag.Bool("check-new", false, "Check for the new state after state transition")
tc *projects.TestContext
states map[string][]appState
)
Expand Down Expand Up @@ -109,6 +109,15 @@ func checkState(eveState *eve.State, state string, appNames []string) error {
if len(states) == len(appNames) {
for _, appName := range appNames {
if !checkNewLastState(appName, state) {
if *checkNew {
// first one is no info from controller
// the second is initial state
// we want to wait for the third or later, thus new state
if len(states[appName]) <= 2 {
fmt.Println(utils.AddTimestamp(fmt.Sprintf("\tappName %s wait for new state", appName)))

Check failure on line 117 in tests/app/app_test.go

View workflow job for this annotation

GitHub Actions / yetus

golangcilint: use of `fmt.Println` forbidden by pattern `^(fmt\.Print(|f|ln)|print|println)$` (forbidigo)
return nil
}
}
out += utils.AddTimestamp(fmt.Sprintf(
"app %s state %s\n",
appName, state))
Expand Down
11 changes: 10 additions & 1 deletion tests/network/nw_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type nwState struct {
// This test wait for the network's state with a timewait.
var (
timewait = flag.Duration("timewait", time.Minute, "Timewait for items waiting")
_ = flag.Bool("check-new", false, "Check only new info messages")
checkNew = flag.Bool("check-new", false, "Check for the new state after state transition")
tc *projects.TestContext
states map[string][]nwState
)
Expand Down Expand Up @@ -96,6 +96,15 @@ func checkState(eveState *eve.State, state string, netNames []string) error {
if len(states) == len(netNames) {
for _, netName := range netNames {
if !checkNewLastState(netName, state) {
if *checkNew {
// first one is no info from controller
// the second is initial state
// we want to wait for the third or later, thus new state
if len(states[netName]) <= 2 {
fmt.Println(utils.AddTimestamp(fmt.Sprintf("\tnetName %s wait for new state", netName)))
return nil
}
}
out += fmt.Sprintf(
"network %s state %s\n",
netName, state)
Expand Down
11 changes: 10 additions & 1 deletion tests/volume/vol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type volState struct {
// This test wait for the volume's state with a timewait.
var (
timewait = flag.Duration("timewait", time.Minute, "Timewait for items waiting")
_ = flag.Bool("check-new", false, "Check only new info messages")
checkNew = flag.Bool("check-new", false, "Check for the new state after state transition")
tc *projects.TestContext
states map[string][]volState
)
Expand Down Expand Up @@ -100,6 +100,15 @@ func checkState(eveState *eve.State, state string, volNames []string) error {
if len(states) == len(volNames) {
for _, volName := range volNames {
if !checkNewLastState(volName, state) {
if *checkNew {
// first one is no info from controller
// the second is initial state
// we want to wait for the third or later, thus new state
if len(states[volName]) <= 2 {
fmt.Println(utils.AddTimestamp(fmt.Sprintf("\tvolName %s wait for new state", volName)))
return nil
}
}
out += fmt.Sprintf(
"volume %s state %s\n",
volName, state)
Expand Down

0 comments on commit 13844e3

Please sign in to comment.