-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathstart.ps1
More file actions
65 lines (57 loc) · 2.16 KB
/
Copy pathstart.ps1
File metadata and controls
65 lines (57 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
echo "開始關閉服務"
docker-compose down
docker stop test1
docker stop test2
docker rm test1
docker rm test2
echo "關閉服務任務完成"
docker version
docker info
docker-compose version
docker-compose build
docker-compose up -d
rm -r .\python\result\
# 设置请求的URL
$url = "http://localhost:4000/api"
# 设置最大重试次数
$maxRetryAttempts = 5
# 循环尝试
for ($attempt = 1; $attempt -le $maxRetryAttempts; $attempt++) {
try {
# 发起GET请求
$response = Invoke-RestMethod -Uri $url -Method Get
# 获取消息字段的值
$message = $response.message
# 检查消息是否为期望的字符串
if ($message -eq "Hello, this is a simple RESTful API!") {
Write-Host "Response content is as expected."
break # 跳出循环,因为成功了
} else {
Write-Host "Response content does not match the expected string. Retrying..."
}
} catch {
Write-Host "Request failed. Retrying in 5 seconds..."
Start-Sleep -Seconds 5
}
}
docker run -d --name test1 --network host --env-file .sql.env -v ${PWD}/sqls:/docker-entrypoint-initdb.d databasesystem-database
docker run -d --name test2 --network host -e DB_HOST=localhost databasesystem-nodejs-app
while ($true) {
try {
# Run MySQL command and capture the output
$output = docker exec -it test1 mysql -h 127.0.0.1 -P 3306 2>&1
# Check if the output contains the access denied error
if ($output -match "Access denied for user 'root'@'127.0.0.1'") {
Write-Host "Connection successful"
break
} else {
Write-Host "Connection error: $output"
}
} catch {
Write-Host "Error: $_"
}
# Wait for one second before the next iteration
Start-Sleep -Seconds 3
}
docker run --rm -v ${PWD}/python/result:/opt/apps/test/python/result --network host databasesystem-python pytest --junitxml=/opt/apps/test/python/result/test-results.xml --json=/opt/apps/test/python/result/test-results.json --html=/opt/apps/test/python/result/report.html --self-contained-html
Start-Process -FilePath "${PWD}/python/result/report.html"