Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion tests/integration/a2a/basic/a2a_agent_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('A2A: Remote Agent Basic', () => {
startFailureTimeout: 60000,
});
await server.start();
}, 60000);
});

afterAll(async () => {
await server.stop();
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/a2a/input_required/input_required_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as path from 'node:path';
import {afterAll, beforeAll, describe, expect, it} from 'vitest';
import {AdkTsApiServer} from '../../test_api_server.js';

const TEST_TIMEOUT = 60000;
const SERVER_START_TIMEOUT_MS = 60000;

describe('A2A: RemoteAgent InputRequired', () => {
let server: AdkTsApiServer;
Expand All @@ -19,10 +19,10 @@ describe('A2A: RemoteAgent InputRequired', () => {
server = new AdkTsApiServer({
agentsDir: path.join(__dirname, 'test_agents'),
a2a: true,
startFailureTimeout: TEST_TIMEOUT,
startFailureTimeout: SERVER_START_TIMEOUT_MS,
});
await server.start();
}, TEST_TIMEOUT);
});

afterAll(async () => {
await server.stop();
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/a2a/stream/stream_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as path from 'node:path';
import {afterAll, beforeAll, describe, expect, it} from 'vitest';
import {AdkTsApiServer} from '../../test_api_server.js';

const TEST_TIMEOUT = 60000;
const SERVER_START_TIMEOUT_MS = 60000;

describe('A2A: RemoteAgent Streaming', () => {
let server: AdkTsApiServer;
Expand All @@ -19,10 +19,10 @@ describe('A2A: RemoteAgent Streaming', () => {
server = new AdkTsApiServer({
agentsDir: path.join(__dirname, 'test_agents'),
a2a: true,
startFailureTimeout: TEST_TIMEOUT,
startFailureTimeout: SERVER_START_TIMEOUT_MS,
});
await server.start();
}, TEST_TIMEOUT);
});

afterAll(async () => {
await server.stop();
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/adk_web/webui_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('WebUI Integration Test', () => {
});
await server.start();
url = server.url;
}, 20000);
});

afterAll(async () => {
if (server) {
Expand Down Expand Up @@ -82,4 +82,4 @@ describe('WebUI Integration Test', () => {
});
},
);
}, 20000);
});
25 changes: 10 additions & 15 deletions tests/integration/agent_loader/agent_dirname_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {sendInput} from '../test_case_utils.js';

const execAsync = promisify(exec);
const dirname = process.cwd();
const TEST_EXECUTION_TIMEOUT = 40000;

describe.each(['__dirname', '__filename', 'import_meta_url'])(
'Agent with %s',
Expand All @@ -28,23 +27,19 @@ describe.each(['__dirname', '__filename', 'import_meta_url'])(
await execAsync('npm install', {cwd: projectPath});
});

it(
'should run agent and load params from file nearby via package.json script',
async () => {
const childProcess = spawn('npm', ['run', 'start'], {
cwd: projectPath,
shell: true,
});
it('should run agent and load params from file nearby via package.json script', async () => {
const childProcess = spawn('npm', ['run', 'start'], {
cwd: projectPath,
shell: true,
});

let response = await sendInput(childProcess, 'Tell me a joke.\n');
let response = await sendInput(childProcess, 'Tell me a joke.\n');

expect(response.toString()).toContain("I'm stubby model response!");
expect(response.toString()).toContain("I'm stubby model response!");

response = await sendInput(childProcess, 'exit\n');
expect(response.toString()).toContain('');
},
TEST_EXECUTION_TIMEOUT,
);
response = await sendInput(childProcess, 'exit\n');
expect(response.toString()).toContain('');
});

afterAll(async () => {
await fs
Expand Down
119 changes: 53 additions & 66 deletions tests/integration/app_loader/app_loader_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {sendInput} from '../test_case_utils.js';

const execAsync = promisify(exec);
const dirname = process.cwd();
const TEST_EXECUTION_TIMEOUT = 40000;

describe('App loader CLI integration', () => {
describe.each(['app_ts', 'app_js', 'app_default'])(
Expand All @@ -31,26 +30,22 @@ describe('App loader CLI integration', () => {
await execAsync('npm install', {cwd: projectPath});
});

it(
'should run app via package.json start script and get responses',
async () => {
const childProcess = spawn('npm', ['run', 'start'], {
cwd: projectPath,
shell: true,
});

let response = await sendInput(
childProcess,
'Tell me about the app.\n',
);

expect(response.toString()).toContain('Hello from');

response = await sendInput(childProcess, 'exit\n');
expect(response.toString()).toContain('');
},
TEST_EXECUTION_TIMEOUT,
);
it('should run app via package.json start script and get responses', async () => {
const childProcess = spawn('npm', ['run', 'start'], {
cwd: projectPath,
shell: true,
});

let response = await sendInput(
childProcess,
'Tell me about the app.\n',
);

expect(response.toString()).toContain('Hello from');

response = await sendInput(childProcess, 'exit\n');
expect(response.toString()).toContain('');
});

afterAll(async () => {
await fs
Expand All @@ -77,55 +72,47 @@ describe('AgentLoader discovery and loading integration', () => {
beforeAll(async () => {
await execAsync('npm install', {cwd: projectPath});
loader = new AgentLoader(projectPath);
// Bundle the discovered entrypoints under the hook budget: preloadAgents()
// esbuild-bundles all four, and paying that inside listApps() made the
// discovery assertion itself time out on loaded runners.
await loader.preloadAgents();
});

it(
'should discover apps vs agents across directories and standalone files',
async () => {
const apps = await loader.listApps();
expect(apps).toHaveLength(2);
expect(apps).toContain('service_alpha');
expect(apps).toContain('standalone_app');

const agentsAndApps = await loader.listAgents();
expect(agentsAndApps).toHaveLength(4);
expect(agentsAndApps).toContain('service_alpha');
expect(agentsAndApps).toContain('service_beta');
expect(agentsAndApps).toContain('standalone_agent');
expect(agentsAndApps).toContain('standalone_app');
},
TEST_EXECUTION_TIMEOUT,
);
it('should discover apps vs agents across directories and standalone files', async () => {
const apps = await loader.listApps();
expect(apps).toHaveLength(2);
expect(apps).toContain('service_alpha');
expect(apps).toContain('standalone_app');

const agentsAndApps = await loader.listAgents();
expect(agentsAndApps).toHaveLength(4);
expect(agentsAndApps).toContain('service_alpha');
expect(agentsAndApps).toContain('service_beta');
expect(agentsAndApps).toContain('standalone_agent');
expect(agentsAndApps).toContain('standalone_app');
});

it(
'should load App from directory entrypoint and expose App and rootAgent',
async () => {
const appFile = await loader.getAppFile('service_alpha');
const loaded = await appFile.load();
expect(isApp(loaded)).toBe(true);
expect((loaded as App).name).toBe('alpha_app');

const rootAgent = await appFile.loadAgent();
expect(isBaseAgent(rootAgent)).toBe(true);
expect(rootAgent.name).toBe('alpha_agent');
},
TEST_EXECUTION_TIMEOUT,
);
it('should load App from directory entrypoint and expose App and rootAgent', async () => {
const appFile = await loader.getAppFile('service_alpha');
const loaded = await appFile.load();
expect(isApp(loaded)).toBe(true);
expect((loaded as App).name).toBe('alpha_app');

it(
'should synthesize App when loadApp() is called on BaseAgent file',
async () => {
const agentFile = await loader.getAppFile('service_beta');
const loaded = await agentFile.load();
expect(isBaseAgent(loaded)).toBe(true);
expect(isApp(loaded)).toBe(false);

const synthApp = await agentFile.loadApp();
expect(isApp(synthApp)).toBe(true);
expect(synthApp.rootAgent.name).toBe('beta_agent');
},
TEST_EXECUTION_TIMEOUT,
);
const rootAgent = await appFile.loadAgent();
expect(isBaseAgent(rootAgent)).toBe(true);
expect(rootAgent.name).toBe('alpha_agent');
});

it('should synthesize App when loadApp() is called on BaseAgent file', async () => {
const agentFile = await loader.getAppFile('service_beta');
const loaded = await agentFile.load();
expect(isBaseAgent(loaded)).toBe(true);
expect(isApp(loaded)).toBe(false);

const synthApp = await agentFile.loadApp();
expect(isApp(synthApp)).toBe(true);
expect(synthApp.rootAgent.name).toBe('beta_agent');
});

afterAll(async () => {
await loader.disposeAll();
Expand Down
88 changes: 34 additions & 54 deletions tests/integration/build_setup/build_setup_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import {getResponse, sendInput} from '../test_case_utils.js';
const execAsync = promisify(exec);
const dirname = process.cwd();

const TEST_EXECUTION_TIMEOUT = 20000;

describe('Build setup', () => {
describe.each([
'js_commonjs',
Expand Down Expand Up @@ -45,68 +43,50 @@ describe('Build setup', () => {
}
});

it(
'should build and run agent successfully',
async () => {
const childProcess = spawn('npm', ['run', 'start'], {
cwd: projectPath,
shell: true,
});
it('should build and run agent successfully', async () => {
const childProcess = spawn('npm', ['run', 'start'], {
cwd: projectPath,
shell: true,
});

let response = await sendInput(childProcess, 'Tell me a joke.\n');
expect(response.toString()).toContain('test-llm-model-response');
let response = await sendInput(childProcess, 'Tell me a joke.\n');
expect(response.toString()).toContain('test-llm-model-response');

response = await sendInput(childProcess, 'exit\n');
expect(response.toString()).toContain('');
},
TEST_EXECUTION_TIMEOUT,
);
response = await sendInput(childProcess, 'exit\n');
expect(response.toString()).toContain('');
});

it.skipIf(
!['js_commonjs', 'js_esm', 'ts_commonjs', 'ts_esm'].includes(buildSetup),
)(
'should handle dynamic imports in DatabaseSessionService',
async () => {
const childProcess = spawn('npm', ['run', 'test:db'], {
cwd: projectPath,
shell: true,
});

const response = await getResponse(childProcess);
expect(response.toString()).toContain('DYNAMIC_IMPORT_SUCCESS');
},
TEST_EXECUTION_TIMEOUT,
);
)('should handle dynamic imports in DatabaseSessionService', async () => {
const childProcess = spawn('npm', ['run', 'test:db'], {
cwd: projectPath,
shell: true,
});

const response = await getResponse(childProcess);
expect(response.toString()).toContain('DYNAMIC_IMPORT_SUCCESS');
});

it.skipIf(
!['js_commonjs', 'js_esm', 'ts_commonjs', 'ts_esm'].includes(buildSetup),
)(
'should import devtools successfully',
async () => {
const childProcess = spawn('npm', ['run', 'test:devtools'], {
cwd: projectPath,
shell: true,
});

const response = await getResponse(childProcess);
expect(response.toString()).toContain(
'Devtools verification successful',
);
},
TEST_EXECUTION_TIMEOUT,
);
)('should import devtools successfully', async () => {
const childProcess = spawn('npm', ['run', 'test:devtools'], {
cwd: projectPath,
shell: true,
});

const response = await getResponse(childProcess);
expect(response.toString()).toContain('Devtools verification successful');
});

it(
'should run devtools CLI successfully',
async () => {
const {stdout} = await execAsync('npx @google/adk-devtools --version', {
cwd: projectPath,
});
it('should run devtools CLI successfully', async () => {
const {stdout} = await execAsync('npx @google/adk-devtools --version', {
cwd: projectPath,
});

expect(stdout).toBeTruthy();
},
TEST_EXECUTION_TIMEOUT,
);
expect(stdout).toBeTruthy();
});

afterAll(async () => {
await fs
Expand Down
Loading