Skip to content

Commit a7400a1

Browse files
authored
Small improvements (#35)
* Output baseUrl of etherpad instance * Add parameter to change timeout setting * Set default scheme to 'http' * Output database error in metrics * Update version * Do not cancel github action tests * Fix tests * Add test for 2.1.0
1 parent 2f396a7 commit a7400a1

File tree

6 files changed

+24
-9
lines changed

6 files changed

+24
-9
lines changed

.github/workflows/e2e-test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ jobs:
4848
{ tag: "2.0.2", expected: "2.0.2" },
4949
{ tag: "2.0.0", expected: "2.0.0" },
5050
]
51+
fail-fast: false
5152

5253
steps:
5354
- name: Checkout repository
@@ -93,6 +94,7 @@ jobs:
9394
{ tag: "1.9.7", expected: "1.9.7" },
9495
{ tag: "1.8.18", expected: "1.8.18" },
9596
]
97+
fail-fast: false
9698

9799
steps:
98100
- name: Checkout repository
@@ -251,13 +253,15 @@ jobs:
251253
matrix:
252254
versions: [
253255
{tag: "develop", expected: "2.1.0"},
256+
{tag: "2.1.0", expected: "2.1.0"},
254257
{tag: "2.0.3", expected: "2.0.3"},
255258
{tag: "1.9.7", expected: "1.9.7"},
256259
{tag: "1.9.0", expected: "1.9.0"},
257260
{tag: "1.8.18", expected: "1.8.18"},
258261
{tag: "1.8.0", expected: "1.8.0"},
259262
{tag: "1.7.5", expected: "1.7.5"}
260263
]
264+
fail-fast: false
261265
steps:
262266
- name: Checkout repository
263267
uses: actions/checkout@v4

src/Console/ScanCommandOutputHelper.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ public function __construct(
2424
) {
2525
}
2626

27-
public function onScanApiStart(): void
27+
public function onScanApiStart(string $baseUrl): void
2828
{
29-
$this->symfonyStyle->title('Starting scan of api...');
29+
$this->symfonyStyle->title('Starting scan of api: ' . $baseUrl);
3030
}
3131

3232
public function onScanApiResponse(ResponseInterface $response): void
@@ -84,6 +84,12 @@ public function onStatsResult(array $data): void
8484
$startTime = new DateTimeImmutable('@' . ($data['httpStartTime'] / 1000));
8585
$this->symfonyStyle->info('Server running since: ' . $startTime->format(DateTimeInterface::RFC3339));
8686
}
87+
if (isset($data['ueberdb_writesFailed']) && $data['ueberdb_writesFailed'] > 0) {
88+
$this->symfonyStyle->error('Database writes failed: ' . $data['ueberdb_writesFailed']);
89+
}
90+
if (isset($data['ueberdb_readsFailed']) && $data['ueberdb_readsFailed'] > 0) {
91+
$this->symfonyStyle->error('Database reads failed: ' . $data['ueberdb_readsFailed']);
92+
}
8793
$this->output->writeln('Stats: ' . print_r($data, true), OutputInterface::VERBOSITY_DEBUG);
8894
}
8995

src/Service/ScannerService.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ class ScannerService
3838
private string $padId;
3939

4040
public function __construct(
41-
string $url
41+
string $url,
42+
float $timeout = 2.0,
4243
) {
4344
$stack = new HandlerStack(Utils::chooseHandler());
4445
$stack->push(Middleware::httpErrors(), 'http_errors');
@@ -47,10 +48,10 @@ public function __construct(
4748
$this->baseUrl = $url;
4849

4950
$this->client = new Client([
50-
'timeout' => 2.0,
51+
'timeout' => $timeout,
5152
'connect_timeout' => 2.0,
5253
RequestOptions::HEADERS => [
53-
'User-Agent' => 'EtherpadScanner/3.1.1',
54+
'User-Agent' => 'EtherpadScanner/3.2.0',
5455
],
5556
'handler' => $stack,
5657
'verify' => false,
@@ -86,6 +87,10 @@ private function scanBaseUrl(ScannerServiceCallbackInterface $callback): void
8687
->withFragment('')
8788
->withQuery('');
8889

90+
if ($uri->getScheme() === '') {
91+
$uri = $uri->withScheme('http');
92+
}
93+
8994
while (true) {
9095
$uriWithPad = $uri->withPath($uri->getPath() . '/p/' . $this->padId);
9196
$result = $this->scanForPath($uriWithPad);
@@ -140,7 +145,7 @@ private function scanForPath(UriInterface $uri): bool
140145

141146
private function scanApi(ScannerServiceCallbackInterface $callback): void
142147
{
143-
$callback->onScanApiStart();
148+
$callback->onScanApiStart($this->baseUrl);
144149
try {
145150
$response = $this->client->get($this->baseUrl . 'api');
146151
$callback->onScanApiResponse($response);

src/Service/ScannerServiceCallbackInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
interface ScannerServiceCallbackInterface
1414
{
15-
public function onScanApiStart(): void;
15+
public function onScanApiStart(string $baseUrl): void;
1616

1717
public function onScanApiResponse(ResponseInterface $response): void;
1818

tests/e2e/fixture/latest.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
Starting scan of api...
2+
Starting scan of api: http://localhost:9001/
33
=======================
44

55
[INFO] No revision in server header

tests/e2e/fixture/master_with_plugins.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
Starting scan of api...
2+
Starting scan of api: http://localhost:9001/
33
=======================
44

55
[INFO] No revision in server header

0 commit comments

Comments
 (0)