Skip to content

[Repo Assist] test(mcp): add connect-timeout default behaviour tests#3947

Merged
lpcox merged 2 commits intomainfrom
repo-assist/test-connect-timeout-defaults-981ead161748c823
Apr 16, 2026
Merged

[Repo Assist] test(mcp): add connect-timeout default behaviour tests#3947
lpcox merged 2 commits intomainfrom
repo-assist/test-connect-timeout-defaults-981ead161748c823

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 This is a Repo Assist automated pull request.

Summary

Adds four white-box tests in package mcp to cover the connectTimeout defaulting behaviour in NewHTTPConnection.

These tests were motivated by the bug in #3933 (inconsistent == 0 guard in reconnectSDKTransport) and serve as regression guards for both fixes.

Tests Added

Test What it checks
TestNewHTTPConnection_DefaultConnectTimeout_ZeroInput connectTimeout=0 → stored as defaultConnectTimeout (30 s)
TestNewHTTPConnection_DefaultConnectTimeout_NegativeInput connectTimeout=-1s → stored as defaultConnectTimeout (guards the <= 0 fix)
TestNewHTTPConnection_DefaultConnectTimeout_CustomValue connectTimeout=10s → stored unchanged
TestDefaultConnectTimeout_Value defaultConnectTimeout == 30*time.Second — prevents silent drift from config.DefaultConnectTimeout

Implementation notes

  • Tests are in package mcp (white-box, same as existing http_connection_test.go) to allow direct access to the unexported conn.connectTimeout field.
  • A shared newMinimalTestServer helper constructs the httptest server needed for NewHTTPConnection to complete its handshake.

Test Status

⚠️ Infrastructure constraint: proxy.golang.org is blocked in this environment, preventing go test from running locally. The tests follow the same pattern as the existing http_connection_test.go tests and are written to pass against the companion fix PR (repo-assist/fix-issue-3933-connect-timeout).

Warning

⚠️ Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • proxy.golang.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "proxy.golang.org"

See Network Configuration for more information.

Generated by Repo Assist · ● 6.1M ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@851905c06e905bf362a9f6cc54f912e3df747d55

@lpcox lpcox marked this pull request as ready for review April 16, 2026 14:41
Copilot AI review requested due to automatic review settings April 16, 2026 14:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds new tests to cover connectTimeout defaulting behavior in NewHTTPConnection, motivated by issue #3933 and intended to act as a regression suite.

Changes:

  • Adds a new connect_timeout_test.go file with 4 tests around connectTimeout defaulting and preservation.
  • Introduces a minimal httptest server helper intended to allow NewHTTPConnection to complete its handshake.
Show a summary per file
File Description
internal/mcp/connect_timeout_test.go Adds white-box tests asserting how NewHTTPConnection stores connectTimeout (default/negative/custom) and attempts to guard the default value.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comments suppressed due to low confidence (1)

internal/mcp/connect_timeout_test.go:87

  • TestDefaultConnectTimeout_Value currently asserts defaultConnectTimeout is 30*time.Second, but defaultConnectTimeout is not defined in this package today. If the intent is to prevent drift from the canonical config value, assert against time.Duration(config.DefaultConnectTimeout) * time.Second (importing internal/config) rather than duplicating 30*time.Second, so the test fails when code and config diverge.
// TestDefaultConnectTimeout_Value guards against the constant value drifting
// away from config.DefaultConnectTimeout (30 s) unintentionally.
func TestDefaultConnectTimeout_Value(t *testing.T) {
	assert.Equal(t, 30*time.Second, defaultConnectTimeout,
		"defaultConnectTimeout must remain 30 s to stay in sync with config.DefaultConnectTimeout")
}
  • Files reviewed: 1/1 changed files
  • Comments generated: 2

Comment thread internal/mcp/connect_timeout_test.go Outdated
Comment on lines +45 to +46
assert.Equal(t, defaultConnectTimeout, conn.connectTimeout,
"zero connectTimeout should be replaced with defaultConnectTimeout")
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

These assertions reference defaultConnectTimeout, but there is no defaultConnectTimeout identifier defined anywhere in internal/mcp (the current implementation hard-codes 30 * time.Second in NewHTTPConnection). As written, this file will not compile. Either introduce defaultConnectTimeout in the production code (and use it in NewHTTPConnection), or have the tests derive the expected value from internal/config.DefaultConnectTimeout (e.g., time.Duration(config.DefaultConnectTimeout) * time.Second) / inline the expected duration.

This issue also appears on line 82 of the same file.

Copilot uses AI. Check for mistakes.
github-actions bot and others added 2 commits April 16, 2026 07:51
Add four tests in package mcp covering the connectTimeout defaulting logic
in NewHTTPConnection:

- TestNewHTTPConnection_DefaultConnectTimeout_ZeroInput
  Ensures that connectTimeout=0 falls back to defaultConnectTimeout (30 s).

- TestNewHTTPConnection_DefaultConnectTimeout_NegativeInput
  Ensures that connectTimeout<0 also falls back (guards the <= 0 fix for
  the bug identified in #3933).

- TestNewHTTPConnection_DefaultConnectTimeout_CustomValue
  Ensures that a positive connectTimeout is stored unchanged.

- TestDefaultConnectTimeout_Value
  Guards the constant value so any drift from config.DefaultConnectTimeout
  (30 s) causes an immediate, obvious test failure rather than a silent bug.

These tests directly exercise the paths fixed in fix(mcp):#3933 and
provide regression coverage for future changes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@lpcox lpcox force-pushed the repo-assist/test-connect-timeout-defaults-981ead161748c823 branch from 825fc60 to 9b7bfbc Compare April 16, 2026 14:51
@lpcox lpcox merged commit 87c9b46 into main Apr 16, 2026
16 checks passed
@lpcox lpcox deleted the repo-assist/test-connect-timeout-defaults-981ead161748c823 branch April 16, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants