From 00092ff03830169166f13b30d4bb8905bf091bb0 Mon Sep 17 00:00:00 2001 From: Yaroslav Grebnov Date: Sat, 14 Nov 2026 16:22:14 +0100 Subject: [PATCH 1/3] Use updated model lib --- execute/runtime/router/http/router_test.go | 3 +- execute/runtime/service/http/real_test.go | 3 +- go.mod | 22 ++-- go.sum | 52 ++++----- model/environment.go | 12 +- model/http.go | 2 +- model/matcher/grpc_message.go | 2 +- model/matcher/string.go | 4 +- model/test.go | 16 +-- model/testsuite.go | 12 +- model/validation.go | 130 +++++++++------------ tools/go.mod | 34 +++--- tools/go.sum | 68 +++++------ 13 files changed, 174 insertions(+), 186 deletions(-) diff --git a/execute/runtime/router/http/router_test.go b/execute/runtime/router/http/router_test.go index b39564e..b2400a9 100644 --- a/execute/runtime/router/http/router_test.go +++ b/execute/runtime/router/http/router_test.go @@ -971,7 +971,8 @@ func TestRouterUnmountClosesActiveRequest(t *testing.T) { } select { - case <-requestDone: + case requestDoneErr := <-requestDone: + _ = requestDoneErr case <-time.After(5 * time.Second): t.Error("active client request did not terminate") } diff --git a/execute/runtime/service/http/real_test.go b/execute/runtime/service/http/real_test.go index 6793973..5cb8bf1 100644 --- a/execute/runtime/service/http/real_test.go +++ b/execute/runtime/service/http/real_test.go @@ -900,7 +900,8 @@ func TestRealHTTPServiceUnmountClosesActiveRequest(t *testing.T) { } select { - case <-requestDone: + case requestDoneErr := <-requestDone: + _ = requestDoneErr case <-time.After(5 * time.Second): t.Error("active client request did not terminate") } diff --git a/go.mod b/go.mod index 80b97ff..c062f1a 100644 --- a/go.mod +++ b/go.mod @@ -4,23 +4,23 @@ go 1.27 require ( github.com/bufbuild/protocompile v0.14.1 - github.com/e2engine/instrumentation-go v0.1.1 - github.com/e2engine/instrumentation-go/grpc v0.1.1 - github.com/e2engine/instrumentation-go/http v0.1.1 + github.com/e2engine/instrumentation-go v0.2.3 + github.com/e2engine/instrumentation-go/grpc v0.2.1 + github.com/e2engine/instrumentation-go/http v0.2.2 github.com/ygrebnov/errorc v0.6.1 github.com/ygrebnov/keys v0.2.0 - github.com/ygrebnov/log v0.4.4 - github.com/ygrebnov/model v0.7.5 + github.com/ygrebnov/log v0.5.1 + github.com/ygrebnov/model v0.8.1 go.uber.org/mock v0.6.0 - google.golang.org/grpc v1.84.0 + google.golang.org/grpc v1.85.0 google.golang.org/protobuf v1.36.12 gopkg.in/yaml.v3 v3.0.1 ) require ( - golang.org/x/net v0.61.0 // indirect - golang.org/x/sync v0.24.0 // indirect - golang.org/x/sys v0.49.0 // indirect - golang.org/x/text v0.43.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20261012220534-4341edf3f941 // indirect + golang.org/x/net v0.62.0 // indirect + golang.org/x/sync v0.25.0 // indirect + golang.org/x/sys v0.50.0 // indirect + golang.org/x/text v0.44.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20261110000943-09e21b237f2c // indirect ) diff --git a/go.sum b/go.sum index 8b8e805..580b57a 100644 --- a/go.sum +++ b/go.sum @@ -2,12 +2,12 @@ github.com/bufbuild/protocompile v0.14.1 h1:iA73zAf/fyljNjQKwYzUHD6AD4R8KMasmwa/ github.com/bufbuild/protocompile v0.14.1/go.mod h1:ppVdAIhbr2H8asPk6k4pY7t9zB1OU5DoEw9xY/FUi1c= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/e2engine/instrumentation-go v0.1.1 h1:pkOQIQWWkGqHdU1F/b0tCtpFyNDc09kKebYZElHZS9k= -github.com/e2engine/instrumentation-go v0.1.1/go.mod h1:zpWF7koAp+vFqYAfOx3mOJFn4GpLtzetguAs8n7+wIE= -github.com/e2engine/instrumentation-go/grpc v0.1.1 h1:0sqxF3oCdxdVaJwzTshaf79VMXglVHJQ1bLte7vnH14= -github.com/e2engine/instrumentation-go/grpc v0.1.1/go.mod h1:l74IeAGD1lOKbrc/rqQJ3qHvrQF1rvefC50v8unCo1U= -github.com/e2engine/instrumentation-go/http v0.1.1 h1:Xu+yRVgv6jsq7eBLzeOeccwM0dyNz2ga1ybaXNUFhTk= -github.com/e2engine/instrumentation-go/http v0.1.1/go.mod h1:dFgPXV8kq17HHTecABNLaAio8td8LtdiNj9cZYS6Kng= +github.com/e2engine/instrumentation-go v0.2.3 h1:Al7SoAIiMHiJ4zxj71JYiFCE9MKgpXFGHxlZCHmbe+0= +github.com/e2engine/instrumentation-go v0.2.3/go.mod h1:DyUxzrRZBCzOk+toAmxex+Xn09fYhutsCRUfNUgS8kQ= +github.com/e2engine/instrumentation-go/grpc v0.2.1 h1:GB+ZDt/36/gtI1MjVD9agT/RdL9tDBVocAaZUD/rBGU= +github.com/e2engine/instrumentation-go/grpc v0.2.1/go.mod h1:iEvQmwSHqSijbqIPpSKI0f2ui/OjIC3pZizgbrhszVY= +github.com/e2engine/instrumentation-go/http v0.2.2 h1:/C0lWgchf/E+gWFdLjPui85w2X3wc8sRNqxqqwdBYGg= +github.com/e2engine/instrumentation-go/http v0.2.2/go.mod h1:F2Tafqfg3h0LDMFlzjkLHpiirF1Kzcx5zmH4OgB8vkk= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= @@ -20,30 +20,30 @@ github.com/ygrebnov/errorc v0.6.1 h1:ICww1JOesR0HyE3cVWMr0SBmB8RV1XSmGwB5yVP1SqE github.com/ygrebnov/errorc v0.6.1/go.mod h1:akitMzADmnm0i1X5fSJfBqiTqCzckka9sgukTRQN5ns= github.com/ygrebnov/keys v0.2.0 h1:KQSQG1la9WkTW59WbB3CK1yhxZ92el2ZJfV1XtlHTp0= github.com/ygrebnov/keys v0.2.0/go.mod h1:4IfRPgv7tFSlToKzHtA9MPMwXP0+HRJ0Kk8XSrvhDvQ= -github.com/ygrebnov/log v0.4.4 h1:Zo8yz95bCZzntqxB9QcnrU6mOgQSVTcDXrisX2lMi4Q= -github.com/ygrebnov/log v0.4.4/go.mod h1:iRhzl04ABw1zzc2YBpDTiAPabtO994Pe1xErnhHXmdM= -github.com/ygrebnov/model v0.7.5 h1:9i7Xz5vxYQXeJW06gTE9/In49f0lEDhulmsBKhsQxWw= -github.com/ygrebnov/model v0.7.5/go.mod h1:qYRz8F/yrt01bPyANAlN0Oqi1fwpgvvl21hjW/NK6N0= +github.com/ygrebnov/log v0.5.1 h1:+Kkr6sjOHcYRvzLEDvEsRdDcQPRy0YUtmgBCNdio7Fk= +github.com/ygrebnov/log v0.5.1/go.mod h1:Y21zKtQ3rEy1FDhSli2NvgaqVyig3hhUfxegjLPuknw= +github.com/ygrebnov/model v0.8.1 h1:KvnS97b/q3Z1GKSHSDYlfHoL3bNDR+ZT9Kf4yc1WnIE= +github.com/ygrebnov/model v0.8.1/go.mod h1:WEMMqdGYF45Kfce0pAe0poiF9hu+PONRSHd2L9li3tw= go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y= go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU= -golang.org/x/mod v0.41.0 h1:qJmnOUb4YB+FsEuM3HcWucdZASCPGhsX6uljO6pog0c= -golang.org/x/mod v0.41.0/go.mod h1:Ek9pY8RKWXwsWvd3rQiHYtMqkjSUV+s1Rj7j4H5Ur6o= -golang.org/x/net v0.61.0 h1:RR+6j/BTBCrggOLugxa+66R8FvoN6MHlzDlZIbN9YFw= -golang.org/x/net v0.61.0/go.mod h1:WgDCOTH8iwtB66T4/GfI94AHo/hhdb7Hah9NDseQfiI= -golang.org/x/sync v0.24.0 h1:iqiDrGoDgyuvAKrhLQthUEzU/R378N78gXbBjxed7oA= -golang.org/x/sync v0.24.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0= -golang.org/x/sys v0.49.0 h1:XbzkgYJHdqh/8m2Uu0W/dQv8nktxx4BFHp1M0gROTXA= -golang.org/x/sys v0.49.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og= -golang.org/x/text v0.43.0 h1:1QivrlhwAsnMOcqgOdl9my7s9OyZl8O5/UGUTJVXoWc= -golang.org/x/text v0.43.0/go.mod h1:hbSIYA/amXcRXTFSZqh8tWHEoqRvvbKPJ2uz/KU+a+s= -golang.org/x/tools v0.51.0 h1:k4Xc/1Om9jwkBJBo4NVLMSARBoWtK10mx+W5BnXCeAI= -golang.org/x/tools v0.51.0/go.mod h1:9eEncMayCV6zRMGhR5eZEC2iBx98qWcF1HZ9Z7wJOoA= +golang.org/x/mod v0.42.0 h1:ICeL3t2L30ljSPHHxDnR4fqVcBt/zR2zJAb9juavmQg= +golang.org/x/mod v0.42.0/go.mod h1:u5fzIrRInkL8MaO1cbRkUHT64v303YIT5KEqpNr7jRs= +golang.org/x/net v0.62.0 h1:18ELalfM5+XNRwzM2nYqXsZQ9ByS1uhj2O/U7+5jqRY= +golang.org/x/net v0.62.0/go.mod h1:WgDCOTH8iwtB66T4/GfI94AHo/hhdb7Hah9NDseQfiI= +golang.org/x/sync v0.25.0 h1:dJnifr0nMV8/SBnBvdo4eSGGnrc3O4FFx6IqvtLcmRs= +golang.org/x/sync v0.25.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0= +golang.org/x/sys v0.50.0 h1:dkKZEFTEKaLr1sjhs0WiKqoi8Jj5nHbS3Njmx1UoMJs= +golang.org/x/sys v0.50.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og= +golang.org/x/text v0.44.0 h1:YItdp/mQNGnsmrgpcdA5yQ3bnRxCfo/Tj/iByGW9GGo= +golang.org/x/text v0.44.0/go.mod h1:S4FR1waQ9LbjQTls97SyRjDaUUVkaM+cXwwuG/G+MwY= +golang.org/x/tools v0.52.0 h1:ryxg4U63oaUYk7uOLTF37n43f4qgtGvqV4Ioit1BaEs= +golang.org/x/tools v0.52.0/go.mod h1:ItcP5UNaVGG+Yc4eIYmaFLNJ4soEopkx5Y2d4lcEurs= gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4= gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20261012220534-4341edf3f941 h1:QG6hS4zFplRZvOQedzei4t2pT/zkQc3VR1u+S9/rcAw= -google.golang.org/genproto/googleapis/rpc v0.0.0-20261012220534-4341edf3f941/go.mod h1:OaIUM3+LpYcK2GXM4FTmhWoIq371Owdr+Cc7/BsYHHc= -google.golang.org/grpc v1.84.0 h1:soMyaPJ8pAak5PIQ0DGBUir0XRo2fRoMqhNWMLlLxO0= -google.golang.org/grpc v1.84.0/go.mod h1:ljCht0DrxQrXBDRTZp52Qxh3Ffk8CdYm2sj4O2QN2C0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20261110000943-09e21b237f2c h1:XXChExL+Tm7Ubp0x0VXUEncPLHrkXIgoVWqnxmKNbAA= +google.golang.org/genproto/googleapis/rpc v0.0.0-20261110000943-09e21b237f2c/go.mod h1:OaIUM3+LpYcK2GXM4FTmhWoIq371Owdr+Cc7/BsYHHc= +google.golang.org/grpc v1.85.0 h1:BPBCfuVRQ1qvBhKDOq9uvQllMvO59rKsYhXpp7Dd8vw= +google.golang.org/grpc v1.85.0/go.mod h1:0rQrOD58yjal/0EaVbGBANindixsCZNQPDV3VKtaKuQ= google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc= google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= diff --git a/model/environment.go b/model/environment.go index 99d4437..f5847e2 100644 --- a/model/environment.go +++ b/model/environment.go @@ -5,7 +5,6 @@ import ( "strconv" "github.com/ygrebnov/errorc" - modellib "github.com/ygrebnov/model" "github.com/e2engine/core/pkg/errors" "github.com/e2engine/core/pkg/keys" @@ -13,8 +12,6 @@ import ( type Environment Resource[EnvironmentSpec] -var environmentBinding *modellib.Binding[Environment] - func (e *Environment) Validate(ctx context.Context) error { if e.Kind != ResourceKindEnvironment { return errorc.With( @@ -25,8 +22,13 @@ func (e *Environment) Validate(ctx context.Context) error { ) } - if err := environmentBinding.Validate(ctx, e); err != nil { - return handleValidationError(err, EntityKindEnvironment) + binding, err := getEnvironmentBinding() + if err != nil { + return err + } + + if errValidate := binding.Validate(ctx, e); errValidate != nil { + return handleValidationError(errValidate, EntityKindEnvironment) } if len(e.Spec.Services) == 0 { diff --git a/model/http.go b/model/http.go index 77d2cc2..246b42f 100644 --- a/model/http.go +++ b/model/http.go @@ -119,7 +119,7 @@ func (h *HTTPResponsePattern) Validate() error { return nil } -func getStringMatcherValidJSONRule() (modellib.Rule, error) { +func getStringMatcherValidJSONRule() modellib.Rule { return modellib.NewRule[*matcher.String]("validjson", func(value *matcher.String, _ ...string) error { if value == nil { return nil diff --git a/model/matcher/grpc_message.go b/model/matcher/grpc_message.go index b9ffa23..06039ff 100644 --- a/model/matcher/grpc_message.go +++ b/model/matcher/grpc_message.go @@ -99,7 +99,7 @@ func (m *GRPCMessage) UnmarshalYAML(node *yaml.Node) error { return nil } -func GetGRPCMessageMatcherRule() (modellib.Rule, error) { +func GetGRPCMessageMatcherRule() modellib.Rule { return modellib.NewRule[*GRPCMessage]( "grpcmessagematcher", func(value *GRPCMessage, _ ...string) error { diff --git a/model/matcher/string.go b/model/matcher/string.go index 7369ba9..b9f81ae 100644 --- a/model/matcher/string.go +++ b/model/matcher/string.go @@ -106,7 +106,7 @@ func (m *String) UnmarshalYAML(node *yaml.Node) error { return nil } -func GetStringMatchersRule() (modellib.Rule, error) { +func GetStringMatchersRule() modellib.Rule { return modellib.NewRule[[]String]( "stringmatchers", func(values []String, _ ...string) error { @@ -154,7 +154,7 @@ func GetStringMatchersRule() (modellib.Rule, error) { ) } -func GetStringMatcherRule() (modellib.Rule, error) { +func GetStringMatcherRule() modellib.Rule { return modellib.NewRule[*String]( "stringmatcher", func(value *String, _ ...string) error { diff --git a/model/test.go b/model/test.go index 674e869..dabcfe6 100644 --- a/model/test.go +++ b/model/test.go @@ -5,7 +5,6 @@ import ( "strconv" "github.com/ygrebnov/errorc" - modellib "github.com/ygrebnov/model" "github.com/e2engine/core/pkg/errors" "github.com/e2engine/core/pkg/keys" @@ -13,19 +12,22 @@ import ( type Test Resource[TestSpec] -var testBinding *modellib.Binding[Test] - func (t *Test) Validate(ctx context.Context) error { if t.Kind != ResourceKindTest { return invalidTestSpec(errorc.New("invalid kind"), "Kind") } - if err := testBinding.Validate(ctx, t); err != nil { - return handleValidationError(err, EntityKindTest) + binding, err := getTestBinding() + if err != nil { + return err + } + + if errValidate := binding.Validate(ctx, t); errValidate != nil { + return handleValidationError(errValidate, EntityKindTest) } - if index, err := t.Spec.validateTags(); err != nil { - return invalidTestSpec(err, "Spec.Tags["+strconv.Itoa(index)+"]") + if index, errValidateTags := t.Spec.validateTags(); errValidateTags != nil { + return invalidTestSpec(errValidateTags, "Spec.Tags["+strconv.Itoa(index)+"]") } fields, err := t.Spec.validateProtocol() diff --git a/model/testsuite.go b/model/testsuite.go index 5624645..b2d4a33 100644 --- a/model/testsuite.go +++ b/model/testsuite.go @@ -6,7 +6,6 @@ import ( "strconv" "github.com/ygrebnov/errorc" - modellib "github.com/ygrebnov/model" "github.com/e2engine/core/pkg/errors" "github.com/e2engine/core/pkg/keys" @@ -14,15 +13,18 @@ import ( type TestSuite Resource[TestSuiteSpec] -var testSuiteBinding *modellib.Binding[TestSuite] - func (t *TestSuite) Validate(ctx context.Context) error { if t.Kind != ResourceKindTestSuite { return invalidTestSuiteSpec(nativeerrors.New("invalid kind"), "Kind") } - if err := testSuiteBinding.Validate(ctx, t); err != nil { - return handleValidationError(err, EntityKindTestSuite) + binding, err := getTestSuiteBinding() + if err != nil { + return err + } + + if errValidate := binding.Validate(ctx, t); errValidate != nil { + return handleValidationError(errValidate, EntityKindTestSuite) } if fields, err := t.Spec.Selectors.Validate(); err != nil { diff --git a/model/validation.go b/model/validation.go index ff0fc28..d0877c5 100644 --- a/model/validation.go +++ b/model/validation.go @@ -6,9 +6,9 @@ import ( "net" "net/url" "regexp" - "slices" "strconv" "strings" + "sync" "github.com/ygrebnov/errorc" modellib "github.com/ygrebnov/model" @@ -19,87 +19,67 @@ import ( "github.com/e2engine/core/pkg/keys" ) -var validationRules []modellib.Rule - -func init() { - validationRules = make([]modellib.Rule, 9) - - idRule, err := getIDRule() - if err != nil { - panic(err) - } - - networkAddressRule, err := getNetworkAddressRule() - if err != nil { - panic(err) - } - - httpURLRule, err := getHTTPURLRule() - if err != nil { - panic(err) - } - - validJSONRule, err := getValidJSONRule() - if err != nil { - panic(err) - } - - stringMatcherRule, err := matcher.GetStringMatcherRule() - if err != nil { - panic(err) - } +var ( + rules []modellib.Rule + newRules sync.Once +) - stringMatchersRule, err := matcher.GetStringMatchersRule() - if err != nil { - panic(err) - } +func GetValidationRules() []modellib.Rule { + newRules.Do(func() { + rules = []modellib.Rule{ + getIDRule(), + getNetworkAddressRule(), + getHTTPURLRule(), + getValidJSONRule(), + matcher.GetStringMatcherRule(), + matcher.GetStringMatchersRule(), + getStringMatcherValidJSONRule(), + matcher.GetGRPCMessageMatcherRule(), + getIPRule(), + } + }) - stringMatcherValidJSONRule, err := getStringMatcherValidJSONRule() - if err != nil { - panic(err) - } + return rules +} - grpcMessageMatcherRule, err := matcher.GetGRPCMessageMatcherRule() - if err != nil { - panic(err) - } +var ( + environmentBinding *modellib.Binding[Environment] + testBinding *modellib.Binding[Test] + testSuiteBinding *modellib.Binding[TestSuite] - ipRule, err := getIPRule() - if err != nil { - panic(err) - } + newEnvironmentBinding sync.Once + newTestBinding sync.Once + newTestSuiteBinding sync.Once - validationRules[0] = idRule - validationRules[1] = networkAddressRule - validationRules[2] = httpURLRule - validationRules[3] = validJSONRule - validationRules[4] = stringMatcherRule - validationRules[5] = stringMatchersRule - validationRules[6] = stringMatcherValidJSONRule - validationRules[7] = grpcMessageMatcherRule - validationRules[8] = ipRule - - environmentBinding, err = modellib.NewBinding[Environment](modellib.WithRules(validationRules...)) - if err != nil { - panic(err) - } + environmentBindingErr error + testBindingErr error + testSuiteBindingErr error +) - testBinding, err = modellib.NewBinding[Test](modellib.WithRules(validationRules...)) - if err != nil { - panic(err) - } +func getEnvironmentBinding() (*modellib.Binding[Environment], error) { + newEnvironmentBinding.Do(func() { + environmentBinding, environmentBindingErr = + modellib.NewBinding[Environment](modellib.WithRules(GetValidationRules()...)) + }) + return environmentBinding, environmentBindingErr +} - testSuiteBinding, err = modellib.NewBinding[TestSuite](modellib.WithRules(validationRules...)) - if err != nil { - panic(err) - } +func getTestBinding() (*modellib.Binding[Test], error) { + newTestBinding.Do(func() { + testBinding, testBindingErr = modellib.NewBinding[Test](modellib.WithRules(GetValidationRules()...)) + }) + return testBinding, testBindingErr } -func GetValidationRules() []modellib.Rule { - return slices.Clone(validationRules) +func getTestSuiteBinding() (*modellib.Binding[TestSuite], error) { + newTestSuiteBinding.Do(func() { + testSuiteBinding, testSuiteBindingErr = + modellib.NewBinding[TestSuite](modellib.WithRules(GetValidationRules()...)) + }) + return testSuiteBinding, testSuiteBindingErr } -func getIDRule() (modellib.Rule, error) { +func getIDRule() modellib.Rule { return modellib.NewRule("id", func(v string, _ ...string) error { r := regexp.MustCompile("^[a-z0-9]{64}$") if !r.MatchString(v) { @@ -110,7 +90,7 @@ func getIDRule() (modellib.Rule, error) { }) } -func getNetworkAddressRule() (modellib.Rule, error) { +func getNetworkAddressRule() modellib.Rule { return modellib.NewRule[string]("networkaddress", func(address string, _ ...string) error { return validateNetworkAddress(address) }) @@ -138,7 +118,7 @@ func validateNetworkAddress(address string) error { return nil } -func getHTTPURLRule() (modellib.Rule, error) { +func getHTTPURLRule() modellib.Rule { return modellib.NewRule[string]( "httpurl", func(value string, _ ...string) error { @@ -179,7 +159,7 @@ func validateHTTPURL(value string) error { return nil } -func getValidJSONRule() (modellib.Rule, error) { +func getValidJSONRule() modellib.Rule { return modellib.NewRule[string]("validjson", func(value string, _ ...string) error { if !json.Valid([]byte(value)) { return errorc.New("value must contain valid JSON") @@ -189,7 +169,7 @@ func getValidJSONRule() (modellib.Rule, error) { }) } -func getIPRule() (modellib.Rule, error) { +func getIPRule() modellib.Rule { return modellib.NewRule[string]("ip", func(ip string, _ ...string) error { if net.ParseIP(ip) == nil { return errorc.New("invalid E2Engine listen interface IP address") diff --git a/tools/go.mod b/tools/go.mod index 0ae7a0e..fdcdc19 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -3,7 +3,7 @@ module tools go 1.27 require ( - github.com/golangci/golangci-lint/v2 v2.14.0 + github.com/golangci/golangci-lint/v2 v2.15.0 go.uber.org/mock v0.6.0 golang.org/x/vuln v1.9.0 ) @@ -44,7 +44,7 @@ require ( github.com/blizzy78/varnamelen v0.8.0 // indirect github.com/bombsimon/wsl/v4 v4.7.0 // indirect github.com/bombsimon/wsl/v5 v5.9.0 // indirect - github.com/breml/bidichk v0.3.3 // indirect + github.com/breml/bidichk v0.3.4 // indirect github.com/breml/errchkjson v0.4.1 // indirect github.com/butuzov/ireturn v0.4.1 // indirect github.com/butuzov/mirror v1.3.3 // indirect @@ -63,7 +63,7 @@ require ( github.com/clipperhouse/uax29/v2 v2.7.0 // indirect github.com/curioswitch/go-reassign v0.3.0 // indirect github.com/daixiang0/gci v0.13.7 // indirect - github.com/dave/dst v0.27.3 // indirect + github.com/dave/dst v0.28.0 // indirect github.com/denis-tingaikin/go-header v0.5.0 // indirect github.com/dlclark/regexp2/v2 v2.2.1 // indirect github.com/ettle/strcase v0.2.0 // indirect @@ -88,15 +88,15 @@ require ( github.com/gofrs/flock v0.13.1 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/golangci/asciicheck v0.5.0 // indirect - github.com/golangci/canonicalheader v0.0.0-20260827115959-a25c71c521f6 // indirect + github.com/golangci/canonicalheader v0.0.0-20260928145534-e18e5c5a078f // indirect github.com/golangci/dupl v0.0.0-20260401084720-c99c5cf5c202 // indirect github.com/golangci/go-printf-func-name v0.1.1 // indirect github.com/golangci/gofmt v0.0.0-20260820135601-e84e05053792 // indirect - github.com/golangci/golines v0.15.0 // indirect + github.com/golangci/golines v0.16.0 // indirect github.com/golangci/misspell v0.8.0 // indirect github.com/golangci/plugin-module-register v0.1.2 // indirect github.com/golangci/revgrep v0.8.0 // indirect - github.com/golangci/rowserrcheck v0.0.0-20260419091836-c5f79b8a11ba // indirect + github.com/golangci/rowserrcheck v0.0.0-20261005233414-e0740d52dee8 // indirect github.com/golangci/swaggoswag v0.0.0-20250504205917-77f2aca3143e // indirect github.com/golangci/unconvert v0.0.0-20250410112200-a129a6e6413e // indirect github.com/google/go-cmp v0.7.0 // indirect @@ -115,10 +115,10 @@ require ( github.com/jjti/go-spancheck v0.6.5 // indirect github.com/julz/importas v0.2.0 // indirect github.com/karamaru-alpha/copyloopvar v1.2.2 // indirect - github.com/kisielk/errcheck v1.20.0 // indirect + github.com/kisielk/errcheck v1.30.0 // indirect github.com/kkHAIKE/contextcheck v1.1.6 // indirect github.com/kulti/thelper v0.7.1 // indirect - github.com/kunwardeep/paralleltest v1.0.15 // indirect + github.com/kunwardeep/paralleltest v1.0.16 // indirect github.com/ldez/exptostd v0.4.5 // indirect github.com/ldez/gomoddirectives v0.10.0 // indirect github.com/ldez/grignotin v0.10.1 // indirect @@ -134,18 +134,18 @@ require ( github.com/maratori/testableexamples v1.0.1 // indirect github.com/maratori/testpackage v1.1.2 // indirect github.com/matoous/godox v1.1.0 // indirect - github.com/mattn/go-colorable v0.1.15 // indirect + github.com/mattn/go-colorable v0.1.16 // indirect github.com/mattn/go-isatty v0.0.22 // indirect github.com/mattn/go-runewidth v0.0.24 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect - github.com/mgechev/revive v1.17.0 // indirect + github.com/mgechev/revive v1.17.1 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/moricho/tparallel v0.3.2 // indirect github.com/muesli/cancelreader v0.2.2 // indirect github.com/nakabonne/nestif v0.3.1 // indirect - github.com/nishanths/exhaustive v0.13.0 // indirect - github.com/nishanths/predeclared v0.2.2 // indirect + github.com/nishanths/exhaustive v0.15.0 // indirect + github.com/nishanths/predeclared v0.3.0 // indirect github.com/nunnatsa/ginkgolinter v0.24.0 // indirect github.com/pelletier/go-toml v1.9.5 // indirect github.com/pelletier/go-toml/v2 v2.4.3 // indirect @@ -186,13 +186,13 @@ require ( github.com/subosito/gotenv v1.4.1 // indirect github.com/tetafro/godot v1.5.6 // indirect github.com/timakin/bodyclose v0.0.0-20260723120731-857993a2939c // indirect - github.com/timonwong/loggercheck v0.12.0 // indirect - github.com/tomarrell/wrapcheck/v2 v2.12.0 // indirect + github.com/timonwong/loggercheck v0.13.0 // indirect + github.com/tomarrell/wrapcheck/v2 v2.13.0 // indirect github.com/tommy-muehle/go-mnd/v2 v2.5.1 // indirect github.com/ultraware/funlen v0.2.0 // indirect github.com/ultraware/whitespace v0.2.0 // indirect - github.com/uudashr/gocognit v1.2.1 // indirect - github.com/uudashr/iface v1.5.1 // indirect + github.com/uudashr/gocognit v1.3.0 // indirect + github.com/uudashr/iface v1.5.3 // indirect github.com/xen0n/gosmopolitan v1.3.0 // indirect github.com/xo/terminfo v1.0.0 // indirect github.com/yagipy/maintidx v1.0.0 // indirect @@ -217,7 +217,7 @@ require ( gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - honnef.co/go/tools v0.8.1 // indirect + honnef.co/go/tools v0.8.2 // indirect mvdan.cc/gofumpt v0.12.0 // indirect mvdan.cc/unparam v0.0.0-20260823230713-2fa3d841b0c8 // indirect ) diff --git a/tools/go.sum b/tools/go.sum index ebc81a7..57c0ed0 100644 --- a/tools/go.sum +++ b/tools/go.sum @@ -114,8 +114,8 @@ github.com/bombsimon/wsl/v4 v4.7.0 h1:1Ilm9JBPRczjyUs6hvOPKvd7VL1Q++PL8M0SXBDf+j github.com/bombsimon/wsl/v4 v4.7.0/go.mod h1:uV/+6BkffuzSAVYD+yGyld1AChO7/EuLrCF/8xTiapg= github.com/bombsimon/wsl/v5 v5.9.0 h1:WCrgZ7RQnZO5oEwbVTlYgBdU3wL294kR1BSWV8vTfsU= github.com/bombsimon/wsl/v5 v5.9.0/go.mod h1:kjo4HiAV5FDkHC8/uzJq9mBffEEd6WT/nvN7DoMovDM= -github.com/breml/bidichk v0.3.3 h1:WSM67ztRusf1sMoqH6/c4OBCUlRVTKq+CbSeo0R17sE= -github.com/breml/bidichk v0.3.3/go.mod h1:ISbsut8OnjB367j5NseXEGGgO/th206dVa427kR8YTE= +github.com/breml/bidichk v0.3.4 h1:70G6w80G6GDZTUURHTC5gBKVjMLMw2736CzXquSf5Ek= +github.com/breml/bidichk v0.3.4/go.mod h1:GOHprnh4i0V7HrvWjtbvbpicTUcqoYt9zYESKcJkk4M= github.com/breml/errchkjson v0.4.1 h1:keFSS8D7A2T0haP9kzZTi7o26r7kE3vymjZNeNDRDwg= github.com/breml/errchkjson v0.4.1/go.mod h1:a23OvR6Qvcl7DG/Z4o0el6BRAjKnaReoPQFciAl9U3s= github.com/butuzov/ireturn v0.4.1 h1:vWb3NO4t77iku/sjCQ/2pHTQeOmxEhjIriJqRLg1Y+I= @@ -161,8 +161,8 @@ github.com/curioswitch/go-reassign v0.3.0 h1:dh3kpQHuADL3cobV/sSGETA8DOv457dwl+f github.com/curioswitch/go-reassign v0.3.0/go.mod h1:nApPCCTtqLJN/s8HfItCcKV0jIPwluBOvZP+dsJGA88= github.com/daixiang0/gci v0.13.7 h1:+0bG5eK9vlI08J+J/NWGbWPTNiXPG4WhNLJOkSxWITQ= github.com/daixiang0/gci v0.13.7/go.mod h1:812WVN6JLFY9S6Tv76twqmNqevN0pa3SX3nih0brVzQ= -github.com/dave/dst v0.27.3 h1:P1HPoMza3cMEquVf9kKy8yXsFirry4zEnWOdYPOoIzY= -github.com/dave/dst v0.27.3/go.mod h1:jHh6EOibnHgcUW3WjKHisiooEkYwqpHLBSX1iOBhEyc= +github.com/dave/dst v0.28.0 h1:EIEuRC5XmVKuZF2OeyMahXX9ARVt6Xxr8vI0WtIY7K8= +github.com/dave/dst v0.28.0/go.mod h1:C4mfimBeSHfsgskhR/mUYSE05s2ih+PW6g9FP3c49tE= github.com/dave/jennifer v1.7.1 h1:B4jJJDHelWcDhlRQxWeo0Npa/pYKBLrirAQoTN45txo= github.com/dave/jennifer v1.7.1/go.mod h1:nXbxhEmQfOZhWml3D1cDK5M1FLnMSozpbFN/m3RmGZc= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -273,26 +273,26 @@ github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golangci/asciicheck v0.5.0 h1:jczN/BorERZwK8oiFBOGvlGPknhvq0bjnysTj4nUfo0= github.com/golangci/asciicheck v0.5.0/go.mod h1:5RMNAInbNFw2krqN6ibBxN/zfRFa9S6tA1nPdM0l8qQ= -github.com/golangci/canonicalheader v0.0.0-20260827115959-a25c71c521f6 h1:fVLolA3dG6s0brGetsiDAtcnpMSwVa2LqXJEw/9RJG4= -github.com/golangci/canonicalheader v0.0.0-20260827115959-a25c71c521f6/go.mod h1:1xo+NFW5S+bEf2DKXhaxuzvcDN5AR6o/KMwvqC5Mkpo= +github.com/golangci/canonicalheader v0.0.0-20260928145534-e18e5c5a078f h1:pOnwRNeWLPkADfkgqKcCP7RPQAS9OIzffaBaktRsKnk= +github.com/golangci/canonicalheader v0.0.0-20260928145534-e18e5c5a078f/go.mod h1:aXo+AVSX0pC3TRo2wAfR92YwBKfG6C2eal+omjKXwYw= github.com/golangci/dupl v0.0.0-20260401084720-c99c5cf5c202 h1:CbTB8KpqnViI6lIXxp03Oclc4VFHi3K4BWC1TacsZ+A= github.com/golangci/dupl v0.0.0-20260401084720-c99c5cf5c202/go.mod h1:NUw9Zr2Sy7+HxzdjIULge71wI6yEg1lWQr7Evcu8K0E= github.com/golangci/go-printf-func-name v0.1.1 h1:hIYTFJqAGp1iwoIfsNTpoq1xZAarogrvjO9AfiW3B4U= github.com/golangci/go-printf-func-name v0.1.1/go.mod h1:Es64MpWEZbh0UBtTAICOZiB+miW53w/K9Or/4QogJss= github.com/golangci/gofmt v0.0.0-20260820135601-e84e05053792 h1:WL8YKrt3UbOBqSRU7GpP5BTtQTMWtVtj+mfPijgZeIg= github.com/golangci/gofmt v0.0.0-20260820135601-e84e05053792/go.mod h1:te5hX0dW4C5r6YbXs+6ysNr8Q5UTmdIqGbb+mlFiYmA= -github.com/golangci/golangci-lint/v2 v2.14.0 h1:ot8QffRa4LzAAEgtvNYrVs9esxQ7xoTwoAv6uhp4ngA= -github.com/golangci/golangci-lint/v2 v2.14.0/go.mod h1:amHimCzNDP1GfVno3hIiNssjvqXmuW+CPZAHOdR4cIc= -github.com/golangci/golines v0.15.0 h1:Qnph25g8Y1c5fdo1X7GaRDGgnMHgnxh4Gk4VfPTtRx0= -github.com/golangci/golines v0.15.0/go.mod h1:AZjXd23tbHMpowhtnGlj9KCNsysj72aeZVVHnVcZx10= +github.com/golangci/golangci-lint/v2 v2.15.0 h1:w94zf8HAYI7hm3164kwKsvZRuqXvY+YxeFoTbu1OLg8= +github.com/golangci/golangci-lint/v2 v2.15.0/go.mod h1:/FRI304IxqDVhX2o3ZZ0qp8Vvz8egJdzCY5A4GjvmTU= +github.com/golangci/golines v0.16.0 h1:xKdwzRvwzLd7V131B/dv90vUiEoTA0vQybdeqperPOg= +github.com/golangci/golines v0.16.0/go.mod h1:mCMgRQHiCvuALJOeaNtylu09zbzvS9Ka01dfvLLJios= github.com/golangci/misspell v0.8.0 h1:qvxQhiE2/5z+BVRo1kwYA8yGz+lOlu5Jfvtx2b04Jbg= github.com/golangci/misspell v0.8.0/go.mod h1:WZyyI2P3hxPY2UVHs3cS8YcllAeyfquQcKfdeE9AFVg= github.com/golangci/plugin-module-register v0.1.2 h1:e5WM6PO6NIAEcij3B053CohVp3HIYbzSuP53UAYgOpg= github.com/golangci/plugin-module-register v0.1.2/go.mod h1:1+QGTsKBvAIvPvoY/os+G5eoqxWn70HYDm2uvUyGuVw= github.com/golangci/revgrep v0.8.0 h1:EZBctwbVd0aMeRnNUsFogoyayvKHyxlV3CdUA46FX2s= github.com/golangci/revgrep v0.8.0/go.mod h1:U4R/s9dlXZsg8uJmaR1GrloUr14D7qDl8gi2iPXJH8k= -github.com/golangci/rowserrcheck v0.0.0-20260419091836-c5f79b8a11ba h1:lqtcnSMDuuJdu/LrKWi5RJzpSNLOJXYe/nzQutTI5kg= -github.com/golangci/rowserrcheck v0.0.0-20260419091836-c5f79b8a11ba/go.mod h1:sCBNcpRmhJCtbFGz49+IM3ETTFf7QdJ30AeYCd43NKk= +github.com/golangci/rowserrcheck v0.0.0-20261005233414-e0740d52dee8 h1:oN042y1yEcpldrqY81puyNA4ZjQZJzt0U/t7HyYrMic= +github.com/golangci/rowserrcheck v0.0.0-20261005233414-e0740d52dee8/go.mod h1:T1Bg58Sk3N352aBbPLJPpHykFWxEEwV3o4/Enn+PPU8= github.com/golangci/swaggoswag v0.0.0-20250504205917-77f2aca3143e h1:ai0EfmVYE2bRA5htgAG9r7s3tHsfjIhN98WshBTJ9jM= github.com/golangci/swaggoswag v0.0.0-20250504205917-77f2aca3143e/go.mod h1:Vrn4B5oR9qRwM+f54koyeH3yzphlecwERs0el27Fr/s= github.com/golangci/unconvert v0.0.0-20250410112200-a129a6e6413e h1:gD6P7NEo7Eqtt0ssnqSJNNndxe69DOQ24A5h7+i3KpM= @@ -379,8 +379,8 @@ github.com/julz/importas v0.2.0 h1:y+MJN/UdL63QbFJHws9BVC5RpA2iq0kpjrFajTGivjQ= github.com/julz/importas v0.2.0/go.mod h1:pThlt589EnCYtMnmhmRYY/qn9lCf/frPOK+WMx3xiJY= github.com/karamaru-alpha/copyloopvar v1.2.2 h1:yfNQvP9YaGQR7VaWLYcfZUlRP2eo2vhExWKxD/fP6q0= github.com/karamaru-alpha/copyloopvar v1.2.2/go.mod h1:oY4rGZqZ879JkJMtX3RRkcXRkmUvH0x35ykgaKgsgJY= -github.com/kisielk/errcheck v1.20.0 h1:9rwHBNKzd4wkDWcROy3DvFGNqEPlkxBg305rvk7HabI= -github.com/kisielk/errcheck v1.20.0/go.mod h1:O+f80MKNwX8Oor2jwgpeQ9An7uJm+hRSgT+h22knRJU= +github.com/kisielk/errcheck v1.30.0 h1:ZIxNDAfAd4larXHTceoZP/dYPAB90dHg1OYhA2sVh5k= +github.com/kisielk/errcheck v1.30.0/go.mod h1:uiCAInmFuyOje4VDdbQSP9mgqf5gORYSXrDf19XilsI= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkHAIKE/contextcheck v1.1.6 h1:7HIyRcnyzxL9Lz06NGhiKvenXq7Zw6Q0UQu/ttjfJCE= github.com/kkHAIKE/contextcheck v1.1.6/go.mod h1:3dDbMRNBFaq8HFXWC1JyvDSPm43CmE6IuHam8Wr0rkg= @@ -396,8 +396,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kulti/thelper v0.7.1 h1:fI8QITAoFVLx+y+vSyuLBP+rcVIB8jKooNSCT2EiI98= github.com/kulti/thelper v0.7.1/go.mod h1:NsMjfQEy6sd+9Kfw8kCP61W1I0nerGSYSFnGaxQkcbs= -github.com/kunwardeep/paralleltest v1.0.15 h1:ZMk4Qt306tHIgKISHWFJAO1IDQJLc6uDyJMLyncOb6w= -github.com/kunwardeep/paralleltest v1.0.15/go.mod h1:di4moFqtfz3ToSKxhNjhOZL+696QtJGCFe132CbBLGk= +github.com/kunwardeep/paralleltest v1.0.16 h1:I0gQkLNgfigjpxWAGhx7PYj3VpswzfGrSV/715t6g+o= +github.com/kunwardeep/paralleltest v1.0.16/go.mod h1:di4moFqtfz3ToSKxhNjhOZL+696QtJGCFe132CbBLGk= github.com/ldez/exptostd v0.4.5 h1:kv2ZGUVI6VwRfp/+bcQ6Nbx0ghFWcGIKInkG/oFn1aQ= github.com/ldez/exptostd v0.4.5/go.mod h1:QRjHRMXJrCTIm9WxVNH6VW7oN7KrGSht69bIRwvdFsM= github.com/ldez/gomoddirectives v0.10.0 h1:Zb23rfMMkG21B6pZ9OfESzemByP5Qr7YvWcXQZE/S3Q= @@ -430,16 +430,16 @@ github.com/matoous/godox v1.1.0 h1:W5mqwbyWrwZv6OQ5Z1a/DHGMOvXYCBP3+Ht7KMoJhq4= github.com/matoous/godox v1.1.0/go.mod h1:jgE/3fUXiTurkdHOLT5WEkThTSuE7yxHv5iWPa80afs= github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE= github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU= -github.com/mattn/go-colorable v0.1.15 h1:+u9SLTRGnXv73cEsnsmoZBom+dMU88B2M0aDcWy0/jY= -github.com/mattn/go-colorable v0.1.15/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= +github.com/mattn/go-colorable v0.1.16 h1:+2YjeAe7xP1OQbZW1jERPWWCDLlNqFNCvjiqGiAt84A= +github.com/mattn/go-colorable v0.1.16/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= github.com/mattn/go-isatty v0.0.22 h1:j8l17JJ9i6VGPUFUYoTUKPSgKe/83EYU2zBC7YNKMw4= github.com/mattn/go-isatty v0.0.22/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4= github.com/mattn/go-runewidth v0.0.24 h1:cpokDiIn0MGnhdHwuWnJBITySJ20QyNGnY2kR/ay2DU= github.com/mattn/go-runewidth v0.0.24/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/mgechev/revive v1.17.0 h1:hwTTVC3svSv9X2FA2hiYT17Uws+lfxDWhPxzBZZCREg= -github.com/mgechev/revive v1.17.0/go.mod h1:uiVNUF8ruVh4WHm/aPs7kKEeuo+m6oO3tuOfniyzP/g= +github.com/mgechev/revive v1.17.1 h1:z8hV0L3uJ6yrwOMnJbkc5qBJpxXa2AxYKFKERGJyA4s= +github.com/mgechev/revive v1.17.1/go.mod h1:FRd64pJwWSEE6j8ESoaX0PixPzjh2rpNSfckbEu3rIE= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= @@ -457,10 +457,10 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nakabonne/nestif v0.3.1 h1:wm28nZjhQY5HyYPx+weN3Q65k6ilSBxDb8v5S81B81U= github.com/nakabonne/nestif v0.3.1/go.mod h1:9EtoZochLn5iUprVDmDjqGKPofoUEBL8U4Ngq6aY7OE= -github.com/nishanths/exhaustive v0.13.0 h1:Rof0axOSNQaaPaPmLK5RxcRrJV2Vcv+vfUmuRy+2EAM= -github.com/nishanths/exhaustive v0.13.0/go.mod h1:3/adQjJgvD/UFHHSYBjpK9Wbz8DOvf0FBtzx+zI0Rlo= -github.com/nishanths/predeclared v0.2.2 h1:V2EPdZPliZymNAn79T8RkNApBjMmVKh5XRpLm/w98Vk= -github.com/nishanths/predeclared v0.2.2/go.mod h1:RROzoN6TnGQupbC+lqggsOlcgysk3LMK/HI84Mp280c= +github.com/nishanths/exhaustive v0.15.0 h1:uFjiO/WvrwQG+ojSZ+vtl/jAFbqA2oAtfpUWK/iKQ8M= +github.com/nishanths/exhaustive v0.15.0/go.mod h1:2by9rYmg9FnsnLQC4Ixig4fQaWxRsY7RluxJuAu9sa0= +github.com/nishanths/predeclared v0.3.0 h1:W3i3JK/DZS5h7QwsEIyU8ler4Z2vwEwQSxNrZzhnlfk= +github.com/nishanths/predeclared v0.3.0/go.mod h1:gN4uryPExDME/zmZdqkKIPSAqcfprj316ZDI6UTqz70= github.com/nunnatsa/ginkgolinter v0.24.0 h1:Mp0EagluLFP98JatP6nqp/gGEoljNG97uf9AcxcBVy8= github.com/nunnatsa/ginkgolinter v0.24.0/go.mod h1:2ZMRuzX6+3XXyY6UZOwb6n+MCocVGbkIsDBC4vuWz5c= github.com/onsi/ginkgo/v2 v2.32.1 h1:6tlvcDm/3sE8lGJbZ4+d4mO3RLy24/tQWOFzVSQNIfw= @@ -588,20 +588,20 @@ github.com/tetafro/godot v1.5.6 h1:IEkrFCwXaYHlOn4mGzGS3F3dkP6m9t0jpwqBFPIkKiA= github.com/tetafro/godot v1.5.6/go.mod h1:eOkMrVQurDui411nBY2FA05EYH01r14LuWY/NrVDVcU= github.com/timakin/bodyclose v0.0.0-20260723120731-857993a2939c h1:d/FUP8GD4QiY/rdFzZmBu3KqL9eBNVzMu7W/5pGkaMM= github.com/timakin/bodyclose v0.0.0-20260723120731-857993a2939c/go.mod h1:sDHLK7rb/59v/ZxZ7KtymgcoxuUMxjXq8gtu9VMOK8M= -github.com/timonwong/loggercheck v0.12.0 h1:7Cb9XGLJZSWYNjgL459DIhpSiEHupD+MLQ6vaN2Pl3g= -github.com/timonwong/loggercheck v0.12.0/go.mod h1:Wa6Y+SJHQR01mViZlLLY5GAZVOWOLNMbkXddMjFWQCs= -github.com/tomarrell/wrapcheck/v2 v2.12.0 h1:H/qQ1aNWz/eeIhxKAFvkfIA+N7YDvq6TWVFL27Of9is= -github.com/tomarrell/wrapcheck/v2 v2.12.0/go.mod h1:AQhQuZd0p7b6rfW+vUwHm5OMCGgp63moQ9Qr/0BpIWo= +github.com/timonwong/loggercheck v0.13.0 h1:6amIOmLLPFYt24rXUbNWzcJeNGuJc+3c31tZtO85VHs= +github.com/timonwong/loggercheck v0.13.0/go.mod h1:thn3allpox0fI5JeUWTCwiwp45peQxCZZHkHuA1Oc6I= +github.com/tomarrell/wrapcheck/v2 v2.13.0 h1:jYbLNs8PDkzGCY6d5LUzJdY7Bq//CTlb2HxZGV5z0JY= +github.com/tomarrell/wrapcheck/v2 v2.13.0/go.mod h1:AQhQuZd0p7b6rfW+vUwHm5OMCGgp63moQ9Qr/0BpIWo= github.com/tommy-muehle/go-mnd/v2 v2.5.1 h1:NowYhSdyE/1zwK9QCLeRb6USWdoif80Ie+v+yU8u1Zw= github.com/tommy-muehle/go-mnd/v2 v2.5.1/go.mod h1:WsUAkMJMYww6l/ufffCD3m+P7LEvr8TnZn9lwVDlgzw= github.com/ultraware/funlen v0.2.0 h1:gCHmCn+d2/1SemTdYMiKLAHFYxTYz7z9VIDRaTGyLkI= github.com/ultraware/funlen v0.2.0/go.mod h1:ZE0q4TsJ8T1SQcjmkhN/w+MceuatI6pBFSxxyteHIJA= github.com/ultraware/whitespace v0.2.0 h1:TYowo2m9Nfj1baEQBjuHzvMRbp19i+RCcRYrSWoFa+g= github.com/ultraware/whitespace v0.2.0/go.mod h1:XcP1RLD81eV4BW8UhQlpaR+SDc2givTvyI8a586WjW8= -github.com/uudashr/gocognit v1.2.1 h1:CSJynt5txTnORn/DkhiB4mZjwPuifyASC8/6Q0I/QS4= -github.com/uudashr/gocognit v1.2.1/go.mod h1:acaubQc6xYlXFEMb9nWX2dYBzJ/bIjEkc1zzvyIZg5Q= -github.com/uudashr/iface v1.5.1 h1:BS3yrgaT55s3dAtJoxuTnsZNbsejq/mVuzp49YDyfBA= -github.com/uudashr/iface v1.5.1/go.mod h1:5UWoT6SvTdTww/KToRj6clO+n4Kg3/NrAQvgOB+5Ggw= +github.com/uudashr/gocognit v1.3.0 h1:Xdw5JwAoYmX3WAB+wsXY3nxEwdw7+MWAnM0wCAAv7A4= +github.com/uudashr/gocognit v1.3.0/go.mod h1:acaubQc6xYlXFEMb9nWX2dYBzJ/bIjEkc1zzvyIZg5Q= +github.com/uudashr/iface v1.5.3 h1:N61bzr11L7BHP6Rct+C6zQePHjSTMeyVBq+s03uB/Ds= +github.com/uudashr/iface v1.5.3/go.mod h1:5UWoT6SvTdTww/KToRj6clO+n4Kg3/NrAQvgOB+5Ggw= github.com/xen0n/gosmopolitan v1.3.0 h1:zAZI1zefvo7gcpbCOrPSHJZJYA9ZgLfJqtKzZ5pHqQM= github.com/xen0n/gosmopolitan v1.3.0/go.mod h1:rckfr5T6o4lBtM1ga7mLGKZmLxswUoH1zxHgNXOsEt4= github.com/xo/terminfo v1.0.0 h1:2ZpYzqWzyyytjk3TP6aJVDhkMAkc99/1xKQdA3TDTBY= @@ -975,8 +975,8 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.8.1 h1:+JKf3xJ1ni4CwrhVg4/pqsfPGP6vNAXcKbMXJodYx3w= -honnef.co/go/tools v0.8.1/go.mod h1:XA+OnlRA9EDh/ukGvXMNSZNKGwFQJ+5dER0ioUkOxks= +honnef.co/go/tools v0.8.2 h1:+jPbCzuYxYrcoOvCecYUFDj+XJQRmzIhJmlbpps21Zk= +honnef.co/go/tools v0.8.2/go.mod h1:xG1Q4n+mg3bKZrO6RWFA9jFlkqplflmDRHGeuexiLDs= mvdan.cc/gofumpt v0.12.0 h1:1Lbudkz2kpM9Cjz2pL4M19u7q+GaEhCTNf7N9mfpcho= mvdan.cc/gofumpt v0.12.0/go.mod h1:SmBHHrljiZu/uoypeKup3rFzP6eoC9UwCp2iH5E3jZA= mvdan.cc/unparam v0.0.0-20260823230713-2fa3d841b0c8 h1:Re1NRyLpiAt9kB+ImaaoapwWiQXrKwER4tY8fLOkDew= From 9056212011cb3917bc9193162d894a9d42570291 Mon Sep 17 00:00:00 2001 From: Yaroslav Grebnov Date: Sat, 14 Nov 2026 16:48:52 +0100 Subject: [PATCH 2/3] Fix executionID forwarding --- execute/runtime/router/grpc/router.go | 1 + execute/runtime/router/grpc/router_test.go | 94 +++++++++++++-- execute/runtime/router/http/request_test.go | 7 +- execute/runtime/router/http/router.go | 14 ++- execute/runtime/router/http/router_test.go | 125 ++++++++++++++++++-- execute/worker/grpc/executor_test.go | 18 +-- execute/worker/http/executor_test.go | 35 +++--- 7 files changed, 248 insertions(+), 46 deletions(-) diff --git a/execute/runtime/router/grpc/router.go b/execute/runtime/router/grpc/router.go index c4f0402..08cdccc 100644 --- a/execute/runtime/router/grpc/router.go +++ b/execute/runtime/router/grpc/router.go @@ -278,6 +278,7 @@ func (r *Router) newHandler( ctx, incomingMetadata.Copy(), ) + outgoingContext = e2enginegrpc.Inject(outgoingContext) var response rawMessage var responseHeader metadata.MD diff --git a/execute/runtime/router/grpc/router_test.go b/execute/runtime/router/grpc/router_test.go index 9e3095d..89c36e6 100644 --- a/execute/runtime/router/grpc/router_test.go +++ b/execute/runtime/router/grpc/router_test.go @@ -22,6 +22,84 @@ import ( "github.com/e2engine/core/pkg/log" ) +const testExecutionID = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + +func TestRouterNormalizesExecutionIDUpstream(t *testing.T) { + upstreamMetadata := make(chan metadata.MD, 1) + upstream := newTestGRPCServer(t, func(_ any, stream grpcpkg.ServerStream) error { + var request rawMessage + if err := stream.RecvMsg(&request); err != nil { + return err + } + md, _ := metadata.FromIncomingContext(stream.Context()) + upstreamMetadata <- md.Copy() + return stream.SendMsg(&request) + }) + defer upstream.stop() + + store := call.NewStoreFactory(&call.Config{ + MaxCalls: 10, + MaxRecordedBytes: 1024 * 1024, + }).New() + router := newTestGRPCRouter(t, store) + router.Register(&runtime.Route{ + ServiceID: "service-1", + ListenAddress: "127.0.0.1:0", + RuntimeAddress: upstream.address(), + }) + if err := router.Mount(t.Context()); err != nil { + t.Fatalf("Mount() error = %v", err) + } + defer func() { + if err := router.Unmount(context.Background()); err != nil { + t.Errorf("Unmount() error = %v", err) + } + }() + + connection, err := grpcpkg.NewClient( + router.mounted[0].listener.Addr().String(), + grpcpkg.WithTransportCredentials(insecure.NewCredentials()), + grpcpkg.WithDefaultCallOptions(grpcpkg.ForceCodec(rawCodec{})), + ) + if err != nil { + t.Fatalf("NewClient() error = %v", err) + } + defer connection.Close() + + tests := []struct { + name string + values []string + want []string + }{ + {name: "valid", values: []string{testExecutionID}, want: []string{testExecutionID}}, + {name: "invalid", values: []string{"execution-1"}}, + {name: "multiple", values: []string{testExecutionID, testExecutionID}}, + {name: "missing"}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + md := metadata.Pairs("x-test", "preserved") + for _, value := range tt.values { + md.Append("e2engine-test-execution-id", value) + } + ctx := metadata.NewOutgoingContext(t.Context(), md) + request := rawMessage{1, 2, 3} + var response rawMessage + if err := connection.Invoke(ctx, "/test.Service/Method", &request, &response); err != nil { + t.Fatalf("Invoke() error = %v", err) + } + + got := <-upstreamMetadata + if values := got.Get("e2engine-test-execution-id"); !slices.Equal(values, tt.want) { + t.Errorf("upstream execution IDs = %q, want %q", values, tt.want) + } + if values := got.Get("x-test"); !slices.Equal(values, []string{"preserved"}) { + t.Errorf("upstream x-test = %q, want [preserved]", values) + } + }) + } +} + func TestRawCodec(t *testing.T) { codec := rawCodec{} @@ -225,7 +303,7 @@ func TestRouter(t *testing.T) { "x-request", "request-value", ), - "execution-1", + testExecutionID, ), ) @@ -293,7 +371,7 @@ func TestRouter(t *testing.T) { } calls := store.Get(call.Filter{ - TestExecutionID: "execution-1", + TestExecutionID: testExecutionID, ServiceID: "service-1", }) @@ -473,7 +551,7 @@ func TestRouterMessageSizeLimit(t *testing.T) { t.Context(), e2enginegrpc.WithTestExecutionID( nil, - "execution-1", + testExecutionID, ), ) @@ -505,7 +583,7 @@ func TestRouterMessageSizeLimit(t *testing.T) { } calls := store.Get(call.Filter{ - TestExecutionID: "execution-1", + TestExecutionID: testExecutionID, ServiceID: "service-1", }) @@ -616,7 +694,7 @@ func TestRouterUpstreamError(t *testing.T) { context.Background(), e2enginegrpc.WithTestExecutionID( nil, - "execution-1", + testExecutionID, ), ) @@ -638,7 +716,7 @@ func TestRouterUpstreamError(t *testing.T) { } calls := store.Get(call.Filter{ - TestExecutionID: "execution-1", + TestExecutionID: testExecutionID, ServiceID: "service-1", }) @@ -1084,7 +1162,7 @@ func TestRouterMetadataSizeLimit(t *testing.T) { "x-request", tt.requestValue, ), - "execution-1", + testExecutionID, ), ) @@ -1149,7 +1227,7 @@ func TestRouterMetadataSizeLimit(t *testing.T) { } calls := store.Get(call.Filter{ - TestExecutionID: "execution-1", + TestExecutionID: testExecutionID, ServiceID: "service-1", }) diff --git a/execute/runtime/router/http/request_test.go b/execute/runtime/router/http/request_test.go index c412bba..86378ca 100644 --- a/execute/runtime/router/http/request_test.go +++ b/execute/runtime/router/http/request_test.go @@ -27,7 +27,7 @@ func TestRequestCapturer(t *testing.T) { req.Header.Set("X-Test", "test") req.Header = e2enginehttp.WithTestExecutionID( req.Header, - "execution-1", + testExecutionID, ) capturer := newRequestCapturer(req, 1024) @@ -77,9 +77,10 @@ func TestRequestCapturer(t *testing.T) { ) } - if id := e2enginehttp.TestExecutionID(got.Headers); id != "execution-1" { + if id := e2enginehttp.TestExecutionID(got.Headers); id != testExecutionID { t.Errorf( - "expected execution ID execution-1, got %q", + "expected execution ID %q, got %q", + testExecutionID, id, ) } diff --git a/execute/runtime/router/http/router.go b/execute/runtime/router/http/router.go index 24441a0..17030da 100644 --- a/execute/runtime/router/http/router.go +++ b/execute/runtime/router/http/router.go @@ -8,6 +8,7 @@ import ( "net/http/httputil" "net/url" + e2engine "github.com/e2engine/instrumentation-go" e2enginehttp "github.com/e2engine/instrumentation-go/http" "github.com/e2engine/core/execute/call" @@ -81,7 +82,7 @@ func (r *Router) Mount(ctx context.Context) error { transport.ResponseHeaderTimeout = r.cfg.ResponseHeaderTimeout transport.MaxResponseHeaderBytes = r.cfg.MaxResponseHeaderBytes - proxy.Transport = transport + proxy.Transport = e2enginehttp.Transport(transport) proxy.ErrorHandler = func( w http.ResponseWriter, @@ -117,7 +118,7 @@ func (r *Router) Mount(ctx context.Context) error { proxy.ServeHTTP(response, req) if errRecord := r.calls.Record(call.Call{ - TestExecutionID: e2enginehttp.TestExecutionID(req.Header), + TestExecutionID: validTestExecutionID(req.Header), ServiceID: route.ServiceID, HTTP: &call.HTTPCall{ Request: request.GetRequest(), @@ -193,6 +194,15 @@ func (r *Router) Mount(ctx context.Context) error { return nil } +func validTestExecutionID(header http.Header) string { + values := header.Values("E2Engine-Test-Execution-ID") + if len(values) != 1 || !e2engine.ValidTestExecutionID(values[0]) { + return "" + } + + return values[0] +} + func (r *Router) Unmount(ctx context.Context) error { err := r.unmountMountedRoutes(ctx, r.mounted) r.mounted = nil diff --git a/execute/runtime/router/http/router_test.go b/execute/runtime/router/http/router_test.go index b2400a9..48701d5 100644 --- a/execute/runtime/router/http/router_test.go +++ b/execute/runtime/router/http/router_test.go @@ -7,6 +7,7 @@ import ( "net" "net/http" "net/http/httptest" + "slices" "strings" "testing" "time" @@ -19,6 +20,109 @@ import ( "github.com/e2engine/core/pkg/log" ) +const testExecutionID = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + +func TestValidTestExecutionID(t *testing.T) { + tests := []struct { + name string + values []string + want string + }{ + {name: "missing"}, + {name: "valid", values: []string{testExecutionID}, want: testExecutionID}, + {name: "empty", values: []string{""}}, + {name: "too short", values: []string{"execution-1"}}, + {name: "uppercase", values: []string{strings.ToUpper(testExecutionID)}}, + {name: "multiple", values: []string{testExecutionID, testExecutionID}}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + header := make(http.Header) + for _, value := range tt.values { + header.Add("E2Engine-Test-Execution-ID", value) + } + + if got := validTestExecutionID(header); got != tt.want { + t.Errorf("validTestExecutionID() = %q, want %q", got, tt.want) + } + }) + } +} + +func TestRouterNormalizesExecutionIDUpstream(t *testing.T) { + upstreamHeaders := make(chan http.Header, 1) + upstream := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + upstreamHeaders <- req.Header.Clone() + w.WriteHeader(http.StatusNoContent) + })) + defer upstream.Close() + + store := call.NewStoreFactory(&call.Config{ + MaxCalls: 10, + MaxRecordedBytes: 1024 * 1024, + }).New() + router := newTestHTTPRouter(t, store) + router.Register(&runtime.Route{ + ServiceID: "service-1", + ListenAddress: "127.0.0.1:0", + RuntimeAddress: upstream.Listener.Addr().String(), + }) + if err := router.Mount(t.Context()); err != nil { + t.Fatalf("Mount() error = %v", err) + } + defer func() { + if err := router.Unmount(context.Background()); err != nil { + t.Errorf("Unmount() error = %v", err) + } + }() + + tests := []struct { + name string + values []string + want []string + }{ + {name: "valid", values: []string{testExecutionID}, want: []string{testExecutionID}}, + {name: "invalid", values: []string{"execution-1"}}, + {name: "multiple", values: []string{testExecutionID, testExecutionID}}, + {name: "missing"}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + req, err := http.NewRequestWithContext( + t.Context(), + http.MethodGet, + "http://"+router.mounted[0].listener.Addr().String(), + nil, + ) + if err != nil { + t.Fatalf("NewRequestWithContext() error = %v", err) + } + req.Header.Set("X-Test", "preserved") + for _, value := range tt.values { + req.Header.Add("E2Engine-Test-Execution-ID", value) + } + + resp, err := http.DefaultClient.Do(req) + if err != nil { + t.Fatalf("Do() error = %v", err) + } + _ = resp.Body.Close() + if resp.StatusCode != http.StatusNoContent { + t.Errorf("status = %d, want %d", resp.StatusCode, http.StatusNoContent) + } + + got := <-upstreamHeaders + if values := got.Values("E2Engine-Test-Execution-ID"); !slices.Equal(values, tt.want) { + t.Errorf("upstream execution IDs = %q, want %q", values, tt.want) + } + if got.Get("X-Test") != "preserved" { + t.Errorf("upstream X-Test = %q, want preserved", got.Get("X-Test")) + } + }) + } +} + func TestRouter(t *testing.T) { var receivedBody string @@ -91,7 +195,7 @@ func TestRouter(t *testing.T) { req.Header.Set("X-Test", "value") - req.Header = e2enginehttp.WithTestExecutionID(req.Header, "execution-1") + req.Header = e2enginehttp.WithTestExecutionID(req.Header, testExecutionID) resp, err := http.DefaultClient.Do(req) if err != nil { @@ -134,7 +238,7 @@ func TestRouter(t *testing.T) { } calls := store.Get(call.Filter{ - TestExecutionID: "execution-1", + TestExecutionID: testExecutionID, ServiceID: "service-1", }) @@ -147,9 +251,10 @@ func TestRouter(t *testing.T) { got := calls[0] - if got.TestExecutionID != "execution-1" { + if got.TestExecutionID != testExecutionID { t.Errorf( - "expected execution ID execution-1, got %s", + "expected execution ID %s, got %s", + testExecutionID, got.TestExecutionID, ) } @@ -290,7 +395,7 @@ func TestRouterProxyError(t *testing.T) { if err != nil { t.Fatalf("cannot create request: %v", err) } - req.Header = e2enginehttp.WithTestExecutionID(req.Header, "execution-1") + req.Header = e2enginehttp.WithTestExecutionID(req.Header, testExecutionID) resp, err := http.DefaultClient.Do(req) if err != nil { @@ -307,7 +412,7 @@ func TestRouterProxyError(t *testing.T) { } calls := store.Get(call.Filter{ - TestExecutionID: "execution-1", + TestExecutionID: testExecutionID, ServiceID: "service-1", }) @@ -503,7 +608,7 @@ func TestRouterTruncatedBodyRecording(t *testing.T) { req.Header = e2enginehttp.WithTestExecutionID( req.Header, - "execution-1", + testExecutionID, ) resp, err := http.DefaultClient.Do(req) @@ -527,7 +632,7 @@ func TestRouterTruncatedBodyRecording(t *testing.T) { } calls := store.Get(call.Filter{ - TestExecutionID: "execution-1", + TestExecutionID: testExecutionID, ServiceID: "service-1", }) @@ -831,7 +936,7 @@ func TestRouterMaxResponseHeaderBytes(t *testing.T) { req.Header = e2enginehttp.WithTestExecutionID( req.Header, - "execution-1", + testExecutionID, ) resp, err := http.DefaultClient.Do(req) @@ -849,7 +954,7 @@ func TestRouterMaxResponseHeaderBytes(t *testing.T) { } calls := store.Get(call.Filter{ - TestExecutionID: "execution-1", + TestExecutionID: testExecutionID, ServiceID: "service-1", }) diff --git a/execute/worker/grpc/executor_test.go b/execute/worker/grpc/executor_test.go index 65a92ad..0558cca 100644 --- a/execute/worker/grpc/executor_test.go +++ b/execute/worker/grpc/executor_test.go @@ -25,6 +25,8 @@ import ( pkgerrors "github.com/e2engine/core/pkg/errors" ) +const testExecutionID = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + func TestFindProtoSpec(t *testing.T) { service := testServiceSpec() @@ -318,7 +320,7 @@ func TestExecutorExecute(t *testing.T) { if id := e2enginegrpc.TestExecutionID( md, - ); id != "execution-123" { + ); id != testExecutionID { t.Errorf( "unexpected execution ID metadata: %s", id, @@ -415,7 +417,7 @@ func TestExecutorExecute(t *testing.T) { ) job := &execute.TestJob{ - ExecutionID: "execution-123", + ExecutionID: testExecutionID, Environment: model.Environment{ Spec: model.EnvironmentSpec{ Services: []model.ServiceSpec{ @@ -493,10 +495,10 @@ func TestExecutorExecute(t *testing.T) { if id := e2enginegrpc.TestExecutionID( metadata.MD(req.Metadata), - ); id != "execution-123" { + ); id != testExecutionID { t.Errorf( "expected execution ID %q, got %q", - "execution-123", + testExecutionID, id, ) } @@ -678,7 +680,7 @@ func TestExecutorExecuteWithTestLevelProto(t *testing.T) { ) job := &execute.TestJob{ - ExecutionID: "execution-123", + ExecutionID: testExecutionID, // No matching gRPC service or protobuf specification. Environment: model.Environment{}, @@ -758,7 +760,7 @@ func TestExecutorExecuteAddressResolutionError(t *testing.T) { Return("", resolveErr) job := &execute.TestJob{ - ExecutionID: "execution-123", + ExecutionID: testExecutionID, Environment: model.Environment{ Spec: model.EnvironmentSpec{ Services: []model.ServiceSpec{ @@ -842,7 +844,7 @@ func TestExecutorExecuteRequestMessageSizeLimit(t *testing.T) { ) job := &execute.TestJob{ - ExecutionID: "execution-123", + ExecutionID: testExecutionID, Environment: model.Environment{ Spec: model.EnvironmentSpec{ Services: []model.ServiceSpec{ @@ -994,7 +996,7 @@ func TestExecutorExecuteResponseMessageSizeLimit(t *testing.T) { ) job := &execute.TestJob{ - ExecutionID: "execution-123", + ExecutionID: testExecutionID, Environment: model.Environment{ Spec: model.EnvironmentSpec{ Services: []model.ServiceSpec{*service}, diff --git a/execute/worker/http/executor_test.go b/execute/worker/http/executor_test.go index 4d541fc..243dce8 100644 --- a/execute/worker/http/executor_test.go +++ b/execute/worker/http/executor_test.go @@ -17,6 +17,11 @@ import ( "github.com/e2engine/core/model/matcher" ) +const ( + testExecutionID = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + explicitTestExecutionID = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" +) + func TestBuildHTTPRequest(t *testing.T) { ctx := context.Background() @@ -93,7 +98,7 @@ func TestBuildHTTPRequest(t *testing.T) { ctx, tt.spec.URL, tt.spec, - "execution-123", + testExecutionID, ) if err != nil { t.Fatalf( @@ -129,10 +134,10 @@ func TestBuildHTTPRequest(t *testing.T) { if id := e2enginehttp.TestExecutionID( req.Header, - ); id != "execution-123" { + ); id != testExecutionID { t.Errorf( "expected execution ID header %q, got %q", - "execution-123", + testExecutionID, id, ) } @@ -198,7 +203,7 @@ func TestBuildHTTPRequestQuery(t *testing.T) { context.Background(), spec.URL, spec, - "execution-123", + testExecutionID, ) if err != nil { t.Fatalf( @@ -249,7 +254,7 @@ func TestBuildHTTPRequestHeaders(t *testing.T) { "value-2", }, }, - "user-value", + explicitTestExecutionID, ), } @@ -257,7 +262,7 @@ func TestBuildHTTPRequestHeaders(t *testing.T) { context.Background(), spec.URL, spec, - "execution-123", + testExecutionID, ) if err != nil { t.Fatalf( @@ -278,7 +283,7 @@ func TestBuildHTTPRequestHeaders(t *testing.T) { if id := e2enginehttp.TestExecutionID( req.Header, - ); id != "execution-123" { + ); id != testExecutionID { t.Errorf( "expected execution header to be overridden, got %s", id, @@ -301,7 +306,7 @@ func TestBuildHTTPRequestCanceledContext(t *testing.T) { ctx, spec.URL, spec, - "execution-123", + testExecutionID, ) if err != nil { t.Fatalf( @@ -330,7 +335,7 @@ func TestBuildHTTPRequestResolvedURL(t *testing.T) { t.Context(), resolvedURL, spec, - "execution-123", + testExecutionID, ) if err != nil { t.Fatalf("buildHTTPRequest() error = %v", err) @@ -468,10 +473,10 @@ func TestExecutorExecute(t *testing.T) { ) { if id := e2enginehttp.TestExecutionID( r.Header, - ); id != "execution-123" { + ); id != testExecutionID { t.Errorf( "expected execution ID %q, got %q", - "execution-123", + testExecutionID, id, ) } @@ -515,7 +520,7 @@ func TestExecutorExecute(t *testing.T) { ) job := &execute.TestJob{ - ExecutionID: "execution-123", + ExecutionID: testExecutionID, Test: model.Test{ Spec: model.TestSpec{ Request: model.RequestSpec{ @@ -557,10 +562,10 @@ func TestExecutorExecute(t *testing.T) { if id := e2enginehttp.TestExecutionID( req.Header, - ); id != "execution-123" { + ); id != testExecutionID { t.Errorf( "expected execution ID header %q, got %q", - "execution-123", + testExecutionID, id, ) } @@ -635,7 +640,7 @@ func TestExecutorExecuteAddressResolutionError(t *testing.T) { Return("", resolveErr) job := &execute.TestJob{ - ExecutionID: "execution-123", + ExecutionID: testExecutionID, Test: model.Test{ Spec: model.TestSpec{ Request: model.RequestSpec{ From 851a4289cf57f0ada355c96fe6b1ed0f87162e6b Mon Sep 17 00:00:00 2001 From: Yaroslav Grebnov Date: Sat, 14 Nov 2026 16:59:51 +0100 Subject: [PATCH 3/3] Fix validation rules getter --- model/validation.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/model/validation.go b/model/validation.go index d0877c5..f869ce0 100644 --- a/model/validation.go +++ b/model/validation.go @@ -6,6 +6,7 @@ import ( "net" "net/url" "regexp" + "slices" "strconv" "strings" "sync" @@ -39,7 +40,7 @@ func GetValidationRules() []modellib.Rule { } }) - return rules + return slices.Clone(rules) } var (