Skip to content
Snippets Groups Projects
Commit 23fb6420 authored by Jigish Chauhan's avatar Jigish Chauhan Committed by Yas Naoi
Browse files

Issue #3174363 by jigish.addweb, yas: Add test cases for Refresh buttons of...

Issue #3174363 by jigish.addweb, yas: Add test cases for Refresh buttons of "All" listing view in each K8s resource (6)
parent 400257d4
No related branches found
Tags 3.0.0-alpha2
No related merge requests found
......@@ -16,6 +16,7 @@ class K8sApiServiceTest extends K8sTestBase {
*/
protected function getPermissions(): array {
return [
'view all cloud service providers',
'list k8s api service',
'add k8s api service',
'edit k8s api service',
......@@ -128,4 +129,96 @@ class K8sApiServiceTest extends K8sTestBase {
}
}
/**
* Test updating all API Service list.
*
* @throws \Behat\Mink\Exception\ExpectationException
*/
public function testUpdateAllApiServiceList(): void {
$cloud_configs = [];
// List Api Service for K8s.
$this->drupalGet('/clouds/k8s/api_service');
$this->assertNoErrorMessage();
// Create Cloud Config.
for ($i = 0; $i < self::K8S_API_SERVICE_REPEAT_COUNT; $i++) {
$this->cloudContext = $this->random->name(8);
$cloud_config = $this->createCloudConfigTestEntity($this->cloudContext);
$cloud_configs[] = $cloud_config;
}
foreach ($cloud_configs ?: [] as $cloud_config) {
$cloud_context = $cloud_config->getCloudContext();
// Add a new Api Service.
$add = $this->createApiServiceTestFormData(self::K8S_API_SERVICE_REPEAT_COUNT);
for ($i = 0, $num = 1; $i < self::K8S_API_SERVICE_REPEAT_COUNT; $i++, $num++) {
$this->reloadMockData();
$this->addApiServiceMockData($add[$i]);
$this->drupalPostForm(
"/clouds/k8s/$cloud_context/api_service/add",
$add[$i]['post_data'],
$this->t('Save')
);
$this->assertNoErrorMessage();
$t_args = ['@type' => 'API Service', '%label' => $add[$i]['name']];
$this->assertSession()->pageTextContains(strip_tags($this->t('The @type %label has been created.', $t_args)));
}
}
// List ApiService for K8s.
$this->drupalGet('/clouds/k8s/api_service');
$this->assertNoErrorMessage();
// Make sure listing.
for ($i = 0; $i < self::K8S_API_SERVICE_REPEAT_COUNT; $i++) {
$this->assertSession()->pageTextContains($add[$i]['name']);
}
// Click 'Refresh'.
$this->clickLink($this->t('Refresh'));
foreach ($cloud_configs ?: [] as $cloud_config) {
$this->assertSession()->pageTextContains($this->t('Updated @resources of @cloud_config cloud service provider.', [
'@resources' => 'Api Services',
'@cloud_config' => $cloud_config->getName(),
]));
}
// Edit a Api Service.
foreach ($cloud_configs ?: [] as $cloud_config) {
$edit = $this->createApiServiceTestFormData(self::K8S_API_SERVICE_REPEAT_COUNT);
for ($i = 0, $num = 1; $i < self::K8S_API_SERVICE_REPEAT_COUNT; $i++, $num++) {
$this->updateApiServiceMockData($edit[$i]);
// Change Api Service Name in mock data.
$add[$i]['name'] = "name-{$this->random->name(8, TRUE)}";
}
// Make sure listing.
$this->drupalGet('/clouds/k8s/api_service');
$this->assertNoErrorMessage();
for ($i = 0; $i < self::K8S_API_SERVICE_REPEAT_COUNT; $i++) {
$this->assertSession()->pageTextNotContains($add[$i]['name']);
}
}
// Click 'Refresh'.
$this->clickLink($this->t('Refresh'));
// Confirm Api Services are successfully updated or not.
foreach ($cloud_configs ?: [] as $cloud_config) {
$this->assertSession()->pageTextContains($this->t('Updated @resources of @cloud_config cloud service provider.', [
'@resources' => 'Api Services',
'@cloud_config' => $cloud_config->getName(),
]));
}
// Make sure listing.
$this->drupalGet('/clouds/k8s/api_service');
$this->assertNoErrorMessage();
}
}
......@@ -23,6 +23,7 @@ class K8sDaemonSetTest extends K8sTestBase {
$this->namespace = $namespaces[0]['name'];
return [
'view all cloud service providers',
'list k8s daemon set',
'add k8s daemon set',
'edit k8s daemon set',
......@@ -134,4 +135,87 @@ class K8sDaemonSetTest extends K8sTestBase {
}
}
/**
* Test updating all daemon set list.
*
* @throws \Behat\Mink\Exception\ExpectationException
*/
public function testUpdateAllDaemonSetList(): void {
$cloud_configs = [];
// List Daemon Set for K8s.
$this->drupalGet('/clouds/k8s/daemon_set');
$this->assertNoErrorMessage();
// Create Cloud Config.
for ($i = 0; $i < self::K8S_DAEMON_SET_REPEAT_COUNT; $i++) {
$this->cloudContext = $this->random->name(8);
$cloud_config = $this->createCloudConfigTestEntity($this->cloudContext);
$cloud_configs[] = $cloud_config;
}
foreach ($cloud_configs ?: [] as $cloud_config) {
// Add a new Daemon Set.
$add = $this->createDaemonSetTestFormData(self::K8S_DAEMON_SET_REPEAT_COUNT, $this->namespace);
for ($i = 0, $num = 1; $i < self::K8S_DAEMON_SET_REPEAT_COUNT; $i++, $num++) {
$this->addDaemonSetMockData($add[$i]);
}
}
// List Daemon Set for K8s.
$this->drupalGet('/clouds/k8s/daemon_set');
$this->assertNoErrorMessage();
// Click 'Refresh'.
$this->clickLink($this->t('Refresh'));
foreach ($cloud_configs ?: [] as $cloud_config) {
$this->assertSession()->pageTextContains($this->t('Updated @resources of @cloud_config cloud service provider.', [
'@resources' => 'Daemon Sets',
'@cloud_config' => $cloud_config->getName(),
]));
}
// Make sure listing.
for ($i = 0; $i < self::K8S_DAEMON_SET_REPEAT_COUNT; $i++) {
$this->assertSession()->pageTextContains($add[1]['name']);
}
// Edit a Daemon Set.
foreach ($cloud_configs ?: [] as $cloud_config) {
$edit = $this->createDaemonSetTestFormData(self::K8S_DAEMON_SET_REPEAT_COUNT, $this->namespace);
for ($i = 0, $num = 1; $i < self::K8S_DAEMON_SET_REPEAT_COUNT; $i++, $num++) {
$this->updateDaemonSetMockData($edit[$i]);
// Change Daemon Set Name in mock data.
$add[$i]['name'] = "name-{$this->random->name(8, TRUE)}";
}
// Make sure listing.
$this->drupalGet('/clouds/k8s/daemon_set');
$this->assertNoErrorMessage();
for ($i = 0; $i < self::K8S_DAEMON_SET_REPEAT_COUNT; $i++) {
$this->assertSession()->pageTextNotContains($add[$i]['name']);
}
}
// Click 'Refresh'.
$this->clickLink($this->t('Refresh'));
// Confirm Daemon Sets are successfully updated or not.
foreach ($cloud_configs ?: [] as $cloud_config) {
$this->assertSession()->pageTextContains($this->t('Updated @resources of @cloud_config cloud service provider.', [
'@resources' => 'Daemon Sets',
'@cloud_config' => $cloud_config->getName(),
]));
}
// Make sure listing.
$this->drupalGet('/clouds/k8s/daemon_set');
$this->assertNoErrorMessage();
for ($i = 0; $i < self::K8S_DAEMON_SET_REPEAT_COUNT; $i++) {
$this->assertSession()->pageTextContains($edit[1]['name']);
}
}
}
......@@ -22,6 +22,7 @@ class K8sEndpointTest extends K8sTestBase {
$this->createNamespaceTestEntity($namespaces[0]);
$this->namespace = $namespaces[0]['name'];
return [
'view all cloud service providers',
'list k8s endpoint',
'add k8s endpoint',
'edit k8s endpoint',
......@@ -133,4 +134,87 @@ class K8sEndpointTest extends K8sTestBase {
}
}
/**
* Test updating all endpoint list.
*
* @throws \Behat\Mink\Exception\ExpectationException
*/
public function testUpdateAllEndpointList(): void {
$cloud_configs = [];
// List Endpoint for K8s.
$this->drupalGet('/clouds/k8s/endpoint');
$this->assertNoErrorMessage();
// Create Cloud Config.
for ($i = 0; $i < self::K8S_ENDPOINT_REPEAT_COUNT; $i++) {
$this->cloudContext = $this->random->name(8);
$cloud_config = $this->createCloudConfigTestEntity($this->cloudContext);
$cloud_configs[] = $cloud_config;
}
foreach ($cloud_configs ?: [] as $cloud_config) {
// Add a new Endpoint.
$add = $this->createEndpointTestFormData(self::K8S_ENDPOINT_REPEAT_COUNT, $this->namespace);
for ($i = 0, $num = 1; $i < self::K8S_ENDPOINT_REPEAT_COUNT; $i++, $num++) {
$this->addEndpointMockData($add[$i]);
}
}
// List Endpoint for K8s.
$this->drupalGet('/clouds/k8s/endpoint');
$this->assertNoErrorMessage();
// Click 'Refresh'.
$this->clickLink($this->t('Refresh'));
foreach ($cloud_configs ?: [] as $cloud_config) {
$this->assertSession()->pageTextContains($this->t('Updated @resources of @cloud_config cloud service provider.', [
'@resources' => 'Endpoints',
'@cloud_config' => $cloud_config->getName(),
]));
}
// Make sure listing.
for ($i = 0; $i < self::K8S_ENDPOINT_REPEAT_COUNT; $i++) {
$this->assertSession()->pageTextContains($add[1]['name']);
}
// Edit a Endpoint.
foreach ($cloud_configs ?: [] as $cloud_config) {
$edit = $this->createEndpointTestFormData(self::K8S_ENDPOINT_REPEAT_COUNT, $this->namespace);
for ($i = 0, $num = 1; $i < self::K8S_ENDPOINT_REPEAT_COUNT; $i++, $num++) {
$this->updateEndpointMockData($edit[$i]);
// Change Endpoint Name in mock data.
$add[$i]['name'] = "name-{$this->random->name(8, TRUE)}";
}
// Make sure listing.
$this->drupalGet('/clouds/k8s/endpoint');
$this->assertNoErrorMessage();
for ($i = 0; $i < self::K8S_ENDPOINT_REPEAT_COUNT; $i++) {
$this->assertSession()->pageTextNotContains($add[$i]['name']);
}
}
// Click 'Refresh'.
$this->clickLink($this->t('Refresh'));
// Confirm Endpoints are successfully updated or not.
foreach ($cloud_configs ?: [] as $cloud_config) {
$this->assertSession()->pageTextContains($this->t('Updated @resources of @cloud_config cloud service provider.', [
'@resources' => 'Endpoints',
'@cloud_config' => $cloud_config->getName(),
]));
}
// Make sure listing.
$this->drupalGet('/clouds/k8s/endpoint');
$this->assertNoErrorMessage();
for ($i = 0; $i < self::K8S_ENDPOINT_REPEAT_COUNT; $i++) {
$this->assertSession()->pageTextContains($edit[1]['name']);
}
}
}
......@@ -16,6 +16,7 @@ class K8sEventTest extends K8sTestBase {
*/
protected function getPermissions(): array {
return [
'view all cloud service providers',
'list k8s event',
'view k8s event',
];
......@@ -51,4 +52,85 @@ class K8sEventTest extends K8sTestBase {
}
}
/**
* Test updating all event list.
*
* @throws \Behat\Mink\Exception\ExpectationException
*/
public function testUpdateAllEventList(): void {
$cloud_configs = [];
// List Event for K8s.
$this->drupalGet('/clouds/k8s/event');
$this->assertNoErrorMessage();
// Create Cloud Config.
for ($i = 0; $i < self::K8S_EVENT_REPEAT_COUNT; $i++) {
$this->cloudContext = $this->random->name(8);
$cloud_config = $this->createCloudConfigTestEntity($this->cloudContext);
$cloud_configs[] = $cloud_config;
}
foreach ($cloud_configs ?: [] as $cloud_config) {
// Add a new Event.
$add = $this->createEventTestFormData(self::K8S_EVENT_REPEAT_COUNT);
$this->updateEventsMockData($add);
}
// List Event for K8s.
$this->drupalGet('/clouds/k8s/event');
$this->assertNoErrorMessage();
// Click 'Refresh'.
$this->clickLink($this->t('Refresh'));
foreach ($cloud_configs ?: [] as $cloud_config) {
$this->assertSession()->pageTextContains($this->t('Updated @resources of @cloud_config cloud service provider.', [
'@resources' => 'Events',
'@cloud_config' => $cloud_config->getName(),
]));
}
// Make sure listing.
for ($i = 0; $i < self::K8S_EVENT_REPEAT_COUNT; $i++) {
$this->assertSession()->pageTextContains($add[$i]['name']);
}
// Edit a Event.
foreach ($cloud_configs ?: [] as $cloud_config) {
$edit = $this->createEventTestFormData(self::K8S_EVENT_REPEAT_COUNT);
for ($i = 0, $num = 1; $i < self::K8S_EVENT_REPEAT_COUNT; $i++, $num++) {
$this->updateEventsMockData($edit);
// Change Event Name in mock data.
$add[$i]['name'] = "name-{$this->random->name(8, TRUE)}";
}
// Make sure listing.
$this->drupalGet('/clouds/k8s/event');
$this->assertNoErrorMessage();
for ($i = 0; $i < self::K8S_EVENT_REPEAT_COUNT; $i++) {
$this->assertSession()->pageTextNotContains($add[$i]['name']);
}
}
// Click 'Refresh'.
$this->clickLink($this->t('Refresh'));
// Confirm Events are successfully updated or not.
foreach ($cloud_configs ?: [] as $cloud_config) {
$this->assertSession()->pageTextContains($this->t('Updated @resources of @cloud_config cloud service provider.', [
'@resources' => 'Events',
'@cloud_config' => $cloud_config->getName(),
]));
}
// Make sure listing.
$this->drupalGet('/clouds/k8s/event');
$this->assertNoErrorMessage();
for ($i = 0; $i < self::K8S_EVENT_REPEAT_COUNT; $i++) {
$this->assertSession()->pageTextContains($edit[$i]['name']);
}
}
}
......@@ -23,6 +23,7 @@ class K8sIngressTest extends K8sTestBase {
$this->namespace = $namespaces[0]['name'];
return [
'view all cloud service providers',
'list k8s ingress',
'add k8s ingress',
'edit k8s ingress',
......@@ -134,4 +135,87 @@ class K8sIngressTest extends K8sTestBase {
}
}
/**
* Test updating all ingress list.
*
* @throws \Behat\Mink\Exception\ExpectationException
*/
public function testUpdateAllIngressList(): void {
$cloud_configs = [];
// List Ingress for K8s.
$this->drupalGet('/clouds/k8s/ingress');
$this->assertNoErrorMessage();
// Create Cloud Config.
for ($i = 0; $i < self::K8S_INGRESS_REPEAT_COUNT; $i++) {
$this->cloudContext = $this->random->name(8);
$cloud_config = $this->createCloudConfigTestEntity($this->cloudContext);
$cloud_configs[] = $cloud_config;
}
foreach ($cloud_configs ?: [] as $cloud_config) {
// Add a new Ingress.
$add = $this->createIngressTestFormData(self::K8S_INGRESS_REPEAT_COUNT, $this->namespace);
for ($i = 0, $num = 1; $i < self::K8S_INGRESS_REPEAT_COUNT; $i++, $num++) {
$this->addIngressMockData($add[$i]);
}
}
// List Ingress for K8s.
$this->drupalGet('/clouds/k8s/ingress');
$this->assertNoErrorMessage();
// Click 'Refresh'.
$this->clickLink($this->t('Refresh'));
foreach ($cloud_configs ?: [] as $cloud_config) {
$this->assertSession()->pageTextContains($this->t('Updated @resources of @cloud_config cloud service provider.', [
'@resources' => 'Ingresses',
'@cloud_config' => $cloud_config->getName(),
]));
}
// Make sure listing.
for ($i = 0; $i < self::K8S_INGRESS_REPEAT_COUNT; $i++) {
$this->assertSession()->pageTextContains($add[1]['name']);
}
// Edit a Ingress.
foreach ($cloud_configs ?: [] as $cloud_config) {
$edit = $this->createIngressTestFormData(self::K8S_INGRESS_REPEAT_COUNT, $this->namespace);
for ($i = 0, $num = 1; $i < self::K8S_INGRESS_REPEAT_COUNT; $i++, $num++) {
$this->updateIngressMockData($edit[$i]);
// Change Ingress Name in mock data.
$add[$i]['name'] = "name-{$this->random->name(8, TRUE)}";
}
// Make sure listing.
$this->drupalGet('/clouds/k8s/ingress');
$this->assertNoErrorMessage();
for ($i = 0; $i < self::K8S_INGRESS_REPEAT_COUNT; $i++) {
$this->assertSession()->pageTextNotContains($add[$i]['name']);
}
}
// Click 'Refresh'.
$this->clickLink($this->t('Refresh'));
// Confirm Ingresss are successfully updated or not.
foreach ($cloud_configs ?: [] as $cloud_config) {
$this->assertSession()->pageTextContains($this->t('Updated @resources of @cloud_config cloud service provider.', [
'@resources' => 'Ingresses',
'@cloud_config' => $cloud_config->getName(),
]));
}
// Make sure listing.
$this->drupalGet('/clouds/k8s/ingress');
$this->assertNoErrorMessage();
for ($i = 0; $i < self::K8S_INGRESS_REPEAT_COUNT; $i++) {
$this->assertSession()->pageTextContains($edit[1]['name']);
}
}
}
......@@ -23,6 +23,7 @@ class K8sServiceAccountTest extends K8sTestBase {
$this->namespace = $namespaces[0]['name'];
return [
'view all cloud service providers',
'list k8s service account',
'add k8s service account',
'edit k8s service account',
......@@ -135,4 +136,87 @@ class K8sServiceAccountTest extends K8sTestBase {
}
}
/**
* Test updating all Service Account list.
*
* @throws \Behat\Mink\Exception\ExpectationException
*/
public function testUpdateAllServiceAccountList(): void {
$cloud_configs = [];
// List Service Account for K8s.
$this->drupalGet('/clouds/k8s/service_account');
$this->assertNoErrorMessage();
// Create Cloud Config.
for ($i = 0; $i < self::K8S_SERVICE_ACCOUNT_REPEAT_COUNT; $i++) {
$this->cloudContext = $this->random->name(8);
$cloud_config = $this->createCloudConfigTestEntity($this->cloudContext);
$cloud_configs[] = $cloud_config;
}
foreach ($cloud_configs ?: [] as $cloud_config) {
// Add a new Service Account.
$add = $this->createServiceAccountTestFormData(self::K8S_SERVICE_ACCOUNT_REPEAT_COUNT, $this->namespace);
for ($i = 0, $num = 1; $i < self::K8S_SERVICE_ACCOUNT_REPEAT_COUNT; $i++, $num++) {
$this->addServiceAccountMockData($add[$i]);
}
}
// List Service Account for K8s.
$this->drupalGet('/clouds/k8s/service_account');
$this->assertNoErrorMessage();
// Click 'Refresh'.
$this->clickLink($this->t('Refresh'));
foreach ($cloud_configs ?: [] as $cloud_config) {
$this->assertSession()->pageTextContains($this->t('Updated @resources of @cloud_config cloud service provider.', [
'@resources' => 'Service Accounts',
'@cloud_config' => $cloud_config->getName(),
]));
}
// Make sure listing.
for ($i = 0; $i < self::K8S_SERVICE_ACCOUNT_REPEAT_COUNT; $i++) {
$this->assertSession()->pageTextContains($add[2]['name']);
}
// Edit a Service Account.
foreach ($cloud_configs ?: [] as $cloud_config) {
$edit = $this->createServiceAccountTestFormData(self::K8S_SERVICE_ACCOUNT_REPEAT_COUNT, $this->namespace);
for ($i = 0, $num = 1; $i < self::K8S_SERVICE_ACCOUNT_REPEAT_COUNT; $i++, $num++) {
$this->updateServiceAccountMockData($edit[$i]);
// Change Service Account Name in mock data.
$add[$i]['name'] = "name-{$this->random->name(8, TRUE)}";
}
// Make sure listing.
$this->drupalGet('/clouds/k8s/service_account');
$this->assertNoErrorMessage();
for ($i = 0; $i < self::K8S_SERVICE_ACCOUNT_REPEAT_COUNT; $i++) {
$this->assertSession()->pageTextNotContains($add[$i]['name']);
}
}
// Click 'Refresh'.
$this->clickLink($this->t('Refresh'));
// Confirm Service Accounts are successfully updated or not.
foreach ($cloud_configs ?: [] as $cloud_config) {
$this->assertSession()->pageTextContains($this->t('Updated @resources of @cloud_config cloud service provider.', [
'@resources' => 'Service Accounts',
'@cloud_config' => $cloud_config->getName(),
]));
}
// Make sure listing.
$this->drupalGet('/clouds/k8s/service_account');
$this->assertNoErrorMessage();
for ($i = 0; $i < self::K8S_SERVICE_ACCOUNT_REPEAT_COUNT; $i++) {
$this->assertSession()->pageTextContains($edit[2]['name']);
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment