7a0da7932b
OSV-Scanner (Scheduled) / scan-scheduled (push) Failing after 0s
Create Release / test-gate (push) Has been cancelled
Create Release / release-gate (push) Has been cancelled
Create Release / ci-gate (push) Has been cancelled
Create Release / version-check (push) Has been cancelled
Create Release / e2e-test-gate (push) Has been cancelled
Create Release / responsive-test-gate (push) Has been cancelled
Create Release / compat-test-gate (push) Has been cancelled
Create Release / compose-integration-gate (push) Has been cancelled
Create Release / vulture-gate (push) Has been cancelled
Create Release / build (push) Has been cancelled
Create Release / provenance (push) Has been cancelled
Create Release / prerelease-docker (push) Has been cancelled
Create Release / publish-docker (push) Has been cancelled
Create Release / create-release (push) Has been cancelled
Create Release / cleanup-changelog (push) Has been cancelled
Create Release / trigger-pypi (push) Has been cancelled
Create Release / monitor-pypi (push) Has been cancelled
Create Release / Clean up orphan prerelease tags and signatures (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-form] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-metrics] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [research-workflow] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-core] (push) Has been cancelled
CodeQL Advanced / Analyze (javascript-typescript) (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [history-news] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [library] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [link-analytics] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-core] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [chat-lifecycle] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [error-benchmark] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [settings-pages] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) (push) Has been cancelled
Docker Tests (Consolidated) / Accessibility Tests (push) Has been cancelled
Docker Tests (Consolidated) / LLM Unit Tests (push) Has been cancelled
Docker Tests (Consolidated) / LLM Example Tests (push) Has been cancelled
Docker Tests (Consolidated) / Production Image Smoke Test (push) Has been cancelled
Docker Tests (Consolidated) / Infrastructure Tests (push) Has been cancelled
OSSF Scorecard / OSSF Security Scorecard Analysis (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [mobile] (push) Has been cancelled
Backwards Compatibility / Verify Encryption Constants (push) Has been cancelled
Backwards Compatibility / PyPI Version Compatibility (push) Has been cancelled
Backwards Compatibility / Database Migration Tests (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Docker Tests (Consolidated) / detect-changes (push) Has been cancelled
Docker Tests (Consolidated) / Build Test Image (push) Has been cancelled
Docker Tests (Consolidated) / All Pytest Tests + Coverage (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [accessibility] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [api-crud] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-login] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-pages] (push) Has been cancelled
Docker Tests (Consolidated) / UI Tests (Puppeteer) [auth-register] (push) Has been cancelled
184 lines
6.9 KiB
JavaScript
184 lines
6.9 KiB
JavaScript
const puppeteer = require('puppeteer');
|
|
const { browserConfig } = require('./browser_config');
|
|
const AuthHelper = require('./auth_helper');
|
|
const { getPuppeteerLaunchOptions } = require('./puppeteer_config');
|
|
const { setupDefaultModel } = require('./model_helper');
|
|
|
|
async function submitResearchBatch(page, queries) {
|
|
// Submit all researches as quickly as possible
|
|
const results = [];
|
|
|
|
for (let i = 0; i < queries.length; i++) {
|
|
const query = queries[i];
|
|
console.log(`\nSubmitting research ${i + 1}: "${query}"`);
|
|
|
|
// Go to home page
|
|
await page.goto('http://127.0.0.1:5000/', { waitUntil: 'domcontentloaded' });
|
|
|
|
// Fill and submit form quickly
|
|
await page.waitForSelector('#query', { timeout: 5000 });
|
|
await page.type('#query', query);
|
|
|
|
// Configure model using model_helper
|
|
// NOTE: We use setupDefaultModel() instead of hardcoding a model name because:
|
|
// 1. In CI, no real OLLAMA models are available (0 models filtered)
|
|
// 2. model_helper.js sets both #model and #model_hidden inputs correctly
|
|
// 3. The test environment needs proper model config
|
|
// Without this, research submission fails with "no model selected"
|
|
try {
|
|
await setupDefaultModel(page);
|
|
console.log('Model configured via model_helper');
|
|
} catch (e) {
|
|
console.log('Warning: Could not configure model:', e.message);
|
|
}
|
|
|
|
// Intercept the response
|
|
const responsePromise = new Promise((resolve) => {
|
|
const handler = async (response) => {
|
|
if (response.url().includes('/api/start_research') && response.status() === 200) {
|
|
try {
|
|
const data = await response.json();
|
|
page.off('response', handler);
|
|
resolve(data);
|
|
} catch {
|
|
resolve(null);
|
|
}
|
|
}
|
|
};
|
|
page.on('response', handler);
|
|
|
|
// Timeout after 10 seconds (faster timeout for batch submissions)
|
|
setTimeout(() => {
|
|
page.off('response', handler);
|
|
resolve({ timeout: true });
|
|
}, 10000);
|
|
});
|
|
|
|
// Wait for form to be ready and submit
|
|
await page.waitForSelector('button[type="submit"]:not([disabled])', { timeout: 5000 });
|
|
await page.click('button[type="submit"]');
|
|
|
|
// Wait for response
|
|
const response = await responsePromise;
|
|
|
|
if (response && !response.timeout) {
|
|
results.push({
|
|
query,
|
|
...response
|
|
});
|
|
console.log(`Response: ${JSON.stringify(response)}`);
|
|
} else {
|
|
console.log(`Failed to get response for research ${i + 1}`);
|
|
}
|
|
|
|
// Small delay between submissions to avoid overwhelming the server
|
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
}
|
|
|
|
return results;
|
|
}
|
|
|
|
(async () => {
|
|
let exitCode = 0;
|
|
const browser = await puppeteer.launch(getPuppeteerLaunchOptions());
|
|
|
|
const page = await browser.newPage();
|
|
|
|
try {
|
|
// Create a fresh user
|
|
const auth = new AuthHelper(page);
|
|
const username = 'directtest_' + Date.now();
|
|
const password = 'T3st!Secure#2024$LDR';
|
|
|
|
console.log('=== Testing Direct Execution Mode ===');
|
|
console.log(`LDR_QUEUE_MODE: ${process.env.LDR_QUEUE_MODE || 'not set'}`);
|
|
console.log(`LDR_MAX_CONCURRENT: ${process.env.LDR_MAX_CONCURRENT || 'not set'}`);
|
|
console.log('');
|
|
|
|
console.log('1. Creating user:', username);
|
|
await auth.register(username, password);
|
|
|
|
const isLoggedIn = await auth.isLoggedIn();
|
|
if (!isLoggedIn) {
|
|
await auth.login(username, password);
|
|
}
|
|
|
|
console.log('\n2. Testing direct mode execution...\n');
|
|
|
|
// Submit 3 researches quickly (reduced from 4 to speed up test)
|
|
const queries = [
|
|
'What is 2+2?', // Simple query for faster processing
|
|
'What is 3+3?', // Simple query for faster processing
|
|
'What is 4+4?' // Should be queued
|
|
];
|
|
|
|
const results = await submitResearchBatch(page, queries);
|
|
|
|
// Analyze results
|
|
console.log('\n3. Results Summary:');
|
|
console.log('===================');
|
|
|
|
let started = 0;
|
|
let queued = 0;
|
|
|
|
results.forEach((result, index) => {
|
|
if (result.status === 'success') {
|
|
started++;
|
|
console.log(`Research ${index + 1}: STARTED (ID: ${result.research_id})`);
|
|
} else if (result.status === 'queued') {
|
|
queued++;
|
|
console.log(`Research ${index + 1}: QUEUED (ID: ${result.research_id}, Position: ${result.queue_position})`);
|
|
}
|
|
});
|
|
|
|
console.log(`\nTotal Started: ${started}`);
|
|
console.log(`Total Queued: ${queued}`);
|
|
|
|
// In direct mode with max_concurrent=2, we expect:
|
|
// - First 2 researches: started immediately
|
|
// - Next 2 researches: queued but potentially started immediately if direct mode works
|
|
console.log('\n4. Checking if direct mode started queued researches...');
|
|
|
|
// Wait a bit for direct mode to potentially kick in
|
|
await new Promise(resolve => setTimeout(resolve, 3000));
|
|
|
|
// Check status of queued researches
|
|
if (queued > 0) {
|
|
console.log('\nChecking status of queued researches:');
|
|
for (const result of results) {
|
|
if (result.status === 'queued' && result.research_id) {
|
|
try {
|
|
const statusResponse = await page.evaluate(async (researchId) => {
|
|
const response = await fetch(`/research/api/status/${researchId}`);
|
|
return await response.json();
|
|
}, result.research_id);
|
|
|
|
console.log(`- Research ${result.research_id}: ${statusResponse.status} (progress: ${statusResponse.progress || 0}%)`);
|
|
|
|
if (statusResponse.status === 'in_progress') {
|
|
console.log(' ✅ Direct mode worked! Research was started from queue.');
|
|
}
|
|
} catch (e) {
|
|
console.log(` Error checking status: ${e.message}`);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Success criteria: At least 1 research started successfully
|
|
// In CI environments, network issues might prevent all from starting
|
|
if (started >= 1) {
|
|
console.log('\n✅ SUCCESS: Direct mode is working!');
|
|
} else {
|
|
console.log('\n❌ FAILURE: No researches started successfully');
|
|
}
|
|
|
|
} catch (error) {
|
|
console.error('Test failed:', error);
|
|
exitCode = 1;
|
|
} finally {
|
|
await browser.close();
|
|
}
|
|
process.exit(exitCode);
|
|
})();
|