2023-05-11 17:21:52 +05:45
|
|
|
<?php declare(strict_types=1);
|
|
|
|
|
/**
|
|
|
|
|
* ownCloud
|
|
|
|
|
*
|
|
|
|
|
* @author Sajan Gurung <sajan@jankaritech.com>
|
|
|
|
|
* @copyright Copyright (c) 2023 Sajan Gurung sajan@jankaritech.com
|
|
|
|
|
*
|
|
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU Affero General Public License,
|
|
|
|
|
* as published by the Free Software Foundation;
|
|
|
|
|
* either version 3 of the License, or any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
use Behat\Behat\Context\Context;
|
2023-09-18 10:21:35 +02:00
|
|
|
use Behat\Gherkin\Node\TableNode;
|
2023-06-06 11:57:04 +05:45
|
|
|
use GuzzleHttp\Exception\GuzzleException;
|
2026-07-15 11:27:47 +05:45
|
|
|
use Psr\Http\Message\ResponseInterface;
|
|
|
|
|
use TestHelpers\HttpRequestHelper;
|
|
|
|
|
use TestHelpers\KeycloakHelper;
|
2023-05-11 17:21:52 +05:45
|
|
|
use TestHelpers\OcisConfigHelper;
|
2024-09-03 12:50:59 +05:45
|
|
|
use TestHelpers\GraphHelper;
|
2023-05-11 17:21:52 +05:45
|
|
|
use PHPUnit\Framework\Assert;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* steps needed to re-configure oCIS server
|
|
|
|
|
*/
|
|
|
|
|
class OcisConfigContext implements Context {
|
2024-12-10 09:59:52 +05:45
|
|
|
private array $enabledPermissionsRoles = [];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function getEnabledPermissionsRoles(): array {
|
|
|
|
|
return $this->enabledPermissionsRoles;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param array $enabledPermissionsRoles
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function setEnabledPermissionsRoles(array $enabledPermissionsRoles): void {
|
|
|
|
|
$this->enabledPermissionsRoles = $enabledPermissionsRoles;
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-11 17:21:52 +05:45
|
|
|
/**
|
2024-04-26 15:27:00 +05:45
|
|
|
* @Given async upload has been enabled with post-processing delayed to :delayTime seconds
|
2023-05-11 17:21:52 +05:45
|
|
|
*
|
|
|
|
|
* @param string $delayTime
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
* @throws GuzzleException
|
|
|
|
|
*/
|
2024-04-26 15:27:00 +05:45
|
|
|
public function asyncUploadHasBeenEnabledWithDelayedPostProcessing(string $delayTime): void {
|
2026-06-22 07:37:21 +00:00
|
|
|
if (OcisConfigHelper::isK8s()) {
|
2025-08-04 14:31:30 +05:45
|
|
|
$envs = [
|
|
|
|
|
"storageusers" => ["OCIS_ASYNC_UPLOADS" => true, "OCIS_EVENTS_ENABLE_TLS" => false],
|
|
|
|
|
"postprocessing" => ["POSTPROCESSING_DELAY" => $delayTime . "s"],
|
|
|
|
|
];
|
|
|
|
|
$response = OcisConfigHelper::reConfigureOcisK8s($envs);
|
|
|
|
|
} else {
|
|
|
|
|
$envs = [
|
|
|
|
|
"OCIS_ASYNC_UPLOADS" => true,
|
|
|
|
|
"OCIS_EVENTS_ENABLE_TLS" => false,
|
|
|
|
|
"POSTPROCESSING_DELAY" => $delayTime . "s",
|
|
|
|
|
];
|
|
|
|
|
$response = OcisConfigHelper::reConfigureOcis($envs);
|
|
|
|
|
}
|
2023-05-11 17:21:52 +05:45
|
|
|
|
2026-06-22 07:37:21 +00:00
|
|
|
$resBody = $response->getBody()->getContents();
|
2023-05-11 17:21:52 +05:45
|
|
|
Assert::assertEquals(
|
|
|
|
|
200,
|
|
|
|
|
$response->getStatusCode(),
|
2026-06-22 07:37:21 +00:00
|
|
|
"Failed to set async upload with delayed post processing. Response: $resBody",
|
2023-05-11 17:21:52 +05:45
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-06-06 11:57:04 +05:45
|
|
|
* @Given the config :configVariable has been set to :configValue
|
2025-08-04 14:31:30 +05:45
|
|
|
* @Given the config :configVariable has been set to :configValue for :serviceName service
|
2023-05-11 17:21:52 +05:45
|
|
|
*
|
2023-06-06 11:57:04 +05:45
|
|
|
* @param string $configVariable
|
|
|
|
|
* @param string $configValue
|
2025-08-04 14:31:30 +05:45
|
|
|
* @param string|null $serviceName
|
2023-05-11 17:21:52 +05:45
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
* @throws GuzzleException
|
|
|
|
|
*/
|
2025-08-04 14:31:30 +05:45
|
|
|
public function theConfigHasBeenSetTo(
|
|
|
|
|
string $configVariable,
|
|
|
|
|
string $configValue,
|
|
|
|
|
?string $serviceName = null,
|
|
|
|
|
): void {
|
|
|
|
|
if (getenv("K8S") === "true") {
|
|
|
|
|
$envs = [
|
|
|
|
|
$serviceName => [$configVariable => $configValue],
|
|
|
|
|
];
|
|
|
|
|
$response = OcisConfigHelper::reConfigureOcisK8s($envs);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
$envs = [
|
|
|
|
|
$configVariable => $configValue,
|
|
|
|
|
];
|
|
|
|
|
$response = OcisConfigHelper::reConfigureOcis($envs);
|
|
|
|
|
}
|
2023-05-11 17:21:52 +05:45
|
|
|
|
2026-07-15 11:27:47 +05:45
|
|
|
$this->assertOcisRestarted(
|
|
|
|
|
$response,
|
|
|
|
|
"Failed to set config $configVariable=$configValue.",
|
2023-05-11 17:21:52 +05:45
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-03 12:50:59 +05:45
|
|
|
/**
|
|
|
|
|
* @Given the administrator has enabled the permissions role :role
|
|
|
|
|
*
|
|
|
|
|
* @param string $role
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function theAdministratorHasEnabledTheRole(string $role): void {
|
|
|
|
|
$roleId = GraphHelper::getPermissionsRoleIdByName($role);
|
|
|
|
|
$defaultRoles = array_values(GraphHelper::DEFAULT_PERMISSIONS_ROLES);
|
2025-01-15 15:30:01 +05:45
|
|
|
if (!\in_array($roleId, $defaultRoles)) {
|
2024-09-03 12:50:59 +05:45
|
|
|
$defaultRoles[] = $roleId;
|
|
|
|
|
}
|
2025-08-04 14:31:30 +05:45
|
|
|
|
|
|
|
|
if (getenv("K8S") === "true") {
|
|
|
|
|
$envs = [
|
|
|
|
|
'graph' => [ "GRAPH_AVAILABLE_ROLES" => implode(',', $defaultRoles)],
|
|
|
|
|
];
|
|
|
|
|
$response = OcisConfigHelper::reConfigureOcisK8s($envs);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
$envs = [
|
|
|
|
|
"GRAPH_AVAILABLE_ROLES" => implode(',', $defaultRoles),
|
|
|
|
|
];
|
|
|
|
|
$response = OcisConfigHelper::reConfigureOcis($envs);
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-22 07:37:21 +00:00
|
|
|
$resBody = $response->getBody()->getContents();
|
2024-09-03 12:50:59 +05:45
|
|
|
Assert::assertEquals(
|
|
|
|
|
200,
|
|
|
|
|
$response->getStatusCode(),
|
2026-06-22 07:37:21 +00:00
|
|
|
"Failed to enable role $role. Response: $resBody",
|
2024-09-03 12:50:59 +05:45
|
|
|
);
|
2024-12-10 09:59:52 +05:45
|
|
|
$this->setEnabledPermissionsRoles($defaultRoles);
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-10 17:15:10 +05:45
|
|
|
/**
|
|
|
|
|
* @Given the administrator has enabled the following share permissions roles:
|
|
|
|
|
*
|
|
|
|
|
* @param TableNode $table
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
2025-06-12 10:59:16 +05:45
|
|
|
public function theAdministratorHasEnabledTheFollowingSharePermissionsRoles(TableNode $table): void {
|
2025-06-10 17:15:10 +05:45
|
|
|
$defaultRoles = array_values(GraphHelper::DEFAULT_PERMISSIONS_ROLES);
|
|
|
|
|
$roles = [];
|
|
|
|
|
foreach ($table->getHash() as $row) {
|
2025-06-12 10:59:16 +05:45
|
|
|
$roles[] = $row['permissions-role'];
|
|
|
|
|
$roleId = GraphHelper::getPermissionsRoleIdByName($row['permissions-role']);
|
2025-06-10 17:15:10 +05:45
|
|
|
if (!\in_array($roleId, $defaultRoles)) {
|
|
|
|
|
$defaultRoles[] = $roleId;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-04 14:31:30 +05:45
|
|
|
if (getenv("K8S") === "true") {
|
|
|
|
|
$envs = [
|
|
|
|
|
'graph' => ["GRAPH_AVAILABLE_ROLES" => implode(',', $defaultRoles)],
|
|
|
|
|
];
|
|
|
|
|
$response = OcisConfigHelper::reConfigureOcisK8s($envs);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
$envs = [
|
|
|
|
|
"GRAPH_AVAILABLE_ROLES" => implode(',', $defaultRoles),
|
|
|
|
|
];
|
|
|
|
|
$response = OcisConfigHelper::reConfigureOcis($envs);
|
|
|
|
|
}
|
2025-06-10 17:15:10 +05:45
|
|
|
|
2026-06-22 07:37:21 +00:00
|
|
|
$resBody = $response->getBody()->getContents();
|
2025-06-10 17:15:10 +05:45
|
|
|
Assert::assertEquals(
|
|
|
|
|
200,
|
|
|
|
|
$response->getStatusCode(),
|
2026-06-22 07:37:21 +00:00
|
|
|
"Failed to enable roles: " . implode(', ', $roles) . ". Response: $resBody",
|
2025-06-10 17:15:10 +05:45
|
|
|
);
|
|
|
|
|
$this->setEnabledPermissionsRoles($defaultRoles);
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-10 09:59:52 +05:45
|
|
|
/**
|
|
|
|
|
* @Given the administrator has disabled the permissions role :role
|
|
|
|
|
*
|
|
|
|
|
* @param string $role
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function theAdministratorHasDisabledThePermissionsRole(string $role): void {
|
|
|
|
|
$roleId = GraphHelper::getPermissionsRoleIdByName($role);
|
|
|
|
|
$availableRoles = $this->getEnabledPermissionsRoles();
|
|
|
|
|
|
|
|
|
|
if ($key = array_search($roleId, $availableRoles)) {
|
|
|
|
|
unset($availableRoles[$key]);
|
|
|
|
|
}
|
2025-08-04 14:31:30 +05:45
|
|
|
if (getenv("K8S") === "true") {
|
|
|
|
|
$envs = [
|
|
|
|
|
'graph' => [ "GRAPH_AVAILABLE_ROLES" => implode(',', $availableRoles)],
|
|
|
|
|
];
|
|
|
|
|
$response = OcisConfigHelper::reConfigureOcisK8s($envs);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
$envs = [
|
|
|
|
|
"GRAPH_AVAILABLE_ROLES" => implode(',', $availableRoles),
|
|
|
|
|
];
|
|
|
|
|
$response = OcisConfigHelper::reConfigureOcis($envs);
|
|
|
|
|
}
|
2026-06-22 07:37:21 +00:00
|
|
|
$resBody = $response->getBody()->getContents();
|
2024-12-10 09:59:52 +05:45
|
|
|
Assert::assertEquals(
|
|
|
|
|
200,
|
|
|
|
|
$response->getStatusCode(),
|
2026-06-22 07:37:21 +00:00
|
|
|
"Failed to disable role $role. Response: $resBody",
|
2024-12-10 09:59:52 +05:45
|
|
|
);
|
|
|
|
|
$this->setEnabledPermissionsRoles($availableRoles);
|
2024-09-03 12:50:59 +05:45
|
|
|
}
|
|
|
|
|
|
2023-09-25 11:50:34 +02:00
|
|
|
/**
|
2025-08-04 14:31:30 +05:45
|
|
|
* @Given the config :configVariable has been set to path :path for :serviceName service
|
2023-09-25 11:50:34 +02:00
|
|
|
*
|
|
|
|
|
* @param string $configVariable
|
|
|
|
|
* @param string $path
|
2025-08-04 14:31:30 +05:45
|
|
|
* @param string|null $serviceName
|
2023-09-25 11:50:34 +02:00
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
* @throws GuzzleException
|
|
|
|
|
*/
|
2025-08-04 14:31:30 +05:45
|
|
|
public function theConfigHasBeenSetToPath(string $configVariable, string $path, ?string $serviceName = null): void {
|
|
|
|
|
if (getenv("K8S") === "true") {
|
2026-06-22 07:37:21 +00:00
|
|
|
if (\str_ends_with($configVariable, "PASSWORD_POLICY_BANNED_PASSWORDS_LIST")) {
|
2026-03-12 10:46:13 +05:45
|
|
|
// The banned password list is already configured in K8s setup.
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// In K8s, we MUST use the mounted paths
|
|
|
|
|
// All files for test MUST be mounted in '/etc/ocis/' + $path
|
2025-12-02 16:42:10 +05:45
|
|
|
$k8sPath = "/etc/ocis/" . $path;
|
2025-08-04 14:31:30 +05:45
|
|
|
$envs = [
|
2025-12-02 16:42:10 +05:45
|
|
|
$serviceName => [$configVariable => $k8sPath],
|
2025-08-04 14:31:30 +05:45
|
|
|
];
|
|
|
|
|
$response = OcisConfigHelper::reConfigureOcisK8s($envs);
|
|
|
|
|
|
|
|
|
|
} else {
|
2025-12-02 16:42:10 +05:45
|
|
|
$path = \dirname(__FILE__) . "/../../" . $path;
|
2025-08-04 14:31:30 +05:45
|
|
|
$envs = [
|
2025-06-19 10:46:56 +05:45
|
|
|
$configVariable => $path,
|
2025-08-04 14:31:30 +05:45
|
|
|
];
|
|
|
|
|
$response = OcisConfigHelper::reConfigureOcis($envs);
|
|
|
|
|
}
|
2026-06-22 07:37:21 +00:00
|
|
|
$resBody = $response->getBody()->getContents();
|
2024-05-02 14:40:41 +05:45
|
|
|
Assert::assertEquals(
|
|
|
|
|
200,
|
|
|
|
|
$response->getStatusCode(),
|
2026-06-22 07:37:21 +00:00
|
|
|
"Failed to set config $configVariable=$path. Response: $resBody",
|
2024-05-02 14:40:41 +05:45
|
|
|
);
|
2023-09-25 11:50:34 +02:00
|
|
|
}
|
|
|
|
|
|
2023-09-18 10:21:35 +02:00
|
|
|
/**
|
|
|
|
|
* @Given the following configs have been set:
|
|
|
|
|
*
|
|
|
|
|
* @param TableNode $table
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
* @throws GuzzleException
|
|
|
|
|
*/
|
|
|
|
|
public function theConfigHasBeenSetToValue(TableNode $table): void {
|
|
|
|
|
$envs = [];
|
2025-08-04 14:31:30 +05:45
|
|
|
if (getenv("K8S") === "true") {
|
|
|
|
|
foreach ($table->getHash() as $row) {
|
2025-12-02 16:42:10 +05:45
|
|
|
$envs[$row['service']][$row['config']] = $row['value'];
|
2025-08-04 14:31:30 +05:45
|
|
|
}
|
|
|
|
|
$response = OcisConfigHelper::reConfigureOcisK8s($envs);
|
|
|
|
|
} else {
|
|
|
|
|
foreach ($table->getHash() as $row) {
|
|
|
|
|
$envs[$row['config']] = $row['value'];
|
|
|
|
|
}
|
|
|
|
|
$response = OcisConfigHelper::reConfigureOcis($envs);
|
2023-09-18 10:21:35 +02:00
|
|
|
}
|
|
|
|
|
|
2026-06-22 07:37:21 +00:00
|
|
|
$resBody = $response->getBody()->getContents();
|
2023-09-18 10:21:35 +02:00
|
|
|
Assert::assertEquals(
|
|
|
|
|
200,
|
|
|
|
|
$response->getStatusCode(),
|
2026-06-22 07:37:21 +00:00
|
|
|
"Failed to set config. Response: $resBody",
|
2023-09-18 10:21:35 +02:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-12 15:57:43 +05:45
|
|
|
/**
|
|
|
|
|
* @Given the administrator has started service :service separately with the following configs:
|
|
|
|
|
*
|
|
|
|
|
* @param string $service
|
|
|
|
|
* @param TableNode $table
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
* @throws GuzzleException
|
|
|
|
|
*/
|
|
|
|
|
public function theAdministratorHasStartedServiceSeparatelyWithTheFollowingConfig(
|
|
|
|
|
string $service,
|
2025-06-19 15:34:02 +05:45
|
|
|
TableNode $table,
|
2024-12-12 15:57:43 +05:45
|
|
|
): void {
|
|
|
|
|
$envs = [];
|
|
|
|
|
foreach ($table->getHash() as $row) {
|
|
|
|
|
$envs[$row['config']] = $row['value'];
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-19 12:12:17 +05:45
|
|
|
$response = OcisConfigHelper::startService($service, $envs);
|
2026-06-22 07:37:21 +00:00
|
|
|
$resBody = $response->getBody()->getContents();
|
2024-12-12 15:57:43 +05:45
|
|
|
Assert::assertEquals(
|
|
|
|
|
200,
|
|
|
|
|
$response->getStatusCode(),
|
2026-06-22 07:37:21 +00:00
|
|
|
"Failed to start service $service. Response: $resBody",
|
2024-12-12 15:57:43 +05:45
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-11 17:21:52 +05:45
|
|
|
/**
|
|
|
|
|
* @AfterScenario @env-config
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
2025-03-06 17:08:54 +05:45
|
|
|
* @throws GuzzleException
|
|
|
|
|
*/
|
|
|
|
|
public function rollback(): void {
|
2026-06-22 07:37:21 +00:00
|
|
|
if (OcisConfigHelper::isK8s()) {
|
2025-09-24 12:18:59 +05:45
|
|
|
$this->rollbackK8sServices();
|
2025-08-04 14:31:30 +05:45
|
|
|
return;
|
|
|
|
|
}
|
2025-03-06 17:08:54 +05:45
|
|
|
$this->rollbackServices();
|
|
|
|
|
$this->rollbackOcis();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return void
|
|
|
|
|
* @throws GuzzleException
|
2023-05-11 17:21:52 +05:45
|
|
|
*/
|
|
|
|
|
public function rollbackOcis(): void {
|
|
|
|
|
$response = OcisConfigHelper::rollbackOcis();
|
2026-07-15 11:27:47 +05:45
|
|
|
$this->assertOcisRestarted(
|
|
|
|
|
$response,
|
|
|
|
|
"Failed to rollback ocis server. Check if oCIS is started with ociswrapper.",
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Asserts that an oCIS restart triggered by ociswrapper succeeded.
|
|
|
|
|
* In vault mode the wrapper's admin health-check uses basic-auth which is
|
|
|
|
|
* disabled (OIDC role assignment only), so the wrapper always returns HTTP 500
|
|
|
|
|
* even after a successful restart. When Keycloak/vault mode is detected we
|
|
|
|
|
* poll the unauthenticated proxy debug readyz endpoint instead of failing.
|
|
|
|
|
*
|
|
|
|
|
* @param ResponseInterface $response
|
|
|
|
|
* @param string $errorMessage
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
private function assertOcisRestarted(ResponseInterface $response, string $errorMessage): void {
|
|
|
|
|
$statusCode = $response->getStatusCode();
|
|
|
|
|
if ($statusCode === 200) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (KeycloakHelper::isTestingWithKeycloak()) {
|
|
|
|
|
$this->waitForOcisProxyReady();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-05-11 17:21:52 +05:45
|
|
|
Assert::assertEquals(
|
|
|
|
|
200,
|
2026-07-15 11:27:47 +05:45
|
|
|
$statusCode,
|
|
|
|
|
$errorMessage . " Response: " . $response->getBody()->getContents(),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Poll the unauthenticated proxy debug readyz endpoint until oCIS is ready.
|
|
|
|
|
* Used in vault/Keycloak mode where basic-auth health checks are unavailable.
|
|
|
|
|
*
|
|
|
|
|
* @param int $timeoutSeconds
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
* @throws GuzzleException
|
|
|
|
|
*/
|
|
|
|
|
private function waitForOcisProxyReady(int $timeoutSeconds = 60): void {
|
2026-09-10 16:49:07 +05:45
|
|
|
// In k8s, port 9205 on the runner's localhost is unavailable (k3d's loadbalancer
|
|
|
|
|
// reserves that range), so the proxy's debug port is forwarded to a different local
|
|
|
|
|
// port for the lifetime of the job. See k8s.yml's "Expose proxy readyz" step.
|
|
|
|
|
$readyzUrl = getenv('PROXY_READYZ_URL') ?: 'http://localhost:9205/readyz';
|
2026-07-15 11:27:47 +05:45
|
|
|
$deadline = time() + $timeoutSeconds;
|
|
|
|
|
while (time() < $deadline) {
|
|
|
|
|
try {
|
|
|
|
|
$response = HttpRequestHelper::get($readyzUrl);
|
|
|
|
|
if ($response->getStatusCode() === 200) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
echo "oCIS not ready yet. Retrying in 1s...\n";
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw new Exception("oCIS not ready. Error: $e");
|
|
|
|
|
}
|
|
|
|
|
sleep(1);
|
|
|
|
|
}
|
|
|
|
|
throw new \RuntimeException(
|
|
|
|
|
"Timed out after {$timeoutSeconds}s waiting for oCIS proxy readyz at {$readyzUrl}",
|
2023-05-11 17:21:52 +05:45
|
|
|
);
|
|
|
|
|
}
|
2025-03-06 17:08:54 +05:45
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return void
|
|
|
|
|
* @throws GuzzleException
|
|
|
|
|
*/
|
|
|
|
|
public function rollbackServices(): void {
|
|
|
|
|
$response = OcisConfigHelper::rollbackServices();
|
2026-06-22 07:37:21 +00:00
|
|
|
$resBody = $response->getBody()->getContents();
|
2025-03-06 17:08:54 +05:45
|
|
|
Assert::assertEquals(
|
|
|
|
|
200,
|
|
|
|
|
$response->getStatusCode(),
|
2026-06-22 07:37:21 +00:00
|
|
|
"Failed to rollback services. Response: $resBody",
|
2025-03-06 17:08:54 +05:45
|
|
|
);
|
|
|
|
|
}
|
2025-09-24 12:18:59 +05:45
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return void
|
|
|
|
|
* @throws GuzzleException
|
|
|
|
|
*/
|
|
|
|
|
public function rollbackK8sServices(): void {
|
|
|
|
|
$url = OcisConfigHelper::getWrapperUrl() . "/k8s/rollback";
|
|
|
|
|
$response = OcisConfigHelper::sendRequest($url, "DELETE");
|
2026-06-22 07:37:21 +00:00
|
|
|
$resBody = $response->getBody()->getContents();
|
2025-09-24 12:18:59 +05:45
|
|
|
Assert::assertEquals(
|
|
|
|
|
200,
|
|
|
|
|
$response->getStatusCode(),
|
2026-06-22 07:37:21 +00:00
|
|
|
"Failed to rollback services. Response: $resBody",
|
2025-09-24 12:18:59 +05:45
|
|
|
);
|
|
|
|
|
}
|
2023-05-11 17:21:52 +05:45
|
|
|
}
|