Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
version: 2

updates:
- package-ecosystem: "gomod"
directory: "/"
directories:
- "/"
- "/tools"
schedule:
interval: "weekly"

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ jobs:

- name: Verify
run: make verify

- name: Verify
run: make verify
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

Core domain model, execution logic, and public APIs for E2Engine.

Part of [E2Engine](https://e2engine.dev), an open-source platform for declarative end-to-end testing.

This module provides the shared models and execution components used across E2Engine, including test and environment definitions, test execution, runtime service management, scheduling, persistence interfaces, and transport primitives.

## Installation
Expand All @@ -22,7 +24,7 @@ Core E2Engine domain models, validation, and shared types.

**repository**

E2Engine repositories contracts for persistence of environments, tests, test suites, and execution state.
E2Engine repository contracts for persistence of environments, tests, test suites, and execution state.

**execute**

Expand Down Expand Up @@ -71,8 +73,9 @@ This repository is part of E2Engine.
- [runner-local](https://github.com/e2engine/runner-local) — local test execution
- [cli](https://github.com/e2engine/cli) — command-line interface
- [tests](https://github.com/e2engine/tests) — end-to-end tests for E2Engine
- demo — executable demonstration system and E2Engine usage examples
- [demo](https://github.com/e2engine/demo) — executable demonstration system and E2Engine usage examples
- [instrumentation-go](https://github.com/e2engine/instrumentation-go) — Go instrumentation library for E2Engine

## License

Licensed under the Apache License, Version 2.0.
Licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE).
34 changes: 13 additions & 21 deletions execute/runtime/router/grpc/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"fmt"
"net"

e2engine "github.com/e2engine/instrumentation-go"
e2enginegrpc "github.com/e2engine/instrumentation-go/grpc"
"github.com/ygrebnov/errorc"
grpcpkg "google.golang.org/grpc"
"google.golang.org/grpc/codes"
Expand Down Expand Up @@ -266,25 +268,19 @@ func (r *Router) newHandler(
)
}

incomingMetadata, _ :=
metadata.FromIncomingContext(
stream.Context(),
)
ctx := e2enginegrpc.Extract(stream.Context())
testExecutionID := e2engine.TestExecutionID(ctx)

var testExecutionID string
if values := incomingMetadata.Get(
string(keys.E2EngineTestExecutionID),
); len(values) > 0 {
testExecutionID = values[0]
}
incomingMetadata, _ := metadata.FromIncomingContext(
stream.Context(),
)

outgoingMetadata := incomingMetadata.Copy()
outgoingMetadata.Delete(
string(keys.E2EngineTestExecutionID),
outgoingMetadata := e2enginegrpc.WithoutTestExecutionID(
incomingMetadata,
)

outgoingContext := metadata.NewOutgoingContext(
stream.Context(),
ctx,
outgoingMetadata,
)

Expand Down Expand Up @@ -354,19 +350,15 @@ func (r *Router) newHandler(
}
}

func cloneMetadata(
source metadata.MD,
) map[string][]string {
func cloneMetadata(source metadata.MD) map[string][]string {
source = e2enginegrpc.WithoutTestExecutionID(source)

result := make(
map[string][]string,
len(source),
)

for key, values := range source {
if key == string(keys.E2EngineTestExecutionID) {
continue
}

result[key] = append(
[]string(nil),
values...,
Expand Down
44 changes: 23 additions & 21 deletions execute/runtime/router/grpc/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net"
"testing"

e2enginegrpc "github.com/e2engine/instrumentation-go/grpc"
grpcpkg "google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials/insecure"
Expand All @@ -14,7 +15,6 @@ import (

"github.com/e2engine/core/execute/call"
"github.com/e2engine/core/execute/runtime"
"github.com/e2engine/core/pkg/keys"
"github.com/e2engine/core/pkg/log"
)

Expand Down Expand Up @@ -85,10 +85,12 @@ func TestRawCodec(t *testing.T) {
}

func TestCloneMetadata(t *testing.T) {
source := metadata.Pairs(
"x-test", "first",
"x-test", "second",
string(keys.E2EngineTestExecutionID), "execution-1",
source := e2enginegrpc.WithTestExecutionID(
metadata.Pairs(
"x-test", "first",
"x-test", "second",
),
"execution-1",
)

got := cloneMetadata(source)
Expand All @@ -103,9 +105,10 @@ func TestCloneMetadata(t *testing.T) {
)
}

if _, ok := got[string(keys.E2EngineTestExecutionID)]; ok {
t.Fatal(
"expected execution ID metadata to be excluded",
if len(got) != 1 {
t.Fatalf(
"expected execution ID metadata to be excluded, got %#v",
got,
)
}

Expand Down Expand Up @@ -259,9 +262,11 @@ func TestRouter(t *testing.T) {

ctx := metadata.NewOutgoingContext(
context.Background(),
metadata.Pairs(
"x-request", "request-value",
string(keys.E2EngineTestExecutionID),
e2enginegrpc.WithTestExecutionID(
metadata.Pairs(
"x-request",
"request-value",
),
"execution-1",
),
)
Expand Down Expand Up @@ -305,11 +310,7 @@ func TestRouter(t *testing.T) {
)
}

if len(
upstreamMetadata.Get(
string(keys.E2EngineTestExecutionID),
),
) != 0 {
if id := e2enginegrpc.TestExecutionID(upstreamMetadata); id != "" {
t.Fatal(
"expected execution ID not to be forwarded upstream",
)
Expand Down Expand Up @@ -366,9 +367,10 @@ func TestRouter(t *testing.T) {
)
}

if _, ok := got.GRPC.Request.Metadata[string(keys.E2EngineTestExecutionID)]; ok {
t.Fatal(
"expected execution ID to be excluded from recorded metadata",
if id := e2enginegrpc.TestExecutionID(got.GRPC.Request.Metadata); id != "" {
t.Fatalf(
"expected execution ID to be excluded from recorded metadata, got %q",
id,
)
}

Expand Down Expand Up @@ -467,8 +469,8 @@ func TestRouterUpstreamError(t *testing.T) {

ctx := metadata.NewOutgoingContext(
context.Background(),
metadata.Pairs(
string(keys.E2EngineTestExecutionID),
e2enginegrpc.WithTestExecutionID(
nil,
"execution-1",
),
)
Expand Down
8 changes: 5 additions & 3 deletions execute/runtime/router/http/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ import (
"io"
"net/http"

e2enginehttp "github.com/e2engine/instrumentation-go/http"

"github.com/e2engine/core/execute/call"
"github.com/e2engine/core/internal/util"
"github.com/e2engine/core/pkg/keys"
)

func captureRequest(req *http.Request) (call.HTTPRequest, error) {
header := util.CloneHTTPHeader(req.Header)
header.Del(string(keys.E2EngineTestExecutionID))
header := e2enginehttp.WithoutTestExecutionID(
req.Header,
)

query := util.CloneQuery(req.URL.Query())

Expand Down
17 changes: 7 additions & 10 deletions execute/runtime/router/http/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
"testing"

"github.com/e2engine/core/pkg/keys"
e2enginehttp "github.com/e2engine/instrumentation-go/http"
)

func TestCaptureRequest(t *testing.T) {
Expand All @@ -22,10 +22,8 @@ func TestCaptureRequest(t *testing.T) {

req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-Test", "test")
req.Header.Set(
string(keys.E2EngineTestExecutionID),
"execution-1",
)

req.Header = e2enginehttp.WithTestExecutionID(req.Header, "execution-1")

got, err := captureRequest(req)
if err != nil {
Expand Down Expand Up @@ -61,11 +59,10 @@ func TestCaptureRequest(t *testing.T) {
)
}

if got.Headers.Get(
string(keys.E2EngineTestExecutionID),
) != "" {
t.Fatal(
"expected execution ID header to be removed",
if id := e2enginehttp.TestExecutionID(got.Headers); id != "" {
t.Errorf(
"expected execution ID header to be removed, got %q",
id,
)
}

Expand Down
3 changes: 2 additions & 1 deletion execute/runtime/router/http/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net/http/httputil"
"net/url"

e2enginehttp "github.com/e2engine/instrumentation-go/http"
"github.com/ygrebnov/errorc"

"github.com/e2engine/core/execute/call"
Expand Down Expand Up @@ -133,7 +134,7 @@ func (r *Router) Mount(ctx context.Context) error {
proxy.ServeHTTP(responseRecorder, req)

r.calls.Record(call.Call{
TestExecutionID: req.Header.Get(string(keys.E2EngineTestExecutionID)),
TestExecutionID: e2enginehttp.TestExecutionID(req.Header),
ServiceID: route.ServiceID,
HTTP: &call.HTTPCall{
Request: request,
Expand Down
23 changes: 9 additions & 14 deletions execute/runtime/router/http/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import (
"strings"
"testing"

e2enginehttp "github.com/e2engine/instrumentation-go/http"

"github.com/e2engine/core/execute/call"
"github.com/e2engine/core/execute/runtime"
"github.com/e2engine/core/pkg/keys"
"github.com/e2engine/core/pkg/log"
)

Expand Down Expand Up @@ -83,10 +84,8 @@ func TestRouter(t *testing.T) {
}

req.Header.Set("X-Test", "value")
req.Header.Set(
string(keys.E2EngineTestExecutionID),
"execution-1",
)

req.Header = e2enginehttp.WithTestExecutionID(req.Header, "execution-1")

resp, err := http.DefaultClient.Do(req)
if err != nil {
Expand Down Expand Up @@ -188,11 +187,10 @@ func TestRouter(t *testing.T) {
)
}

if got.HTTP.Request.Headers.Get(
string(keys.E2EngineTestExecutionID),
) != "" {
t.Fatal(
"expected execution ID header to be excluded from recorded request",
if id := e2enginehttp.TestExecutionID(got.HTTP.Request.Headers); id != "" {
t.Errorf(
"expected execution ID header to be removed, got %q",
id,
)
}

Expand Down Expand Up @@ -274,10 +272,7 @@ func TestRouterProxyError(t *testing.T) {
if err != nil {
t.Fatalf("cannot create request: %v", err)
}
req.Header.Set(
string(keys.E2EngineTestExecutionID),
"execution-1",
)
req.Header = e2enginehttp.WithTestExecutionID(req.Header, "execution-1")

resp, err := http.DefaultClient.Do(req)
if err != nil {
Expand Down
6 changes: 2 additions & 4 deletions execute/worker/grpc/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"

e2enginegrpc "github.com/e2engine/instrumentation-go/grpc"
"github.com/ygrebnov/errorc"
ggrpc "google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
Expand Down Expand Up @@ -83,10 +84,7 @@ func (e *TestExecutor) Execute(
defer connection.Close()

callMetadata := metadata.MD(spec.Metadata).Copy()
callMetadata.Set(
string(keys.E2EngineTestExecutionID),
job.ExecutionID,
)
callMetadata = e2enginegrpc.WithTestExecutionID(callMetadata, job.ExecutionID)

callCtx := metadata.NewOutgoingContext(
ctx,
Expand Down
Loading
Loading