Skip to content

Commit

Permalink
feat: PRT - Add cache to protocol integration tests (#1708)
Browse files Browse the repository at this point in the history
* Add golang/mock as a direct requirement in go.mod

* Move all createRpcConsumer function arguments to a struct

* Small fix to one of the integration tests

* Add option to add cache for consumer in integration tests

* Add consumer with cache integration test

* Small code clean for the test

* Move all createRpcProvider function arguments to a struct

* Small fixes to TestConsumerProviderWithConsumerSideCache

* Add TestConsumerProviderWithProviderSideCache

* Small fix to cache server

* Disable metrics server for cache in tests

* Add TestConsumerProviderWithConsumerAndProviderSideCache

* Attempt to fix test

* Small fix to a different test
  • Loading branch information
shleikes authored Sep 24, 2024
1 parent 6278d1a commit db8248c
Show file tree
Hide file tree
Showing 3 changed files with 656 additions and 60 deletions.
10 changes: 5 additions & 5 deletions ecosystem/cache/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,34 +107,34 @@ func (cs *CacheServer) Serve(ctx context.Context,
if strings.HasPrefix(listenAddr, unixPrefix) { // Unix socket
host, port, err := net.SplitHostPort(listenAddr)
if err != nil {
utils.LavaFormatFatal("Failed to parse unix socket, provide address in this format unix:/tmp/example.sock: %v\n", err)
utils.LavaFormatFatal("Failed to parse unix socket, provide address in this format unix:/tmp/example.sock", err)
return
}

syscall.Unlink(port)

addr, err := net.ResolveUnixAddr(host, port)
if err != nil {
utils.LavaFormatFatal("Failed to resolve unix socket address: %v\n", err)
utils.LavaFormatFatal("Failed to resolve unix socket address", err)
return
}

lis, err = net.ListenUnix(host, addr)
if err != nil {
utils.LavaFormatFatal("Faild to listen to unix socket listener: %v\n", err)
utils.LavaFormatFatal("Failed to listen to unix socket listener", err)
return
}

// Set permissions for the Unix socket
err = os.Chmod(port, 0o600)
if err != nil {
utils.LavaFormatFatal("Failed to set permissions for Unix socket: %v\n", err)
utils.LavaFormatFatal("Failed to set permissions for Unix socket", err)
return
}
} else {
lis, err = net.Listen("tcp", listenAddr)
if err != nil {
utils.LavaFormatFatal("Cache server failure setting up TCP listener: %v\n", err)
utils.LavaFormatFatal("Cache server failure setting up TCP listener", err)
return
}
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ require (
github.com/fullstorydev/grpcurl v1.8.5
github.com/goccy/go-json v0.10.2
github.com/gogo/status v1.1.0
github.com/golang/mock v1.6.0
github.com/golang/protobuf v1.5.4
github.com/itchyny/gojq v0.12.16
github.com/jhump/protoreflect v1.15.1
Expand Down Expand Up @@ -85,7 +86,6 @@ require (
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gogo/googleapis v1.4.1 // indirect
github.com/golang/glog v1.2.0 // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/google/flatbuffers v1.12.1 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/s2a-go v0.1.7 // indirect
Expand Down
Loading

0 comments on commit db8248c

Please sign in to comment.