Skip to content

Commit 805d4a7

Browse files
authored
Merge pull request #936 from RedisInsight/e2e/regression-web-fixes
e2e fixes for web tests
2 parents 1296b2e + 58f9859 commit 805d4a7

File tree

5 files changed

+181
-144
lines changed

5 files changed

+181
-144
lines changed

tests/e2e/helpers/api/api-database.ts

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { t } from 'testcafe';
22
import * as request from 'supertest';
33
import { asyncFilter, doAsyncStuff } from '../async-helper';
4-
import { AddNewDatabaseParameters, OSSClusterParameters, databaseParameters } from '../../pageObjects/add-redis-database-page';
4+
import { AddNewDatabaseParameters, OSSClusterParameters, databaseParameters, SentinelParameters } from '../../pageObjects/add-redis-database-page';
55
import { apiUrl } from '../../helpers/conf';
66

77
const endpoint = apiUrl;
@@ -39,7 +39,7 @@ export async function addNewStandaloneDatabasesApi(databasesParameters: AddNewDa
3939
}
4040

4141
/**
42-
* Adda new database from OSS Cluster through api using host and port
42+
* Add a new database from OSS Cluster through api using host and port
4343
* @param databaseParameters The database parameters
4444
*/
4545
export async function addNewOSSClusterDatabaseApi(databaseParameters: OSSClusterParameters): Promise<void> {
@@ -51,6 +51,23 @@ export async function addNewOSSClusterDatabaseApi(databaseParameters: OSSCluster
5151
await t.expect(await response.body.name).eql(databaseParameters.ossClusterDatabaseName, `Database Name is not equal to ${databaseParameters.ossClusterDatabaseName} in response`);
5252
}
5353

54+
/**
55+
* Add a Sentinel database via autodiscover through api
56+
* @param databaseParameters The database parameters
57+
*/
58+
export async function discoverSentinelDatabaseApi(databaseParameters: SentinelParameters): Promise<void> {
59+
const response = await request(endpoint).post('/instance/sentinel-masters')
60+
.send({
61+
'host': databaseParameters.sentinelHost,
62+
'port': databaseParameters.sentinelPort,
63+
'password': databaseParameters.sentinelPassword,
64+
'masters': databaseParameters.masters
65+
})
66+
.set('Accept', 'application/json');
67+
68+
await t.expect(response.status).eql(201, 'The autodiscover of Sentinel database request failed');
69+
}
70+
5471
/**
5572
* Get all databases through api
5673
*/
@@ -102,6 +119,18 @@ export async function deleteOSSClusterDatabaseApi(databaseParameters: OSSCluster
102119
await t.expect(response.status).eql(200, 'Delete OSS cluster database request failed');
103120
}
104121

122+
/**
123+
* Delete a Sentinel database through api
124+
* @param databaseParameters The database parameters
125+
*/
126+
export async function deleteSentinelDatabaseApi(databaseParameters: SentinelParameters): Promise<void> {
127+
const databaseId = await getDatabaseByName(databaseParameters.name);
128+
const response = await request(endpoint).delete('/instance')
129+
.send({ 'ids': [`${databaseId}`] }).set('Accept', 'application/json');
130+
131+
await t.expect(response.status).eql(200, 'Delete Sentinel database request failed');
132+
}
133+
105134
/**
106135
* Delete Standalone databases through api
107136
* @param databasesParameters The databases parameters as array

tests/e2e/helpers/conf.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,18 @@ export const ossClusterConfig = {
4040
export const ossSentinelConfig = {
4141
sentinelHost: process.env.OSS_SENTINEL_HOST || 'oss-sentinel',
4242
sentinelPort: process.env.OSS_SENTINEL_PORT || '26379',
43-
sentinelPassword: process.env.OSS_SENTINEL_PASSWORD || 'password'
43+
sentinelPassword: process.env.OSS_SENTINEL_PASSWORD || 'password',
44+
masters: [{
45+
alias: "primary-group-1",
46+
db: "0",
47+
name: "primary-group-1"
48+
},
49+
{
50+
alias: "primary-group-2",
51+
db: "0",
52+
name: "primary-group-2"
53+
}],
54+
name: "primary-group-2"
4455
};
4556

4657
export const redisEnterpriseClusterConfig = {

tests/e2e/pageObjects/add-redis-database-page.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,9 @@ export type AddNewDatabaseParameters = {
177177
export type SentinelParameters = {
178178
sentinelHost: string,
179179
sentinelPort: string,
180-
sentinelPassword?: string
180+
masters?: object[],
181+
sentinelPassword?: string,
182+
name?: string
181183
};
182184

183185
/**

tests/e2e/tests/regression/database/database-list-search.e2e.ts

Lines changed: 72 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ import { t } from 'testcafe';
22
import { acceptLicenseTerms } from '../../../helpers/database';
33
import {
44
addNewStandaloneDatabasesApi,
5-
addNewOSSClusterDatabaseApi,
65
deleteStandaloneDatabasesApi,
6+
discoverSentinelDatabaseApi,
7+
deleteSentinelDatabaseApi,
8+
addNewOSSClusterDatabaseApi,
79
deleteOSSClusterDatabaseApi
810
} from '../../../helpers/api/api-database';
911
import { MyRedisDatabasePage } from '../../../pageObjects';
1012
import { rte } from '../../../helpers/constants';
11-
import { commonUrl, ossStandaloneConfig, ossStandaloneV5Config, ossClusterConfig } from '../../../helpers/conf';
13+
import { commonUrl, ossStandaloneConfig, ossStandaloneV5Config, ossSentinelConfig, ossClusterConfig } from '../../../helpers/conf';
1214

1315
const myRedisDatabasePage = new MyRedisDatabasePage();
1416
const databasesForSearch = [
@@ -25,86 +27,83 @@ const databasesForAdding = [
2527
];
2628

2729
fixture `Database list search`
28-
.meta({ type: 'regression' })
30+
.meta({ type: 'regression', rte: rte.standalone })
2931
.page(commonUrl)
30-
.beforeEach(async() => {
32+
.beforeEach(async () => {
3133
// Add new databases using API
3234
await acceptLicenseTerms();
3335
await addNewStandaloneDatabasesApi(databasesForAdding);
3436
await addNewOSSClusterDatabaseApi(ossClusterConfig);
37+
await discoverSentinelDatabaseApi(ossSentinelConfig);
3538
// Reload Page
3639
await t.eval(() => location.reload());
3740
})
38-
.afterEach(async() => {
41+
.afterEach(async () => {
3942
//Clear and delete databases
4043
await deleteStandaloneDatabasesApi(databasesForAdding);
4144
await deleteOSSClusterDatabaseApi(ossClusterConfig);
45+
await deleteSentinelDatabaseApi(ossSentinelConfig);
4246
});
43-
test
44-
.meta({ rte: rte.standalone })('Verify that user can search DB by database name on the List of databases', async t => {
45-
//Search for DB by name
46-
const searchedDBName = 'Search';
47-
await t.typeText(myRedisDatabasePage.searchInput, searchedDBName, { replace: true });
48-
//Verify that database found on the list search by name
49-
await t.expect(myRedisDatabasePage.dbNameList.withExactText(databasesForSearch[0].databaseName).exists).ok('The database with alias is found', { timeout: 10000 });
50-
await t.expect(myRedisDatabasePage.dbNameList.withExactText(databasesForSearch[1].databaseName).exists).ok('The database with alias is found', { timeout: 10000 });
51-
await t.expect(myRedisDatabasePage.dbNameList.withExactText(databasesForSearch[2].databaseName).exists).notOk('The database with other alias is not found', { timeout: 10000 });
52-
});
53-
test
54-
.meta({ rte: rte.standalone })('Verify that user can search DB by host on the List of databases', async t => {
55-
//Search for DB by host
56-
const searchedDBHost = ossStandaloneConfig.host;
57-
await t.typeText(myRedisDatabasePage.searchInput, searchedDBHost, { replace: true });
58-
//Verify that database found on the list search by host
59-
await t.expect(myRedisDatabasePage.dbNameList.withExactText(databasesForSearch[0].databaseName).exists).ok('The database with host is found', { timeout: 10000 });
60-
await t.expect(myRedisDatabasePage.dbNameList.withExactText(databasesForSearch[1].databaseName).exists).ok('The database with host is found', { timeout: 10000 });
61-
await t.expect(myRedisDatabasePage.dbNameList.withExactText(ossClusterConfig.ossClusterDatabaseName).exists).notOk('The database with other host is not found', { timeout: 10000 });
62-
});
63-
test
64-
.meta({ rte: rte.standalone })('Verify that user can search DB by port on the List of databases', async t => {
65-
//Search for DB by port
66-
const searchedDBPort = ossStandaloneConfig.port;
67-
await t.typeText(myRedisDatabasePage.searchInput, searchedDBPort, { replace: true });
68-
//Verify that database found on the list search by port
69-
await t.expect(myRedisDatabasePage.dbNameList.withExactText(databasesForSearch[0].databaseName).exists).ok('The database with port is found', { timeout: 10000 });
70-
await t.expect(myRedisDatabasePage.dbNameList.withExactText(databasesForSearch[1].databaseName).exists).ok('The database with port is found', { timeout: 10000 });
71-
await t.expect(myRedisDatabasePage.dbNameList.withExactText(ossClusterConfig.ossClusterDatabaseName).exists).notOk('The database with other port is not found', { timeout: 10000 });
72-
});
73-
test
74-
.meta({ rte: rte.standalone })('Verify that user can search DB by Connection Type on the List of databases', async t => {
75-
//Search for DB by connection type
76-
const searchedDBConType = 'Standalone';
77-
await t.typeText(myRedisDatabasePage.searchInput, searchedDBConType, { replace: true });
78-
//Verify that database found on the list search by connection type
79-
await t.expect(myRedisDatabasePage.dbNameList.withExactText(databasesForSearch[0].databaseName).exists).ok('The database with connection type is found', { timeout: 10000 });
80-
await t.expect(myRedisDatabasePage.dbNameList.withExactText(databasesForSearch[1].databaseName).exists).ok('The database with connection type is found', { timeout: 10000 });
81-
await t.expect(myRedisDatabasePage.dbNameList.withExactText(ossClusterConfig.ossClusterDatabaseName).exists).notOk('The database with other connection type is not found', { timeout: 10000 });
82-
});
83-
test
84-
.meta({ rte: rte.standalone })('Verify that user can search DB by Last Connection on the List of databases', async t => {
85-
const searchedDBFirst = 'less than a minute ago';
86-
const searchedDBSecond = '1 minute ago';
87-
const searchTimeout = 60 * 1000; // 60 sec to wait for changing Last Connection time
88-
const dbSelector = myRedisDatabasePage.dbNameList.withExactText(databasesForSearch[2].databaseName);
89-
const startTime = Date.now();
90-
//Search for DB by Last Connection
91-
await t.typeText(myRedisDatabasePage.searchInput, searchedDBFirst, { replace: true });
92-
//Verify that database added < 1min ago found on the list search by Last Connection
93-
await t.expect(myRedisDatabasePage.dbNameList.withExactText(databasesForSearch[1].databaseName).exists).ok('The database with Last Connection is found', { timeout: 10000 });
94-
//Verify that database added > 1min ago found on the list search by Last Connection
95-
do {
96-
await t.eval(() => location.reload());
97-
await t.typeText(myRedisDatabasePage.searchInput, searchedDBSecond, { replace: true });
98-
}
99-
while (!(await dbSelector.exists) && Date.now() - startTime < searchTimeout);
100-
await t.expect(dbSelector.exists).ok('The database with Last Connection is found', { timeout: 10000 });
101-
});
102-
test
103-
.meta({ rte: rte.standalone })('Verify that user sees "No results found" message when pattern doesn`t match any database', async t => {
104-
//Search for DB by Invalid search
105-
const searchedDBHost = 'invalid';
106-
await t.typeText(myRedisDatabasePage.searchInput, searchedDBHost, { replace: true });
107-
//Verify that "No results found" message is displayed in case of invalid search
108-
await t.expect(myRedisDatabasePage.noResultsFoundMessage.exists).ok('"No results found message" not displayed');
109-
await t.expect(myRedisDatabasePage.noResultsFoundText.exists).ok('"No databases matched your search" message not displayed');
110-
});
47+
test('Verify that user can search DB by database name on the List of databases', async t => {
48+
//Search for DB by name
49+
const searchedDBName = 'Search';
50+
await t.typeText(myRedisDatabasePage.searchInput, searchedDBName, { replace: true });
51+
//Verify that database found on the list search by name
52+
await t.expect(myRedisDatabasePage.dbNameList.withExactText(databasesForSearch[0].databaseName).exists).ok('The database with alias not found', { timeout: 10000 });
53+
await t.expect(myRedisDatabasePage.dbNameList.withExactText(databasesForSearch[1].databaseName).exists).ok('The database with alias not found', { timeout: 10000 });
54+
await t.expect(myRedisDatabasePage.dbNameList.withExactText(databasesForSearch[2].databaseName).exists).notOk('The database with other alias is found', { timeout: 10000 });
55+
});
56+
test('Verify that user can search DB by host on the List of databases', async t => {
57+
//Search for DB by host
58+
const searchedDBHost = ossStandaloneConfig.host;
59+
await t.typeText(myRedisDatabasePage.searchInput, searchedDBHost, { replace: true });
60+
//Verify that database found on the list search by host
61+
await t.expect(myRedisDatabasePage.dbNameList.withExactText(databasesForSearch[0].databaseName).exists).ok('The database with host not found', { timeout: 10000 });
62+
await t.expect(myRedisDatabasePage.dbNameList.withExactText(databasesForSearch[1].databaseName).exists).ok('The database with host not found', { timeout: 10000 });
63+
await t.expect(myRedisDatabasePage.dbNameList.withExactText(ossSentinelConfig.name).exists).notOk('The database with other host is found', { timeout: 10000 });
64+
});
65+
test('Verify that user can search DB by port on the List of databases', async t => {
66+
//Search for DB by port
67+
const searchedDBPort = ossSentinelConfig.sentinelPort;
68+
await t.typeText(myRedisDatabasePage.searchInput, searchedDBPort, { replace: true });
69+
//Verify that database found on the list search by port
70+
await t.expect(myRedisDatabasePage.dbNameList.withExactText(databasesForSearch[0].databaseName).exists).notOk('The database with port is found', { timeout: 10000 });
71+
await t.expect(myRedisDatabasePage.dbNameList.withExactText(databasesForSearch[1].databaseName).exists).notOk('The database with port is found', { timeout: 10000 });
72+
await t.expect(myRedisDatabasePage.dbNameList.withExactText(ossSentinelConfig.name).exists).ok('The database with other port is not found', { timeout: 10000 });
73+
});
74+
// Unskip after fixing https://redislabs.atlassian.net/browse/RI-3300
75+
test.skip('Verify that user can search DB by Connection Type on the List of databases', async t => {
76+
//Search for DB by connection type
77+
const searchedDBConType = 'OSS Cluster';
78+
await t.typeText(myRedisDatabasePage.searchInput, searchedDBConType, { replace: true });
79+
//Verify that database found on the list search by connection type
80+
await t.expect(myRedisDatabasePage.dbNameList.withExactText(ossClusterConfig.ossClusterDatabaseName).exists).ok('The database with connection type not found', { timeout: 10000 });
81+
await t.expect(myRedisDatabasePage.dbNameList.withExactText(databasesForSearch[0].databaseName).exists).notOk('The database with other connection type found', { timeout: 10000 });
82+
await t.expect(myRedisDatabasePage.dbNameList.withExactText(databasesForSearch[1].databaseName).exists).notOk('The database with other connection type found', { timeout: 10000 });
83+
});
84+
test('Verify that user can search DB by Last Connection on the List of databases', async t => {
85+
const searchedDBFirst = 'less than a minute ago';
86+
const searchedDBSecond = '1 minute ago';
87+
const searchTimeout = 60 * 1000; // 60 sec to wait for changing Last Connection time
88+
const dbSelector = myRedisDatabasePage.dbNameList.withExactText(databasesForSearch[2].databaseName);
89+
const startTime = Date.now();
90+
//Search for DB by Last Connection
91+
await t.typeText(myRedisDatabasePage.searchInput, searchedDBFirst, { replace: true });
92+
//Verify that database added < 1min ago found on the list search by Last Connection
93+
await t.expect(myRedisDatabasePage.dbNameList.withExactText(databasesForSearch[1].databaseName).exists).ok('The database with Last Connection not found', { timeout: 10000 });
94+
//Verify that database added > 1min ago found on the list search by Last Connection
95+
do {
96+
await t.eval(() => location.reload());
97+
await t.typeText(myRedisDatabasePage.searchInput, searchedDBSecond, { replace: true });
98+
}
99+
while (!(await dbSelector.exists) && Date.now() - startTime < searchTimeout);
100+
await t.expect(dbSelector.exists).ok('The database with Last Connection not found', { timeout: 10000 });
101+
});
102+
test('Verify that user sees "No results found" message when pattern doesn`t match any database', async t => {
103+
//Search for DB by Invalid search
104+
const searchedDBHost = 'invalid';
105+
await t.typeText(myRedisDatabasePage.searchInput, searchedDBHost, { replace: true });
106+
//Verify that "No results found" message is displayed in case of invalid search
107+
await t.expect(myRedisDatabasePage.noResultsFoundMessage.exists).ok('"No results found message" not displayed');
108+
await t.expect(myRedisDatabasePage.noResultsFoundText.exists).ok('"No databases matched your search" message not displayed');
109+
});

0 commit comments

Comments
 (0)