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

Issue #3172945 by jigish.addweb, yas: [K8s] As a developer, add test cases for...

Issue #3172945 by jigish.addweb, yas: [K8s] As a developer, add test cases for Refresh buttons of "All" listing view in each K8s resource (4)
parent 5cebf6b8
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,7 @@ class K8sClusterRoleTest extends K8sTestBase {
*/
protected function getPermissions(): array {
return [
'view all cloud service providers',
'list k8s cluster role',
'view k8s cluster role',
'edit k8s cluster role',
......@@ -126,4 +127,87 @@ class K8sClusterRoleTest extends K8sTestBase {
}
}
/**
* Test updating all cluster role list.
*
* @throws \Behat\Mink\Exception\ExpectationException
*/
public function testUpdateAllClusterRoleList(): void {
$cloud_configs = [];
// List Cluster Role for K8s.
$this->drupalGet('/clouds/k8s/cluster_role');
$this->assertNoErrorMessage();
// Create Cloud Config.
for ($i = 0; $i < self::K8S_CLUSTER_ROLE_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 Cluster Role.
$add = $this->createClusterRoleTestFormData(self::K8S_CLUSTER_ROLE_REPEAT_COUNT);
for ($i = 0, $num = 1; $i < self::K8S_CLUSTER_ROLE_REPEAT_COUNT; $i++, $num++) {
$this->addClusterRoleMockData($add[$i]);
}
}
// List Cluster Role for K8s.
$this->drupalGet('/clouds/k8s/cluster_role');
$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' => 'Cluster Roles',
'@cloud_config' => $cloud_config->getName(),
]));
}
// Make sure listing.
for ($i = 0; $i < self::K8S_CLUSTER_ROLE_REPEAT_COUNT; $i++) {
$this->assertSession()->pageTextContains($add[1]['name']);
}
// Edit a Cluster Role.
foreach ($cloud_configs ?: [] as $cloud_config) {
$edit = $this->createClusterRoleTestFormData(self::K8S_CLUSTER_ROLE_REPEAT_COUNT);
for ($i = 0, $num = 1; $i < self::K8S_CLUSTER_ROLE_REPEAT_COUNT; $i++, $num++) {
$this->updateClusterRoleMockData($edit[$i]);
// Change Cluster Role Name in mock data.
$add[$i]['name'] = "name-{$this->random->name(8, TRUE)}";
}
// Make sure listing.
$this->drupalGet('/clouds/k8s/cluster_role');
$this->assertNoErrorMessage();
for ($i = 0; $i < self::K8S_CLUSTER_ROLE_REPEAT_COUNT; $i++) {
$this->assertSession()->pageTextNotContains($add[$i]['name']);
}
}
// Click 'Refresh'.
$this->clickLink($this->t('Refresh'));
// Confirm Cluster Roles 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' => 'Cluster Roles',
'@cloud_config' => $cloud_config->getName(),
]));
}
// Make sure listing.
$this->drupalGet('/clouds/k8s/cluster_role');
$this->assertNoErrorMessage();
for ($i = 0; $i < self::K8S_CLUSTER_ROLE_REPEAT_COUNT; $i++) {
$this->assertSession()->pageTextContains($edit[1]['name']);
}
}
}
......@@ -23,6 +23,7 @@ class K8sConfigMapTest extends K8sTestBase {
$this->namespace = $namespaces[0]['name'];
return [
'view all cloud service providers',
'list k8s configmap',
'view k8s configmap',
'edit k8s configmap',
......@@ -134,4 +135,87 @@ class K8sConfigMapTest extends K8sTestBase {
}
}
/**
* Test updating all Config Map list.
*
* @throws \Behat\Mink\Exception\ExpectationException
*/
public function testUpdateAllConfigMapList(): void {
$cloud_configs = [];
// List Config Map for K8s.
$this->drupalGet('/clouds/k8s/config_map');
$this->assertNoErrorMessage();
// Create Cloud Config.
for ($i = 0; $i < self::K8S_CONFIG_MAP_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 Config Map.
$add = $this->createConfigMapTestFormData(self::K8S_CONFIG_MAP_REPEAT_COUNT, $this->namespace);
for ($i = 0, $num = 1; $i < self::K8S_CONFIG_MAP_REPEAT_COUNT; $i++, $num++) {
$this->addConfigMapMockData($add[$i]);
}
}
// List Config Map for K8s.
$this->drupalGet('/clouds/k8s/config_map');
$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' => 'ConfigMaps',
'@cloud_config' => $cloud_config->getName(),
]));
}
// Make sure listing.
for ($i = 0; $i < self::K8S_CONFIG_MAP_REPEAT_COUNT; $i++) {
$this->assertSession()->pageTextContains($add[1]['name']);
}
// Edit a Config Map.
foreach ($cloud_configs ?: [] as $cloud_config) {
$edit = $this->createConfigMapTestFormData(self::K8S_CONFIG_MAP_REPEAT_COUNT, $this->namespace);
for ($i = 0, $num = 1; $i < self::K8S_CONFIG_MAP_REPEAT_COUNT; $i++, $num++) {
$this->updateConfigMapMockData($edit[$i]);
// Change Config Map Name in mock data.
$add[$i]['name'] = "name-{$this->random->name(8, TRUE)}";
}
// Make sure listing.
$this->drupalGet('/clouds/k8s/config_map');
$this->assertNoErrorMessage();
for ($i = 0; $i < self::K8S_CONFIG_MAP_REPEAT_COUNT; $i++) {
$this->assertSession()->pageTextNotContains($add[$i]['name']);
}
}
// Click 'Refresh'.
$this->clickLink($this->t('Refresh'));
// Confirm Config Maps 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' => 'ConfigMaps',
'@cloud_config' => $cloud_config->getName(),
]));
}
// Make sure listing.
$this->drupalGet('/clouds/k8s/config_map');
$this->assertNoErrorMessage();
for ($i = 0; $i < self::K8S_CONFIG_MAP_REPEAT_COUNT; $i++) {
$this->assertSession()->pageTextContains($edit[1]['name']);
}
}
}
......@@ -23,6 +23,7 @@ class K8sRoleBindingTest extends K8sTestBase {
$this->namespace = $namespaces[0]['name'];
return [
'view all cloud service providers',
'list k8s role binding',
'edit k8s role binding',
'add k8s role binding',
......@@ -133,4 +134,87 @@ class K8sRoleBindingTest extends K8sTestBase {
}
}
/**
* Test updating all Role Binding list.
*
* @throws \Behat\Mink\Exception\ExpectationException
*/
public function testUpdateAllRoleBindingList(): void {
$cloud_configs = [];
// List Role Binding for K8s.
$this->drupalGet('/clouds/k8s/role_binding');
$this->assertNoErrorMessage();
// Create Cloud Config.
for ($i = 0; $i < self::K8S_ROLE_BINDING_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 Role Binding.
$add = $this->createRoleBindingTestFormData(self::K8S_ROLE_BINDING_REPEAT_COUNT, $this->namespace);
for ($i = 0, $num = 1; $i < self::K8S_ROLE_BINDING_REPEAT_COUNT; $i++, $num++) {
$this->addRoleBindingMockData($add[$i]);
}
}
// List Role Binding for K8s.
$this->drupalGet('/clouds/k8s/role_binding');
$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' => 'Role Bindings',
'@cloud_config' => $cloud_config->getName(),
]));
}
// Make sure listing.
for ($i = 0; $i < self::K8S_ROLE_BINDING_REPEAT_COUNT; $i++) {
$this->assertSession()->pageTextContains($add[1]['name']);
}
// Edit a Role Binding.
foreach ($cloud_configs ?: [] as $cloud_config) {
$edit = $this->createRoleBindingTestFormData(self::K8S_ROLE_BINDING_REPEAT_COUNT, $this->namespace);
for ($i = 0, $num = 1; $i < self::K8S_ROLE_BINDING_REPEAT_COUNT; $i++, $num++) {
$this->updateRoleBindingMockData($edit[$i]);
// Change Role Binding Name in mock data.
$add[$i]['name'] = "name-{$this->random->name(8, TRUE)}";
}
// Make sure listing.
$this->drupalGet('/clouds/k8s/role_binding');
$this->assertNoErrorMessage();
for ($i = 0; $i < self::K8S_ROLE_BINDING_REPEAT_COUNT; $i++) {
$this->assertSession()->pageTextNotContains($add[$i]['name']);
}
}
// Click 'Refresh'.
$this->clickLink($this->t('Refresh'));
// Confirm Role Bindings 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' => 'Role Bindings',
'@cloud_config' => $cloud_config->getName(),
]));
}
// Make sure listing.
$this->drupalGet('/clouds/k8s/role_binding');
$this->assertNoErrorMessage();
for ($i = 0; $i < self::K8S_ROLE_BINDING_REPEAT_COUNT; $i++) {
$this->assertSession()->pageTextContains($edit[1]['name']);
}
}
}
......@@ -22,6 +22,7 @@ class K8sRoleTest extends K8sTestBase {
$this->namespace = $namespaces[0]['name'];
return [
'view all cloud service providers',
'list k8s role',
'view k8s role',
'edit k8s role',
......@@ -133,4 +134,87 @@ class K8sRoleTest extends K8sTestBase {
}
}
/**
* Test updating all role list.
*
* @throws \Behat\Mink\Exception\ExpectationException
*/
public function testUpdateAllRoleList(): void {
$cloud_configs = [];
// List Role for K8s.
$this->drupalGet('/clouds/k8s/role');
$this->assertNoErrorMessage();
// Create Cloud Config.
for ($i = 0; $i < self::K8S_ROLE_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 Role.
$add = $this->createRoleTestFormData(self::K8S_ROLE_REPEAT_COUNT, $this->namespace);
for ($i = 0, $num = 1; $i < self::K8S_ROLE_REPEAT_COUNT; $i++, $num++) {
$this->addRoleMockData($add[$i]);
}
}
// List Role for K8s.
$this->drupalGet('/clouds/k8s/role');
$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' => 'Roles',
'@cloud_config' => $cloud_config->getName(),
]));
}
// Make sure listing.
for ($i = 0; $i < self::K8S_ROLE_REPEAT_COUNT; $i++) {
$this->assertSession()->pageTextContains($add[1]['name']);
}
// Edit a Role.
foreach ($cloud_configs ?: [] as $cloud_config) {
$edit = $this->createRoleTestFormData(self::K8S_ROLE_REPEAT_COUNT, $this->namespace);
for ($i = 0, $num = 1; $i < self::K8S_ROLE_REPEAT_COUNT; $i++, $num++) {
$this->updateRoleMockData($edit[$i]);
// Change Role Name in mock data.
$add[$i]['name'] = "name-{$this->random->name(8, TRUE)}";
}
// Make sure listing.
$this->drupalGet('/clouds/k8s/role');
$this->assertNoErrorMessage();
for ($i = 0; $i < self::K8S_ROLE_REPEAT_COUNT; $i++) {
$this->assertSession()->pageTextNotContains($add[$i]['name']);
}
}
// Click 'Refresh'.
$this->clickLink($this->t('Refresh'));
// Confirm Roles 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' => 'Roles',
'@cloud_config' => $cloud_config->getName(),
]));
}
// Make sure listing.
$this->drupalGet('/clouds/k8s/role');
$this->assertNoErrorMessage();
for ($i = 0; $i < self::K8S_ROLE_REPEAT_COUNT; $i++) {
$this->assertSession()->pageTextContains($edit[1]['name']);
}
}
}
......@@ -23,6 +23,7 @@ class K8sSecretTest extends K8sTestBase {
$this->namespace = $namespaces[0]['name'];
return [
'view all cloud service providers',
'list k8s secret',
'view k8s secret',
'edit k8s secret',
......@@ -134,4 +135,87 @@ class K8sSecretTest extends K8sTestBase {
}
}
/**
* Test updating all Secret list.
*
* @throws \Behat\Mink\Exception\ExpectationException
*/
public function testUpdateAllSecretList(): void {
$cloud_configs = [];
// List Secret for K8s.
$this->drupalGet('/clouds/k8s/secret');
$this->assertNoErrorMessage();
// Create Cloud Config.
for ($i = 0; $i < self::K8S_SECRET_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 Secret.
$add = $this->createSecretTestFormData(self::K8S_SECRET_REPEAT_COUNT, $this->namespace);
for ($i = 0, $num = 1; $i < self::K8S_SECRET_REPEAT_COUNT; $i++, $num++) {
$this->addSecretMockData($add[$i]);
}
}
// List Secret for K8s.
$this->drupalGet('/clouds/k8s/secret');
$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' => 'Secrets',
'@cloud_config' => $cloud_config->getName(),
]));
}
// Make sure listing.
for ($i = 0; $i < self::K8S_SECRET_REPEAT_COUNT; $i++) {
$this->assertSession()->pageTextContains($add[1]['name']);
}
// Edit a Secret.
foreach ($cloud_configs ?: [] as $cloud_config) {
$edit = $this->createSecretTestFormData(self::K8S_SECRET_REPEAT_COUNT, $this->namespace);
for ($i = 0, $num = 1; $i < self::K8S_SECRET_REPEAT_COUNT; $i++, $num++) {
$this->updateSecretMockData($edit[$i]);
// Change Secret Name in mock data.
$add[$i]['name'] = "name-{$this->random->name(8, TRUE)}";
}
// Make sure listing.
$this->drupalGet('/clouds/k8s/secret');
$this->assertNoErrorMessage();
for ($i = 0; $i < self::K8S_SECRET_REPEAT_COUNT; $i++) {
$this->assertSession()->pageTextNotContains($add[$i]['name']);
}
}
// Click 'Refresh'.
$this->clickLink($this->t('Refresh'));
// Confirm Secrets 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' => 'Secrets',
'@cloud_config' => $cloud_config->getName(),
]));
}
// Make sure listing.
$this->drupalGet('/clouds/k8s/secret');
$this->assertNoErrorMessage();
for ($i = 0; $i < self::K8S_SECRET_REPEAT_COUNT; $i++) {
$this->assertSession()->pageTextContains($edit[1]['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