Skip to content

Commit a73eb88

Browse files
Merge pull request #4261 from RedisInsight/feature/RI-6457/get-proper-rdi-version
RI-6457: Display proper RDI version
2 parents acbeb6e + 79e1678 commit a73eb88

File tree

5 files changed

+72
-12
lines changed

5 files changed

+72
-12
lines changed

redisinsight/api/src/modules/rdi/rdi.service.spec.ts

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,13 @@ describe('RdiService', () => {
145145
});
146146

147147
describe('create', () => {
148+
const validGetPipelineStatus = () => Promise.resolve({
149+
components: {
150+
processor:{
151+
version: "test-version"
152+
}
153+
}});
154+
148155
it('should create an Rdi instance', async () => {
149156
const dto: CreateRdiDto = {
150157
name: 'name',
@@ -154,7 +161,9 @@ describe('RdiService', () => {
154161
};
155162
const sessionMetadata = { userId: '123', sessionId: '789' };
156163
repository.create.mockResolvedValue(mockRdi);
157-
rdiClientFactory.createClient.mockResolvedValue(undefined);
164+
rdiClientFactory.createClient.mockReturnValue({
165+
getPipelineStatus: validGetPipelineStatus
166+
});
158167

159168
const result = await service.create(sessionMetadata, dto);
160169

@@ -177,6 +186,52 @@ describe('RdiService', () => {
177186

178187
await expect(service.create(sessionMetadata, dto)).rejects.toThrowError(wrapRdiPipelineError(error));
179188
});
189+
190+
it('should get the RDI version', async () => {
191+
const dto: CreateRdiDto = {
192+
name: 'name',
193+
url: 'http://localhost:4000',
194+
password: 'pass',
195+
username: 'user',
196+
};
197+
const sessionMetadata = { userId: '123', sessionId: '789' };
198+
199+
repository.create.mockResolvedValue(mockRdi);
200+
rdiClientFactory.createClient.mockReturnValue({
201+
getPipelineStatus: validGetPipelineStatus
202+
});
203+
204+
await service.create(sessionMetadata, dto);
205+
206+
expect(repository.create).toHaveBeenCalledWith(expect.objectContaining({
207+
version: 'test-version'
208+
}))
209+
});
210+
211+
it('should get the default RDI version when other information is missing', async () => {
212+
const dto: CreateRdiDto = {
213+
name: 'name',
214+
url: 'http://localhost:4000',
215+
password: 'pass',
216+
username: 'user',
217+
};
218+
const sessionMetadata = { userId: '123', sessionId: '789' };
219+
220+
repository.create.mockResolvedValue(mockRdi);
221+
rdiClientFactory.createClient.mockResolvedValue({
222+
getPipelineStatus: () => Promise.resolve(({
223+
components: {
224+
// missing processor.version
225+
}
226+
}))
227+
});
228+
229+
await service.create(sessionMetadata, dto);
230+
231+
expect(repository.create).toHaveBeenCalledWith(expect.objectContaining({
232+
version: '-'
233+
}))
234+
});
180235
});
181236

182237
describe('delete', () => {

redisinsight/api/src/modules/rdi/rdi.service.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ import { RdiPipelineNotFoundException, wrapRdiPipelineError } from 'src/modules/
1616
import { isUndefined, omitBy } from 'lodash';
1717
import { deepMerge } from 'src/common/utils';
1818
import { RdiAnalytics } from './rdi.analytics';
19-
import { CloudAuthService } from '../cloud/auth/cloud-auth.service';
19+
import { RdiClient } from './client/rdi.client';
20+
21+
const DEFAULT_RDI_VERSION = '-';
2022

2123
@Injectable()
2224
export class RdiService {
@@ -38,6 +40,12 @@ export class RdiService {
3840
return Object.keys(omitBy(dto, isUndefined)).some((field) => this.connectionFields.includes(field));
3941
}
4042

43+
private static async getRdiVersion(client: RdiClient): Promise<string> {
44+
const pipelineStatus = await client.getPipelineStatus();
45+
const version = pipelineStatus?.components?.processor?.version || DEFAULT_RDI_VERSION;
46+
return version;
47+
}
48+
4149
async list(): Promise<Rdi[]> {
4250
return await this.repository.list();
4351
}
@@ -72,16 +80,15 @@ export class RdiService {
7280
async create(sessionMetadata: SessionMetadata, dto: CreateRdiDto): Promise<Rdi> {
7381
const model = classToClass(Rdi, dto);
7482
model.lastConnection = new Date();
75-
// TODO add request to get version
76-
model.version = '1.2';
7783

7884
const rdiClientMetadata = {
7985
sessionMetadata,
8086
id: uuidv4(),
8187
};
8288

8389
try {
84-
await this.rdiClientFactory.createClient(rdiClientMetadata, model);
90+
const client = await this.rdiClientFactory.createClient(rdiClientMetadata, model);
91+
model.version = await RdiService.getRdiVersion(client);
8592
} catch (error) {
8693
this.logger.error('Failed to create rdi instance', sessionMetadata);
8794

redisinsight/ui/src/pages/rdi/pipeline-management/pages/config/Config.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ const Config = () => {
116116
/>
117117
</div>
118118
<EuiText className="rdi__text" color="subdued">
119-
{'Configure target instance '}
119+
{'Provide '}
120120
<EuiLink
121121
external={false}
122122
data-testid="rdi-pipeline-config-link"
@@ -131,7 +131,7 @@ const Config = () => {
131131
>
132132
connection details
133133
</EuiLink>
134-
{' and applier settings.'}
134+
{' for source and target databases and other collector configurations, such as tables and columns to track.'}
135135
</EuiText>
136136
{pipelineLoading ? (
137137
<div className={cx('rdi__editorWrapper', 'rdi__loading')} data-testid="rdi-config-loading">

redisinsight/ui/src/pages/rdi/pipeline-management/pages/job/Job.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ const Job = (props: Props) => {
191191
</div>
192192
</div>
193193
<EuiText className="rdi__text" color="subdued">
194-
{'Describe the '}
194+
{'Create a job per source table to filter, transform, and '}
195195
<EuiLink
196196
external={false}
197197
data-testid="rdi-pipeline-transformation-link"
@@ -204,9 +204,9 @@ const Job = (props: Props) => {
204204
}
205205
)}
206206
>
207-
transformation logic
207+
map data
208208
</EuiLink>
209-
{' to perform on data from a single source'}
209+
{' to Redis.'}
210210
</EuiText>
211211
{loading ? (
212212
<div className={cx('rdi__editorWrapper', 'rdi__loading')} data-testid="rdi-job-loading">

redisinsight/ui/src/pages/rdi/statistics/status/Status.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ interface Props {
2525
const Status = ({ data }: Props) => (
2626
<Panel paddingSize="l">
2727
<EuiFlexGroup>
28-
<StatusItem label="RDI Version" value={data.rdiVersion} />
29-
<VerticalDivider />
3028
<StatusItem label="Address" value={data.address} />
3129
<VerticalDivider />
3230
<StatusItem label="Run status" value={data.runStatus} />

0 commit comments

Comments
 (0)