1
0
mirror of https://github.com/redis/go-redis.git synced 2025-10-26 06:51:16 +03:00
Files
go-redis/maintnotifications/e2e/utils_test.go
Hristo Temelski 1e6ee06740 test(e2e): testing framework upgrade (#3541)
* update e2e test, change script

* update script and tests

* fixed bdbid parsing

* disabled majority of tests, swapped event order

* change the config tag

* revert test order

* fix typo

* reenable all e2e tests

* change the clonfig flag key for all e2e tests

* improve logging for debug purposes of tests

* longer deadline for FI in CI

* increase waiting for notifications

* extend tests

* dont fail on flaky third client

* fi new params

* fix test build

* more time for migrating

* first wait for FI action, then assert notification

* fix test build

* fix tests

* fix tests

* change output

* global print logs for tests

* better output

* fix error format

* maybe the notification is already received

* second and third client fix

* print output if failed

* better second and third client checks

* output action data if notification is not received

* stop command runner

* database create / delete actions

* database create / delete actions used in tests

* fix import

* remove example

* remove unused var

* use different port than the one in env

* wait for action to get the response

* fix output

* fix create db config

* fix create db config

* use new database for client

* fix create db config

* db per scenario

* less logs, correct check

* Add CTRF to the scenario tests (#3545)

* add some json ctrf improvements

* fix -v

* attempt to separate the output

---------

Co-authored-by: Nedyalko Dyakov <1547186+ndyakov@users.noreply.github.com>

---------

Co-authored-by: Nedyalko Dyakov <nedyalko.dyakov@gmail.com>
Co-authored-by: kiryazovi-redis <ivaylo.kiryazov@redis.com>
Co-authored-by: Nedyalko Dyakov <1547186+ndyakov@users.noreply.github.com>
2025-10-17 17:23:10 +03:00

77 lines
1.7 KiB
Go

package e2e
import (
"fmt"
"path/filepath"
"runtime"
"time"
)
func isTimeout(errMsg string) bool {
return contains(errMsg, "i/o timeout") ||
contains(errMsg, "deadline exceeded") ||
contains(errMsg, "context deadline exceeded")
}
// isTimeoutError checks if an error is a timeout error
func isTimeoutError(err error) bool {
if err == nil {
return false
}
// Check for various timeout error types
errStr := err.Error()
return isTimeout(errStr)
}
// contains checks if a string contains a substring (case-insensitive)
func contains(s, substr string) bool {
return len(s) >= len(substr) &&
(s == substr ||
(len(s) > len(substr) &&
(s[:len(substr)] == substr ||
s[len(s)-len(substr):] == substr ||
containsSubstring(s, substr))))
}
func containsSubstring(s, substr string) bool {
for i := 0; i <= len(s)-len(substr); i++ {
if s[i:i+len(substr)] == substr {
return true
}
}
return false
}
func min(a, b int) int {
if a < b {
return a
}
return b
}
func printLog(group string, isError bool, format string, args ...interface{}) {
_, filename, line, _ := runtime.Caller(2)
filename = filepath.Base(filename)
finalFormat := "%s:%d [%s][%s] " + format + "\n"
if isError {
finalFormat = "%s:%d [%s][%s][ERROR] " + format + "\n"
}
ts := time.Now().Format("15:04:05.000")
args = append([]interface{}{filename, line, ts, group}, args...)
fmt.Printf(finalFormat, args...)
}
func actionOutputIfFailed(status *ActionStatusResponse) string {
if status.Status != StatusFailed {
return ""
}
if status.Error != nil {
return fmt.Sprintf("%v", status.Error)
}
if status.Output == nil {
return ""
}
return fmt.Sprintf("%+v", status.Output)
}