Skip to content

Commit f2c2bdc

Browse files
author
Kristiyan Ivanov
authored
Merge pull request #4569 from RedisInsight/bugfix/be/RI-7077-forcestandalone-in-test-connection
RI-7077: do not switch to cluster if force standalone is set
2 parents 38f85ad + b1ec02d commit f2c2bdc

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

redisinsight/api/src/modules/database/providers/database.factory.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,23 @@ describe('DatabaseFactory', () => {
112112

113113
expect(result).toEqual(mockClusterDatabaseWithTlsAuth);
114114
});
115+
it('should create standalone model when cluster database is passed but with standalone flag on', async () => {
116+
mockRedisSentinelUtil.isSentinel.mockResolvedValue(false);
117+
mockRedisClusterUtil.isCluster.mockResolvedValue(true);
118+
119+
const result = await service.createDatabaseModel(mockSessionMetadata, {
120+
...mockClusterDatabaseWithTlsAuth,
121+
forceStandalone: true,
122+
});
123+
124+
expect({
125+
forceStandalone: result.forceStandalone,
126+
connectionType: result.connectionType,
127+
}).toEqual({
128+
forceStandalone: true,
129+
connectionType: ConnectionType.STANDALONE,
130+
});
131+
});
115132
});
116133

117134
describe('createStandaloneDatabaseModel', () => {

redisinsight/api/src/modules/database/providers/database.factory.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export class DatabaseFactory {
7373
database,
7474
client,
7575
);
76-
} else if (await isCluster(client)) {
76+
} else if (!database.forceStandalone && (await isCluster(client))) {
7777
model = await this.createClusterDatabaseModel(
7878
sessionMetadata,
7979
database,
@@ -123,6 +123,7 @@ export class DatabaseFactory {
123123
* Fetches cluster nodes
124124
* Creates cluster client to validate connection. Disconnect after check
125125
* Creates database model for cluster connection type
126+
* @param sessionMetadata
126127
* @param database
127128
* @param client
128129
* @private
@@ -164,6 +165,7 @@ export class DatabaseFactory {
164165
* Fetches sentinel masters and align with defined one
165166
* Creates sentinel client to validate connection. Disconnect after check
166167
* Creates database model for cluster connection type
168+
* @param sessionMetadata
167169
* @param database
168170
* @param client
169171
* @private

0 commit comments

Comments
 (0)