Skip to content

Commit

Permalink
fix: adds graph api to unload the ebpf hooks during unit test code co…
Browse files Browse the repository at this point in the history
…verage (keploy#1604)

* fix: adds stopTest graph api to unload the ebpf hooks from kernel

Signed-off-by: re-Tick <[email protected]>

* fix(serve): runs the proxy server after loading ebpf hooks

since the keploy pid is extracted from the user space progrom pid and passed into the ebpf map from
the c code itself when sys-bind is called. And sys-bind is called when a port allocation occurs so,
need to start proxy server when the fetchTestsets is fired to load ebpf hooks correctly into the
kernel.

Signed-off-by: re-Tick <[email protected]>

* style: removes commented code

Signed-off-by: re-Tick <[email protected]>

---------

Signed-off-by: re-Tick <[email protected]>
  • Loading branch information
re-Tick authored Feb 22, 2024
1 parent b86e53e commit 9fb89f7
Show file tree
Hide file tree
Showing 11 changed files with 252 additions and 122 deletions.
33 changes: 17 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@ require (
github.com/yudai/gojsondiff v1.0.0
go.mongodb.org/mongo-driver v1.11.6
go.uber.org/zap v1.24.0
golang.org/x/crypto v0.11.0 // indirect
golang.org/x/sys v0.10.0
google.golang.org/protobuf v1.30.0 // indirect
golang.org/x/crypto v0.18.0 // indirect
golang.org/x/sys v0.16.0
google.golang.org/protobuf v1.32.0 // indirect
)

require github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect
require (
github.com/google/uuid v1.6.0 // indirect
github.com/sosodev/duration v1.2.0 // indirect
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect
)

require (
gopkg.in/yaml.v3 v3.0.1
Expand All @@ -48,7 +52,7 @@ require (
github.com/jmoiron/sqlx v1.3.3 // indirect
github.com/klauspost/compress v1.15.11 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/onsi/ginkgo v1.16.5 // indirect
github.com/onsi/gomega v1.27.10 // indirect
Expand All @@ -62,23 +66,22 @@ require (
github.com/zmap/zlint/v3 v3.1.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/net v0.12.0
golang.org/x/text v0.11.0 // indirect
golang.org/x/tools v0.9.3 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.20.0
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.17.0 // indirect
k8s.io/klog/v2 v2.80.1 // indirect
)

require (
github.com/99designs/gqlgen v0.17.36
github.com/99designs/gqlgen v0.17.44
github.com/TheZeroSlave/zapsentry v1.18.0
github.com/agnivade/levenshtein v1.1.1
github.com/charmbracelet/glamour v0.6.0
github.com/emirpasic/gods v1.18.1
github.com/getsentry/sentry-go v0.17.0
github.com/hashicorp/go-memdb v1.3.4
github.com/jackc/pgproto3/v2 v2.3.2
github.com/vektah/gqlparser/v2 v2.5.8
github.com/vektah/gqlparser/v2 v2.5.11
github.com/xdg-go/pbkdf2 v1.0.0
github.com/xdg-go/scram v1.1.1
github.com/xdg-go/stringprep v1.0.4
Expand All @@ -93,17 +96,15 @@ require (
github.com/dlclark/regexp2 v1.4.0 // indirect
github.com/gorilla/css v1.0.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/hashicorp/go-immutable-radix v1.3.0 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.3 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/microcosm-cc/bluemonday v1.0.21 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/muesli/termenv v0.13.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/urfave/cli/v2 v2.25.5 // indirect
github.com/urfave/cli/v2 v2.27.1 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
github.com/yudai/pp v2.0.1+incompatible // indirect
Expand Down
71 changes: 32 additions & 39 deletions go.sum

Large diffs are not rendered by default.

97 changes: 89 additions & 8 deletions pkg/graph/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions pkg/graph/gqlgen.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Where are all the schema files located? globs are supported eg src/**/*.graphqls
schema:
- graph/*.graphqls
- schema.graphqls

# Where should the generated server code go?
exec:
filename: graph/generated.go
filename: generated.go
package: graph

# Uncomment to enable federation
Expand All @@ -14,15 +14,15 @@ exec:

# Where should any generated models go?
model:
filename: graph/model/models_gen.go
filename: model/models_gen.go
package: model

# Where should the resolver implementations go?
resolver:
layout: follow-schema
dir: graph
package: graph
filename_template: "{name}.resolvers.go"
filename_template: "schema.resolvers.go"
# Optional: turn on to not generate template comments above resolvers
# omit_template_comment: false

Expand Down Expand Up @@ -66,7 +66,7 @@ resolver:
# gqlgen will search for any type names in the schema in these go packages
# if they match it will use them, otherwise it will generate them.
autobind:
# - "go.keploy.io/server/pkg/service/serve/graph/model"
# - "go.keploy.io/server/pkg/graph/model"

# This section declares type mapping between the GraphQL and go type systems
#
Expand Down
6 changes: 6 additions & 0 deletions pkg/graph/model/models_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions pkg/graph/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package graph
import (
"go.keploy.io/server/pkg/hooks"
"go.keploy.io/server/pkg/platform"
"go.keploy.io/server/pkg/proxy"
"go.keploy.io/server/pkg/service/test"
"go.uber.org/zap"
)
Expand All @@ -17,6 +18,12 @@ type Resolver struct {
TestReportFS platform.TestReportDB
Storage platform.TestCaseDB
LoadedHooks *hooks.Hook
ProxySet *proxy.ProxySet
KeployServerPort uint32
PassThroughPorts []uint
ProxyPort uint32
Lang string
MongoPassword string
Logger *zap.Logger
Path string
TestReportPath string
Expand Down
1 change: 1 addition & 0 deletions pkg/graph/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type RunTestSetResponse {
type Query {
testSets: [String!]!
testSetStatus(testRunId: String!): TestSetStatus!
stopTest: Boolean!
}

type Mutation {
Expand Down
Loading

0 comments on commit 9fb89f7

Please sign in to comment.