增加生产环境配置文件。
This commit is contained in:
parent
aa3f497434
commit
e59c5c5c60
5
.env.dev
5
.env.dev
@ -7,7 +7,7 @@ IBP_PASSWORD=123456
|
||||
|
||||
# 测试配置
|
||||
TEST_DATA_DIR=test-data
|
||||
TEST_BATCH_SIZE=2
|
||||
TEST_BATCH_SIZE=1
|
||||
TEST_RETRY_COUNT=3
|
||||
TEST_BATCH_INTERVAL=2000
|
||||
TEST_MAX_RETRY_DELAY=10000
|
||||
@ -31,3 +31,6 @@ TEST_PROGRESS_FILE_PATH=test-data/test-progress.json
|
||||
PAGE_LOAD_MAX_RETRIES=5
|
||||
PAGE_LOAD_RETRY_INTERVAL=3000
|
||||
PAGE_LOAD_STABILITY_DELAY=2000
|
||||
|
||||
# 邮件配置
|
||||
EMAIL_RECIPIENTS=shengzeqiang@iscmtech.com, wanghaipeng@iscmtech.com
|
||||
9
.env.uat
9
.env.uat
@ -7,19 +7,19 @@ IBP_PASSWORD=Lianyu_123
|
||||
|
||||
# 测试配置
|
||||
TEST_DATA_DIR=test-data
|
||||
TEST_BATCH_SIZE=2
|
||||
TEST_BATCH_SIZE=1
|
||||
TEST_RETRY_COUNT=3
|
||||
TEST_BATCH_INTERVAL=2000
|
||||
TEST_MAX_RETRY_DELAY=10000
|
||||
|
||||
# 超时配置
|
||||
MENU_TIME_OUT=60000
|
||||
EXPECT_TIMEOUT=3600000
|
||||
EXPECT_TIMEOUT=36000000
|
||||
|
||||
# 浏览器配置
|
||||
BROWSER_HEADLESS=false
|
||||
BROWSER_SLOW_MO=100
|
||||
BROWSER_TIMEOUT=120000
|
||||
BROWSER_TIMEOUT=1200000
|
||||
VIEWPORT_WIDTH=1920
|
||||
VIEWPORT_HEIGHT=1080
|
||||
|
||||
@ -31,3 +31,6 @@ TEST_PROGRESS_FILE_PATH=test-data/test-progress.json
|
||||
PAGE_LOAD_MAX_RETRIES=5
|
||||
PAGE_LOAD_RETRY_INTERVAL=3000
|
||||
PAGE_LOAD_STABILITY_DELAY=2000
|
||||
|
||||
# 邮件配置
|
||||
EMAIL_RECIPIENTS=shengzeqiang@iscmtech.com, wanghaipeng@iscmtech.com
|
||||
@ -1,6 +1,13 @@
|
||||
// @ts-check
|
||||
const {defineConfig, devices} = require('@playwright/test');
|
||||
const testLifecycle = require('./src/hooks/testLifecycle');
|
||||
const dotenv = require('dotenv');
|
||||
|
||||
// 根据环境加载对应的.env文件
|
||||
const env = process.env.NODE_ENV || 'dev';
|
||||
const envPath = `.env.${env}`;
|
||||
dotenv.config({ path: envPath });
|
||||
console.log(`[Playwright Config] 已加载环境配置: ${envPath}`);
|
||||
|
||||
/**
|
||||
* Read environment variables and process them
|
||||
|
||||
BIN
playwright.rar
BIN
playwright.rar
Binary file not shown.
@ -1,34 +1,22 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name devops.iscmtech.com;
|
||||
@echo off
|
||||
echo Starting automated tests...
|
||||
cd /d %~dp0
|
||||
|
||||
:: 设置控制台编码为UTF-8
|
||||
chcp 65001 > nul
|
||||
|
||||
location ~ ^/(deploy/longi|notice/zentao/statistics) {
|
||||
proxy_pass http://127.0.0.1:8080;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
location /deploy-ease/ {
|
||||
proxy_pass http://127.0.0.1:8081;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
location /prod/longi/ {
|
||||
proxy_pass http://127.0.0.1:8082;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
location /order/longi/ {
|
||||
proxy_pass http://127.0.0.1:8084;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
}
|
||||
:: 设置默认环境为dev
|
||||
if "%1"=="" (
|
||||
set TEST_ENV=dev
|
||||
) else (
|
||||
set TEST_ENV=%1
|
||||
)
|
||||
|
||||
echo [Batch] Preparing to run tests in %TEST_ENV% environment...
|
||||
|
||||
:: 运行测试并发送报告
|
||||
set NODE_ENV=%TEST_ENV%
|
||||
node src/scripts/runTestsAndSendReport.js
|
||||
|
||||
echo.
|
||||
echo [Batch] Execution completed
|
||||
@ -22,7 +22,7 @@ class TestLifecycle {
|
||||
await FileUtils.ensureDirectoryExists('./test-results');
|
||||
// 清空之前的性能数据
|
||||
await performanceService.clearPerformanceData();
|
||||
console.log('✨ 测试环境初始化完成');
|
||||
console.log('✨ 环境初始化完成');
|
||||
}
|
||||
|
||||
async afterAll() {
|
||||
@ -30,9 +30,11 @@ class TestLifecycle {
|
||||
try {
|
||||
const performanceData = performanceService.getPerformanceData();
|
||||
console.log('获取到性能数据:', performanceData.length, '条记录');
|
||||
const report = this.generateReport(performanceData);
|
||||
// 获取当前环境
|
||||
const env = process.env.NODE_ENV || 'dev';
|
||||
const report = this.generateReport(performanceData, env);
|
||||
await this.saveReport(report);
|
||||
console.log(`📊 测试报告已生成: ${this.reportPath}`);
|
||||
console.log(`📊 ${env} 测试报告已生成: ${this.reportPath}`);
|
||||
} catch (error) {
|
||||
console.error('生成测试报告出错:', error);
|
||||
throw error;
|
||||
@ -42,9 +44,10 @@ class TestLifecycle {
|
||||
/**
|
||||
* 生成测试报告
|
||||
* @param {Object} data 性能数据对象
|
||||
* @param {String} env 当前环境
|
||||
* @returns {String} 测试报告字符串
|
||||
*/
|
||||
generateReport(performanceData) {
|
||||
generateReport(performanceData, env) {
|
||||
// 统计数据
|
||||
const totalTests = performanceData.length;
|
||||
const successTests = performanceData.filter(record => record.success).length;
|
||||
@ -82,7 +85,7 @@ class TestLifecycle {
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>测试执行报告</title>
|
||||
<title>测试执行报告 (${env})</title>
|
||||
<style>
|
||||
body { font-family: Arial, sans-serif; margin: 0; padding: 20px; background: #f5f5f5; }
|
||||
.container { max-width: 1200px; margin: 0 auto; background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
|
||||
@ -103,7 +106,7 @@ class TestLifecycle {
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<h1>测试执行报告</h1>
|
||||
<h1>测试执行报告 (${env})</h1>
|
||||
<p>执行时间: ${new Date().toLocaleString()}</p>
|
||||
</div>
|
||||
|
||||
|
||||
@ -53,9 +53,11 @@ async function runTestsAndSendReport() {
|
||||
|
||||
// 发送邮件
|
||||
console.log('[Node] Sending test report email...');
|
||||
const emailRecipients = process.env.EMAIL_RECIPIENTS || 'wanghaipeng@iscmtech.com';
|
||||
console.log(`[Node] Email recipients: ${emailRecipients}`);
|
||||
const result = await emailService.sendMail({
|
||||
to: 'dengqichen@iscmtech.com',
|
||||
subject: `[成功] Playwright自动化测试报告 (${env}) - ${startTime.toLocaleDateString()}`,
|
||||
to: emailRecipients,
|
||||
subject: `隆基需求计划页面可用性-自动化测试报告 (${env}) - ${startTime.toLocaleDateString()}`,
|
||||
html: performanceReport
|
||||
});
|
||||
|
||||
@ -73,9 +75,10 @@ async function runTestsAndSendReport() {
|
||||
const reportPath = path.join(process.cwd(), 'test-results', 'performance-report.html');
|
||||
if (fs.existsSync(reportPath)) {
|
||||
const performanceReport = fs.readFileSync(reportPath, 'utf8');
|
||||
const emailRecipients = process.env.EMAIL_RECIPIENTS || 'wanghaipeng@iscmtech.com';
|
||||
const result = await emailService.sendMail({
|
||||
to: 'wanghaipeng@iscmtech.com',
|
||||
subject: `[失败] Playwright自动化测试报告 (${env}) - ${startTime.toLocaleDateString()}`,
|
||||
to: emailRecipients,
|
||||
subject: `隆基需求计划页面可用性-自动化测试报告 (${env}) - ${startTime.toLocaleDateString()}`,
|
||||
html: performanceReport
|
||||
});
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user