Skip to content

Added some startup checks in integration test #2962

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

Merged
merged 1 commit into from
Jul 30, 2025
Merged
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
41 changes: 37 additions & 4 deletions internal/integrationtest/daemon/daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"net/http"
"net/http/httptest"
"strings"
"sync/atomic"
"testing"
"time"

Expand Down Expand Up @@ -567,17 +568,36 @@ func TestDaemonUserAgent(t *testing.T) {
// The user-agent is tested inside the HTTPServeFile function
test_index := paths.New("..", "testdata", "test_index.json")
url := env.HTTPServeFile(8000, test_index)
// Wait for the server to be ready
fmt.Print("Waiting for test server to be ready: ")
for i := range 20 {
if resp, err := http.Get(url.String()); err == nil && resp.StatusCode == http.StatusOK {
fmt.Println("Test server is ready")
break
}
time.Sleep(100 * time.Millisecond)
fmt.Print(".")
require.Less(t, i, 19, "Test server did not start in time")
}

var enableTest atomic.Bool

ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Test that the user-agent contains metadata from the context when the CLI is in daemon mode
userAgent := r.Header.Get("User-Agent")

if !enableTest.Load() {
return
}
fmt.Println("Got user-agent:", userAgent)

require.Contains(t, userAgent, "cli-test/0.0.0")
require.Contains(t, userAgent, "grpc-go")
// Depends on how we built the client we may have git-snapshot or 0.0.0-git in dev releases
require.Condition(t, func() (success bool) {
return strings.Contains(userAgent, "arduino-cli/git-snapshot") ||
strings.Contains(userAgent, "arduino-cli/0.0.0-git")
})
require.True(t,
strings.Contains(userAgent, "arduino-cli/git-snapshot") || strings.Contains(userAgent, "arduino-cli/0.0.0-git"),
"invalid user-agent value: "+userAgent,
)

proxiedReq, err := http.NewRequest(r.Method, url.String(), r.Body)
require.NoError(t, err)
Expand All @@ -594,6 +614,19 @@ func TestDaemonUserAgent(t *testing.T) {
}))
defer ts.Close()

fmt.Print("Waiting for the proxy test server to be ready: ")
for i := range 20 {
if resp, err := http.Get(ts.URL); err == nil && resp.StatusCode == http.StatusOK {
fmt.Println("Test server is ready")
break
}
time.Sleep(100 * time.Millisecond)
fmt.Print(".")
require.Less(t, i, 19, "Test server did not start in time")
}

enableTest.Store(true)

grpcInst := cli.Create()
require.NoError(t, grpcInst.Init("", "", func(ir *commands.InitResponse) {
fmt.Printf("INIT> %v\n", ir.GetMessage())
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy