Skip to content

Commit

Permalink
reduce info inside annotations (#543)
Browse files Browse the repository at this point in the history
Signed-off-by: Petr Fedchenkov <[email protected]>
  • Loading branch information
giggsoff authored Feb 28, 2021
1 parent 19b76d7 commit ecf7086
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 20 deletions.
4 changes: 1 addition & 3 deletions tests/app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ func checkNewLastState(appName, state string) bool {
if ok {
lastState := appStates[len(appStates)-1]
if lastState.state != state {
fmt.Printf("lastState: %s expected state: %s time: %s\n", lastState.state, state,
time.Now().Format(time.RFC3339Nano))
return true
}
}
Expand All @@ -88,7 +86,7 @@ func checkState(eveState *eve.State, state string, appNames []string) error {
}
for _, app := range eveState.Applications() {
if _, inSlice := utils.FindEleInSlice(appNames, app.Name); inSlice {
checkAndAppendState(app.Name, "EXISTS")
checkAndAppendState(app.Name, app.EVEState)
foundAny = true
}
}
Expand Down
4 changes: 3 additions & 1 deletion tests/escript/go-internal/testscript/testscript.go
Original file line number Diff line number Diff line change
Expand Up @@ -777,8 +777,10 @@ func (ts *TestScript) addGHAnnotation() {
pathToPrint = filepath.Join(testDirectory, split[1])
}
}
//we should return only text after last [stdout] line
lastIndexOfStdout := strings.LastIndex(ts.log.String(), "\n[stdout]\n") + 1
// replace symbols to be compatible with GH Actions
ghAnnotation := strings.ReplaceAll(ts.log.String(), "\n", "%0A")
ghAnnotation := strings.ReplaceAll(ts.log.String()[lastIndexOfStdout:], "\n", "%0A")
ghAnnotation = strings.ReplaceAll(ghAnnotation, "\r", "%0D")
// print annotation
fmt.Printf("::error file=%s,line=%d::%s\n", pathToPrint, ts.lineno, ghAnnotation)
Expand Down
21 changes: 9 additions & 12 deletions tests/network/nw_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,32 +51,30 @@ func TestMain(m *testing.M) {
}

// checkNewLastState returns true if provided state not equals with last
func checkNewLastState(volName, state string) bool {
volStates, ok := states[volName]
func checkNewLastState(netName, state string) bool {
netStates, ok := states[netName]
if ok {
lastState := volStates[len(volStates)-1]
lastState := netStates[len(netStates)-1]
if lastState.state != state {
fmt.Printf("lastState: %s state: %s time: %s\n", lastState.state, state,
time.Now().Format(time.RFC3339Nano))
return true
}
}
return false
}

func checkAndAppendState(volName, state string) {
if checkNewLastState(volName, state) {
states[volName] = append(states[volName], nwState{state: state, timestamp: time.Now()})
func checkAndAppendState(netName, state string) {
if checkNewLastState(netName, state) {
states[netName] = append(states[netName], nwState{state: state, timestamp: time.Now()})
}
}

func checkState(eveState *eve.State, state string, netNames []string) error {
out := "\n"
if state == "-" {
foundAny := false
for _, vol := range eveState.Networks() {
if _, inSlice := utils.FindEleInSlice(netNames, vol.Name); inSlice {
checkAndAppendState(vol.Name, "EXISTS")
for _, net := range eveState.Networks() {
if _, inSlice := utils.FindEleInSlice(netNames, net.Name); inSlice {
checkAndAppendState(net.Name, net.EveState)
foundAny = true
}
}
Expand All @@ -92,7 +90,6 @@ func checkState(eveState *eve.State, state string, netNames []string) error {
}
for _, net := range eveState.Networks() {
if _, inSlice := utils.FindEleInSlice(netNames, net.Name); inSlice {
fmt.Printf("%s: %s\n", net.Name, net.EveState)
checkAndAppendState(net.Name, net.EveState)
}
}
Expand Down
5 changes: 1 addition & 4 deletions tests/volume/vol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ func checkNewLastState(volName, state string) bool {
if ok {
lastState := volStates[len(volStates)-1]
if lastState.state != state {
fmt.Printf("lastState: %s expected state: %s time: %s\n", lastState.state, state,
time.Now().Format(time.RFC3339Nano))
return true
}
}
Expand All @@ -80,7 +78,7 @@ func checkState(eveState *eve.State, state string, volNames []string) error {
}
for _, vol := range eveState.Volumes() {
if _, inSlice := utils.FindEleInSlice(volNames, vol.Name); inSlice {
checkAndAppendState(vol.Name, "EXISTS")
checkAndAppendState(vol.Name, vol.EveState)
foundAny = true
}
}
Expand All @@ -96,7 +94,6 @@ func checkState(eveState *eve.State, state string, volNames []string) error {
}
for _, vol := range eveState.Volumes() {
if _, inSlice := utils.FindEleInSlice(volNames, vol.Name); inSlice {
fmt.Printf("%s: %s\n", vol.Name, vol.EveState)
checkAndAppendState(vol.Name, vol.EveState)
}
}
Expand Down

0 comments on commit ecf7086

Please sign in to comment.