Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RelayMiner]: add proxy.Ping(...) capability to test connectivity between relay servers and backend URLs #744

Open
wants to merge 25 commits into
base: main
Choose a base branch
from

Conversation

eddyzags
Copy link

@eddyzags eddyzags commented Aug 17, 2024

Summary

This PR adds the capability to test the connectivity between the Relay Servers and the Backend URLs in two ways.

  1. Safeguard at Startup:
    For every suppliers.[].service_config.backend_url referenced as input inside the Relay Miner Configuration file, the Relay Proxy will verify wether the network connection between the targeted backend_url and the relayerminer process is functioning properly. If one or more connections aren't possible, the relay miner won't be able to start.

  2. Configurable Ping HTTP server:
    The Relay Miner process will listen for incoming request to synchronously test the connectivity of every referenced suppliers.[].service_config.backend_url. If one or more backend URLs aren't reachable, the incoming request will fail.

Based on the serverConfig.ServerType (Example: HTTP), each Server Type will implement their own logic to implement to test the connectivity.

Issue

Type of change

Select one or more:

  • New feature, functionality or library
  • Bug fix
  • Code health or cleanup
  • Documentation
  • Other (specify)

Testing

Documentation changes (only if making doc changes)

  • make docusaurus_start; only needed if you make doc changes

Local Testing (only if making code changes)

  • Unit Tests: make go_develop_and_test
  • LocalNet E2E Tests: make test_e2e
  • See quickstart guide for instructions

PR Testing (only if making code changes)

  • DevNet E2E Tests: Add the devnet-test-e2e label to the PR.
    • THIS IS VERY EXPENSIVE, so only do it after all the reviews are complete.
    • Optionally run make trigger_ci if you want to re-trigger tests without any code changes
    • If tests fail, try re-running failed tests only using the GitHub UI as shown here

Sanity Checklist

  • I have tested my changes using the available tooling
  • I have commented my code
  • I have performed a self-review of my own code; both comments & source code
  • I create and reference any new tickets, if applicable
  • I have left TODOs throughout the codebase, if applicable

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced a new configuration section for the ping functionality, allowing users to test backend connectivity within the relay miner's setup.
    • Added methods to handle ping requests, enhancing health check capabilities for relay servers.
  • Bug Fixes

    • Improved error handling during the server startup process if any relay server is unreachable.
  • Tests

    • Added tests for the new ping functionality to ensure operational integrity and reliability of the relay miner.

Copy link

coderabbitai bot commented Aug 17, 2024

Walkthrough

This update introduces a new ping functionality across various configuration files and related code components for the relay miner. By allowing connectivity testing of backend URLs, the changes enhance monitoring and health-check capabilities. The implementation includes new configuration options, modifications to handle ping requests, and improved testing mechanisms to ensure robust operation. Overall, these improvements aim to bolster the reliability and operational robustness of the relay miner service.

Changes

Files Change Summary
docusaurus/docs/.../relayminer_config.md
localnet/poktrolld/config/...
localnet/poktrolld/config/relayminer_config_full_example.yaml
localnet/poktrolld/config/relayminer_config_localnet_vscode.yaml
Added ping configuration sections with enabled and addr settings, enhancing monitoring capabilities.
pkg/relayer/cmd/cmd.go Introduced Ping functionality to establish a TCP listener and serve ping requests, improving monitoring.
pkg/relayer/config/... Added Ping fields to configuration structures, expanding configurability for health checks.
pkg/relayer/interface.go Introduced Ping methods in RelayerProxy and RelayServer interfaces for connectivity testing.
pkg/relayer/proxy/... Added Ping methods to relayerProxy and synchronousRPCServer for backend connectivity checks.
pkg/relayer/relayminer.go Added ServePing method to handle ping requests and respond based on backend connectivity status.
pkg/relayer/relayminer_test.go Implemented TestRelayMiner_Ping to validate the ping feature in a simulated environment.
testutil/testrelayer/proxy.go Introduced NewMockOneTimeRelayerProxyWithPing for enhanced testing of RelayerProxy functionalities.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Outside diff range, codebase verification and nitpick comments (2)
pkg/relayer/relayminer.go (1)

138-154: Log error details for better debugging.

In the ServePing function, when an error occurs during the Ping call, consider logging the error details before returning a 500 status. This will help in diagnosing issues more effectively.

			if errs := rel.relayerProxy.Ping(ctx); errs != nil {
+				rel.logger.Error().Err(errs).Msg("failed to ping relay servers")
				w.WriteHeader(http.StatusInternalServerError)
				return
			}
pkg/relayer/proxy/proxy_test.go (1)

155-158: Consider extending test coverage for Ping method.

While the current test ensures no errors are returned, consider adding scenarios to test edge cases, such as:

  • Handling of unreachable URLs.
  • Different HTTP status codes.
  • Timeout scenarios.

This will ensure comprehensive coverage of the Ping method's behavior.

pkg/relayer/proxy/synchronous.go Outdated Show resolved Hide resolved
pkg/relayer/proxy/proxy.go Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (1)
pkg/relayer/proxy/proxy.go (1)

203-203: Fix typographical error in log message.

The log message contains a typographical error: "occured" should be "occurred".

- Msg("an unexpected error occured while pinging backend URL")
+ Msg("an unexpected error occurred while pinging backend URL")

@Olshansk Olshansk added the community A ticket intended to potentially be picked up by a community member label Aug 19, 2024
@Olshansk Olshansk added this to the Shannon Quality of Life milestone Aug 19, 2024
@Olshansk Olshansk requested a review from okdas August 21, 2024 22:08
Copy link
Member

@Olshansk Olshansk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eddyzags For a first contribution, this is super impressive!! 💪

Left some comments but great job otherwise. 🙌

Let's finish it off and lmk if you're interested in contributing more as we get closer to BETA.

pkg/relayer/cmd/cmd.go Show resolved Hide resolved
pkg/relayer/config/types.go Show resolved Hide resolved
pkg/relayer/proxy/proxy.go Show resolved Hide resolved
pkg/relayer/proxy/proxy.go Outdated Show resolved Hide resolved
pkg/relayer/proxy/proxy.go Outdated Show resolved Hide resolved
pkg/relayer/relayminer.go Outdated Show resolved Hide resolved
pkg/relayer/relayminer.go Show resolved Hide resolved
testutil/testrelayer/proxy.go Show resolved Hide resolved
pkg/relayer/proxy/synchronous.go Outdated Show resolved Hide resolved
pkg/relayer/relayminer_test.go Show resolved Hide resolved
@eddyzags
Copy link
Author

Hey @Olshansk 👋🏾 ! Thanks for taking the time to review the code and the feedback.

Let's finish it off

Yes let's tackle that. I will make changes to the latest comments by Monday at the latest.

I am also working on the forward feature (see issue comment). I'll open a PR as soon as I can.

and lmk if you're interested in contributing more as we get closer to BETA.

And yes, I am definitely interested in contributing more 🚀

@Olshansk
Copy link
Member

Olshansk commented Sep 3, 2024

@eddyzags Sounds great! Please re-request a review when you're ready. I will take another look then.

@Olshansk
Copy link
Member

Olshansk commented Sep 5, 2024

@eddyzags Just FYI: #744 (comment)

@Olshansk
Copy link
Member

@eddyzags Another bump

@eddyzags
Copy link
Author

eddyzags commented Sep 25, 2024

Hey @Olshansk

I've just added the last requested modifications:

  • Document Localnet configuration file
  • Add Localnet helpers to Makefile to ping Relayer Miners

As the Ping safeguard implementation won't start the Relay Miner pod if the suppliers aren't reachable, I had to clean the Relay Miner's Helm value files when starting the Localnet environment based on the constraints below:

  1. If ollama.enabled=true & rest.enabled=false in poktroll/localnet_config.yaml
    Use a Relayer Miner configuration that defines an Anvil & Ollama supplier as a value file for the relayerminer Helm Chart.
  2. If ollama.enabled=false & rest.enabled=true in poktroll/localnet_config.yaml
    Use a Relay Miner configuration that defines an Anvil & Rest supplier as a value file for the relayeminer Helm Chart.
  3. if ollama.enabled=true & rest.enabled=true in poktroll/localnet_config.yaml
    Use a Relay Miner configuration that defines an Anvil, Rest, & Ollama supplier as a value file for the Helm Chart

In other words, this new logic forces us to only reference the available suppliers in the Relay Miner's configuration.
After some tests, the Relay Miner pod starts correctly only if I activate the deployment of an Ollama and Rest supplier (ollama.enabled=true & rest.enabled=true in localnet_config.yaml). But for the other scenarios, the relayminer pod remains in CrashLoopBackoff state.
The Relayer Miner pod isn't failing because of the Ping safeguard, but because the Relay Miner isn't managing the associated service endpoint (see error instruction here).

Error message:

failed to start relay miner: service endpoint http://relayminer1:8545 not handled by the relay miner: service endpoint not handled by relayer proxy

The Relay miner configuration seems to expects all the suppliers list (Ollama, Anvi & Rest) even if the supplier's container isn't deployed. If this is true, the Relay Miner won't be able to start with the Ping safeguard if one supplier isn't deployed.
I would appreciate some guidance here 🙏🏾 . Is there a link with the fact that we define the supplier list in the genesis.json?

@Olshansk
Copy link
Member

@eddyzags Appreciate the detailed feedback.

Re review - I will take a look next week but hopefully @bryanchriswhite can help out as well.

failed to start relay miner: service endpoint http://relayminer1:8545 not handled by the relay miner: service endpoint not handled by relayer proxy

Re this error. I'll take a deeper look next week but in the meantime, can you try:

  1. Removing localnet_config.yaml
  2. Merging with main
  3. Re-running localnet

This might be something historical we've already solved

Copy link
Member

@Olshansk Olshansk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eddyzags Please merge with main and will re-review then.

Makefile Outdated Show resolved Hide resolved
Copy link
Contributor

@bryanchriswhite bryanchriswhite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super cool feature @eddyzags 😎 - thanks for the contribution! 🚀 🙌

(And apologies for the review delay 😅)

Makefile Show resolved Hide resolved
Tiltfile Show resolved Hide resolved
Comment on lines 179 to 182
Configures a `ping` server to test the connectivity of every backend URLs. If
all the backend URLs are reachable, the endpoint returns a 200 HTTP
Code. Otherwise, if one or more backend URLs aren't reachable, the service
returns an 500 HTTP Internal server error.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you considered using 204 No Content for the success and 503 Service Unavailable for the error status codes? I think they could be more appropriate than 200 and 500.

Suggested change
Configures a `ping` server to test the connectivity of every backend URLs. If
all the backend URLs are reachable, the endpoint returns a 200 HTTP
Code. Otherwise, if one or more backend URLs aren't reachable, the service
returns an 500 HTTP Internal server error.
Configures a `ping` server to test the connectivity of all backend URLs. If
all the backend URLs are reachable, the endpoint returns a 200 HTTP
Code. If one or more backend URLs aren't reachable, the service
returns an 500 HTTP Internal server error.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, I think those status codes are more appropriate.
I am on it 👍🏾

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not so sure about 503 Service Unavailable in the end. The Relayminer server was ready to handle the request, but subsequent calls are not possible. Therefore, there is an internal error in my opinion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you elaborate on "The Relayminer server was ready to handle the request, subsequent calls are not possible" I'm not sure I follow?

Do you think 504 Gateway Timeout is more appropriate?

My thinking is that 500 is quite generic and we should consider using a more specific status if one applies.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thinking is that 500 is quite generic and we should consider using a more specific status if one applies.

I agree. 500 can be generic, and we must use a more specific status code. I also think we shouldn't use 500 because that implies that the server (in this case, relayminer) is completely unusable. But that isn't entirely the case. AFAIK if one supplier isn't reachable anymore, the other configured ones can still function, and the relayminer can continue to mine requests for them.

Could you elaborate on "The Relayminer server was ready to handle the request, subsequent calls are not possible" I'm not sure I follow?

In my mind, there are three actors here:

  1. The client to the /ping endpoint. (could be curl -x GET <addr>:<port>/ping)
  2. The server (relayminer)
  3. The third-party service (supplier)

What I meant by "The Relayminer server was ready/able to handle requests" is the interaction between 1 & 2. And what I meant by the "subsequent calls are not possible" is the interaction between 2 & 3. I hope that makes sense.

My problem with 503 Service Unavailable is that it implies a temporary state. But we are not so sure about that. The supplier might never come back online.
So yes, I think 504 Gateway Timeout is more appropriate if the context timeout. But if the the third-party (supplier) return an unexpected response, we must use 503 Bad Gateway IMO. wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intentional diff?

Same goes for all files in the loalnet/kubernetes directory.

One simple way to revert these would be to do something like:

git fetch origin
git checkout origin/main -- localnet/kubernetes
git add localnet/kubernetes
git commit

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, these changes were intentional and required for this PR.

In the main branch, you can see that Tilt is setting the Kubernetes Values for the Relayminer's configuration (1, 2 & 3) where all the suppliers are defined (see here for Relayminer 1) whether the localnet_config_default (see here) actually deploys the Kubernetes pod or not. This is a problem because these PR modifications prevent the Relayminer application from starting if one or more Backend URLs aren't reachable.

I needed to find a way to:

Pseudocode:

* If Title `localnet_config` enables Ollama, rest, and anvil deployment
    * Use a Relayminer configuration where Ollama, Rest, and Anvil are defined as suppliers.
* If Title `localnet_config` enables Ollama, Rest. But disabled Anvil
    * Use a Relayminer configuration where Ollama and Rest are defined as suppliers. But not Anvil
* If Title `localnet_config` enables Ollama. But disabled Rest and Anvil
    * Use a Relayminer configuration where Ollama supplier is defined as a supplier. But not Rest, Anvil.
, etc...

Maybe there is some better way to define the according suppliers based on the localnet_config dynamically. I am open to suggestions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(cc @okdas)

pkg/relayer/relayminer_test.go Show resolved Hide resolved
pkg/relayer/relayminer_test.go Outdated Show resolved Hide resolved
pkg/relayer/relayminer_test.go Show resolved Hide resolved
pkg/relayer/relayminer_test.go Outdated Show resolved Hide resolved
testutil/testrelayer/proxy.go Outdated Show resolved Hide resolved
@Olshansk
Copy link
Member

Olshansk commented Nov 4, 2024

@eddyzags Do you still plan on finishing off this work?

…ty between relay servers and backend URLs (#1)

* relayer: add RelayServers() method to RelayProxy interface; Add Ping(), ServiceIDs(), Forward() method to RelayServer interface; add RelayServers slice with helper method byServiceID

* relayer: add forward config entry

* relayer: implement ServiceIDs, Forward, and Ping method for synchrounous RPC server

* relayer: add RelayServers implementation for RelayProxy

* relayer: add Ping and Forward options

* relayer: integrate ping option

* relayer: add ServePing and ServeForward method to RelayMiner

* test proxy.Ping() in test + remove forward feature

* add serve ping test

* add doc
pkg/relayer/relayminer_test.go Outdated Show resolved Hide resolved
pkg/relayer/relayminer_test.go Show resolved Hide resolved
Comment on lines 139 to 149
ln, err := net.Listen("tcp", relayMinerConfig.Ping.Addr)
if err != nil {
return fmt.Errorf("failed to listen ping server: %w", err)
}

if err := relayMiner.ServePing(ctx, ln); err != nil {
return fmt.Errorf("failed to start ping server: %w", err)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly! 🙌 😄

My rationale is to improve alignment with the single responsibility principle. In this case, a change in the relayminer ping config structure or server implementation SHOULD NOT cause this function to change (the main relayer CLI entrypoint).

Notice how this would be consistent with the other config-based conditional branches, which are encapsulated into their own methods (i.e. #ServeMetrics(), #ServePprof()).

@@ -134,6 +135,17 @@ func runRelayer(cmd *cobra.Command, _ []string) error {
}
}

if relayMinerConfig.Ping.Enabled {
ln, err := net.Listen("tcp", relayMinerConfig.Ping.Addr)
Copy link
Contributor

@bryanchriswhite bryanchriswhite Nov 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not immediately obvious to me that net.SplitHostPort() should be called as a result of calling net.Listen(); however, a simple test seems to indicate that is the case as the error messages trace back to net.SplitHostPort():

package temp

import (
	"net"
	"testing"

	"github.com/stretchr/testify/require"
)

func TestNoPort(t *testing.T) {
	ln, err := net.Listen("tcp", "localhost")
	require.NoError(t, err)
	require.NotNil(t, ln)
}

func TestTooManyColons(t *testing.T) {
	ln, err := net.Listen("tcp", "localhost::9000")
	require.NoError(t, err)
	require.NotNil(t, ln)
}

func TestURLInsteadOfHostPort(t *testing.T) {
	ln, err := net.Listen("tcp", "http://localhost")
	require.NoError(t, err)
	require.NotNil(t, ln)
}

func TestFQDN(t *testing.T) {
	ln, err := net.Listen("tcp", "example.com:9000")
	require.NoError(t, err)
	require.NotNil(t, ln)
}

@eddyzags I suppose the output of this test also indicates that the UX would be that if the address is invalid, then the relayminer fails to start, correct?

=== RUN   TestNoPort
    test_test.go:12: 
        	Error Trace:	/home/bwhite/Projects/pokt/poktroll/temp/test_test.go:12
        	Error:      	Received unexpected error:
        	            	listen tcp: address localhost: missing port in address
        	Test:       	TestNoPort
--- FAIL: TestNoPort (0.00s)

=== RUN   TestTooManyColons
    test_test.go:18: 
        	Error Trace:	/home/bwhite/Projects/pokt/poktroll/temp/test_test.go:18
        	Error:      	Received unexpected error:
        	            	listen tcp: address localhost::9000: too many colons in address
        	Test:       	TestTooManyColons
--- FAIL: TestTooManyColons (0.00s)

=== RUN   TestURLInsteadOfHostPort
    test_test.go:24: 
        	Error Trace:	/home/bwhite/Projects/pokt/poktroll/temp/test_test.go:24
        	Error:      	Received unexpected error:
        	            	listen tcp: lookup tcp///localhost: unknown port
        	Test:       	TestURLInsteadOfHostPort
--- FAIL: TestURLInsteadOfHostPort (0.03s)

=== RUN   TestFQDN
    test_test.go:30: 
        	Error Trace:	/home/bwhite/Projects/pokt/poktroll/temp/test_test.go:30
        	Error:      	Received unexpected error:
        	            	listen tcp 93.184.215.14:9000: bind: cannot assign requested address
        	Test:       	TestFQDN
--- FAIL: TestFQDN (0.03s)

FAIL

Process finished with the exit code 1

_ = resp.Body.Close()

if resp.StatusCode >= http.StatusInternalServerError {
return ErrRelayerProxySupplierNotReachable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should interpolate which endpoint was not reachable:

Suggested change
return ErrRelayerProxySupplierNotReachable
return ErrRelayerProxySupplierNotReachable.Wrapf(
"endpoint URL %q status: %d",
endpointUrl, resp.StatusCode,
)

// Ping tries to dial the suppliers backend URLs to test the connection.
func (sync *synchronousRPCServer) Ping(ctx context.Context) error {
for _, supplierCfg := range sync.serverConfig.SupplierConfigsMap {
httpClient := &http.Client{Timeout: 2 * time.Second}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
httpClient := &http.Client{Timeout: 2 * time.Second}
httpClient := &http.Client{Timeout: 2 * time.Second}
endpointUrl := supplierCfg.ServiceConfig.BackendUrl.String()

// YAMLRelayMinerPingConfig represents the configuration to expose a ping server.
type YAMLRelayMinerPingConfig struct {
Enabled bool `yaml:"enabled"`
// Addr is the address to bind to (format: 'hostname:port')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Addr is the address to bind to (format: 'hostname:port')
// Addr is the address to bind to (format: 'hostname:port' where 'hostname' can be a DNS name or an IP)

Comment on lines +210 to +211
rp.logger.Error().Err(err).
Msg("an unexpected error occured while pinging backend URL")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think an error message is necessary here, especially if we add more detail elsewhere as suggested.

Suggested change
rp.logger.Error().Err(err).
Msg("an unexpected error occured while pinging backend URL")
rp.logger.Error().Err(err).Send()

@@ -57,3 +60,72 @@ func TestRelayMiner_StartAndStop(t *testing.T) {
err = relayminer.Stop(ctx)
require.NoError(t, err)
}

func TestRelayMiner_Ping(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this all the test coverage that there is or did I miss something?

I would love to see coverage over a few more scenarios:

  1. Multi-supplier relayminer success.
  2. Relayminer with multiple endpoint, including a DNS name, ipv4 address and ipv6 address success
    Mocking the DNS name is pretty straightforward with the go-mockdns package.
  3. Multi-endpoint partial success/failure on startup (i.e. some endpoints should be unreachable on startup)
  4. Multi-endpoint partial success/failure post-startup (i.e. some endpoints should become unreachable after startup)

Consider refactoring this test code into a test suite to de-duplicate common code by moving it into methods on the suite and storing case-specific test state on the suite struct (per test case).

pkg/relayer/relayminer_test.go Show resolved Hide resolved
],
]

if localnet_config["rest"]["enabled"]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need multiple configuration files, and not just one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community A ticket intended to potentially be picked up by a community member
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

4 participants