Enhance health check and integration tests for Tai

- Update health check messages in CI workflows to specify HTTP and gRPC readiness for the Tai service.
- Refactor integration tests to use `require` assertions instead of `assert`, improving error handling and test reliability.
- Ensure that responses from gRPC calls are not nil, enhancing test robustness.

These changes improve the clarity of service readiness checks and strengthen the integration test suite.
This commit is contained in:
Max 2026-03-04 15:32:10 +08:00
parent 1c79908649
commit 9dc99d8b8e
3 changed files with 29 additions and 13 deletions

View file

@ -1706,10 +1706,18 @@ jobs:
yaoapp/tai:latest
for i in $(seq 1 30); do
if curl -sf http://127.0.0.1:8080/healthz > /dev/null 2>&1; then
echo "Tai is ready"
echo "Tai HTTP is ready"
break
fi
echo "Waiting for Tai... ($i)"
echo "Waiting for Tai HTTP... ($i)"
sleep 1
done
for i in $(seq 1 15); do
if nc -z 127.0.0.1 9100 2>/dev/null; then
echo "Tai gRPC is ready"
break
fi
echo "Waiting for Tai gRPC... ($i)"
sleep 1
done

View file

@ -1260,10 +1260,18 @@ jobs:
yaoapp/tai:latest
for i in $(seq 1 30); do
if curl -sf http://127.0.0.1:8080/healthz > /dev/null 2>&1; then
echo "Tai is ready"
echo "Tai HTTP is ready"
break
fi
echo "Waiting for Tai... ($i)"
echo "Waiting for Tai HTTP... ($i)"
sleep 1
done
for i in $(seq 1 15); do
if nc -z 127.0.0.1 9100 2>/dev/null; then
echo "Tai gRPC is ready"
break
fi
echo "Waiting for Tai gRPC... ($i)"
sleep 1
done

View file

@ -90,7 +90,8 @@ func TestIntegration_Shell_Echo(t *testing.T) {
client := setupClient(t, "grpc:shell")
resp, err := client.Shell(context.Background(), "echo", []string{"hello"}, nil, 5)
assert.NoError(t, err)
require.NoError(t, err)
require.NotNil(t, resp)
assert.Equal(t, int32(0), resp.ExitCode)
assert.Contains(t, string(resp.Stdout), "hello")
}
@ -147,10 +148,8 @@ func TestIntegration_API_Proxy(t *testing.T) {
client := setupClient(t, "grpc:run", "grpc:mcp")
resp, err := client.API(context.Background(), "GET", "/api/__yao/app/setting", nil, nil)
assert.NoError(t, err)
assert.NotNil(t, resp)
// API proxy returns the response; the actual status depends on the route.
// A valid openapi path returns 200; anything else returns 404.
require.NoError(t, err)
require.NotNil(t, resp)
t.Logf("API proxy status: %d", resp.Status)
}
@ -313,7 +312,7 @@ func TestRelay_Healthz(t *testing.T) {
defer client.Close()
status, err := client.Healthz(context.Background())
assert.NoError(t, err)
require.NoError(t, err)
assert.Equal(t, "ok", status)
}
@ -321,8 +320,8 @@ func TestRelay_Run_Ping(t *testing.T) {
client := setupRelayClient(t, "grpc:run")
data, err := client.Run(context.Background(), "utils.app.Ping", nil, 0)
assert.NoError(t, err)
assert.NotNil(t, data)
require.NoError(t, err)
require.NotNil(t, data)
t.Logf("relay Run result: %s", string(data))
}
@ -337,7 +336,8 @@ func TestRelay_Shell_Echo(t *testing.T) {
client := setupRelayClient(t, "grpc:shell")
resp, err := client.Shell(context.Background(), "echo", []string{"relay-test"}, nil, 5)
assert.NoError(t, err)
require.NoError(t, err)
require.NotNil(t, resp)
assert.Equal(t, int32(0), resp.ExitCode)
assert.Contains(t, string(resp.Stdout), "relay-test")
}