Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(recordings): check target's jvmId for recording events (backport #1126) #1151

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/Agent/AgentLiveProbes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export const AgentLiveProbes: React.FC<AgentLiveProbesProps> = (_) => {
context.target.target(),
context.notificationChannel.messages(NotificationCategory.ProbeTemplateApplied),
]).subscribe(([currentTarget, e]) => {
if (currentTarget?.connectUrl != e.message.targetId) {
if (currentTarget?.connectUrl != e.message.targetId && currentTarget?.jvmId != e.message.jvmId) {
return;
}
setProbes((old) => {
Expand Down
2 changes: 1 addition & 1 deletion src/app/RecordingMetadata/BulkEditLabels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export const BulkEditLabels: React.FC<BulkEditLabelsProps> = ({
]).subscribe((parts) => {
const currentTarget = parts[0];
const event = parts[1];
if (currentTarget?.connectUrl != event.message.target) {
if (currentTarget?.connectUrl != event.message.target && currentTarget?.jvmId != event.message.jvmId) {
return;
}
setRecordings((old) =>
Expand Down
8 changes: 4 additions & 4 deletions src/app/Recordings/ActiveRecordingsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export const ActiveRecordingsTable: React.FC<ActiveRecordingsTableProps> = (prop
context.notificationChannel.messages(NotificationCategory.SnapshotCreated),
),
]).subscribe(([currentTarget, event]) => {
if (currentTarget?.connectUrl != event.message.target) {
if (currentTarget?.connectUrl != event.message.target && currentTarget?.jvmId != event.message.jvmId) {
return;
}
setRecordings((old) => old.concat([event.message.recording]));
Expand All @@ -268,7 +268,7 @@ export const ActiveRecordingsTable: React.FC<ActiveRecordingsTableProps> = (prop
context.notificationChannel.messages(NotificationCategory.SnapshotDeleted),
),
]).subscribe(([currentTarget, event]) => {
if (currentTarget?.connectUrl != event.message.target) {
if (currentTarget?.connectUrl != event.message.target && currentTarget?.jvmId != event.message.jvmId) {
return;
}

Expand All @@ -284,7 +284,7 @@ export const ActiveRecordingsTable: React.FC<ActiveRecordingsTableProps> = (prop
context.target.target(),
context.notificationChannel.messages(NotificationCategory.ActiveRecordingStopped),
]).subscribe(([currentTarget, event]) => {
if (currentTarget?.connectUrl != event.message.target) {
if (currentTarget?.connectUrl != event.message.target && currentTarget?.jvmId != event.message.jvmId) {
return;
}
setRecordings((old) => {
Expand Down Expand Up @@ -315,7 +315,7 @@ export const ActiveRecordingsTable: React.FC<ActiveRecordingsTableProps> = (prop
context.target.target(),
context.notificationChannel.messages(NotificationCategory.RecordingMetadataUpdated),
]).subscribe(([currentTarget, event]) => {
if (currentTarget?.connectUrl != event.message.target) {
if (currentTarget?.connectUrl != event.message.target && currentTarget?.jvmId != event.message.jvmId) {
return;
}
setRecordings((old) =>
Expand Down
6 changes: 3 additions & 3 deletions src/app/Recordings/ArchivedRecordingsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ export const ArchivedRecordingsTable: React.FC<ArchivedRecordingsTableProps> = (
context.notificationChannel.messages(NotificationCategory.ActiveRecordingSaved),
),
]).subscribe(([currentTarget, event]) => {
if (currentTarget?.connectUrl != event.message.target) {
if (currentTarget?.connectUrl != event.message.target && currentTarget?.jvmId != event.message.jvmId) {
return;
}
setRecordings((old) =>
Expand All @@ -326,7 +326,7 @@ export const ArchivedRecordingsTable: React.FC<ArchivedRecordingsTableProps> = (
propsTarget,
context.notificationChannel.messages(NotificationCategory.ArchivedRecordingDeleted),
]).subscribe(([currentTarget, event]) => {
if (currentTarget?.connectUrl != event.message.target) {
if (currentTarget?.connectUrl != event.message.target && currentTarget?.jvmId != event.message.jvmId) {
return;
}
setRecordings((old) => old.filter((r) => r.name !== event.message.recording.name));
Expand All @@ -341,7 +341,7 @@ export const ArchivedRecordingsTable: React.FC<ArchivedRecordingsTableProps> = (
propsTarget,
context.notificationChannel.messages(NotificationCategory.RecordingMetadataUpdated),
]).subscribe(([currentTarget, event]) => {
if (currentTarget?.connectUrl != event.message.target) {
if (currentTarget?.connectUrl != event.message.target && currentTarget?.jvmId != event.message.jvmId) {
return;
}
setRecordings((old) =>
Expand Down
1 change: 0 additions & 1 deletion src/app/Shared/Services/api.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,6 @@ export interface NotificationMessage {
meta: MessageMeta;
// Should a message be any type? Try T?
message: any; // eslint-disable-line @typescript-eslint/no-explicit-any
serverTime: number;
}

export interface MessageMeta {
Expand Down
12 changes: 0 additions & 12 deletions src/mirage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export const startMirage = ({ environment = 'development' } = {}) => {
type: 'application',
subtype: 'json',
},
serverTime: +Date.now(),
},
message: {
'127.0.0.1': 'accepted',
Expand Down Expand Up @@ -116,7 +115,6 @@ export const startMirage = ({ environment = 'development' } = {}) => {
meta: {
category: 'TargetJvmDiscovery',
type: { type: 'application', subType: 'json' },
serverTime: +Date.now(),
},
message: { event: { serviceRef: target, kind: 'FOUND' } },
}),
Expand Down Expand Up @@ -186,7 +184,6 @@ export const startMirage = ({ environment = 'development' } = {}) => {
meta: {
category: 'ArchivedRecordingDeleted',
type: { type: 'application', subType: 'json' },
serverTime: +Date.now(),
},
message: {
recording: {
Expand Down Expand Up @@ -229,7 +226,6 @@ export const startMirage = ({ environment = 'development' } = {}) => {
meta: {
category: 'ActiveRecordingCreated',
type: { type: 'application', subType: 'json' },
serverTime: +Date.now(),
},
message: {
target: request.params.targetId,
Expand All @@ -253,7 +249,6 @@ export const startMirage = ({ environment = 'development' } = {}) => {
meta: {
category: 'ActiveRecordingDeleted',
type: { type: 'application', subType: 'json' },
serverTime: +Date.now(),
},
message: {
recording: {
Expand Down Expand Up @@ -282,7 +277,6 @@ export const startMirage = ({ environment = 'development' } = {}) => {
meta: {
category: 'ActiveRecordingStopped',
type: { type: 'application', subType: 'json' },
serverTime: +Date.now(),
},
message: {
recording: {
Expand All @@ -308,7 +302,6 @@ export const startMirage = ({ environment = 'development' } = {}) => {
meta: {
category: 'ActiveRecordingSaved',
type: { type: 'application', subType: 'json' },
serverTime: ts,
},
message: {
recording: archived,
Expand Down Expand Up @@ -426,7 +419,6 @@ export const startMirage = ({ environment = 'development' } = {}) => {
meta: {
category: 'RuleCreated',
type: { type: 'application', subType: 'json' },
serverTime: +Date.now(),
},
message: rule,
};
Expand All @@ -453,7 +445,6 @@ export const startMirage = ({ environment = 'development' } = {}) => {
meta: {
category: 'RuleUpdated',
type: { type: 'application', subType: 'json' },
serverTime: +Date.now(),
},
message: rule,
};
Expand All @@ -473,7 +464,6 @@ export const startMirage = ({ environment = 'development' } = {}) => {
meta: {
category: 'RuleDeleted',
type: { type: 'application', subType: 'json' },
serverTime: +Date.now(),
},
message: rule,
};
Expand Down Expand Up @@ -581,7 +571,6 @@ export const startMirage = ({ environment = 'development' } = {}) => {
meta: {
category: 'RecordingMetadataUpdated',
type: { type: 'application', subType: 'json' },
serverTime: +Date.now(),
},
message: {
recordingName: variables.recordingName,
Expand Down Expand Up @@ -628,7 +617,6 @@ export const startMirage = ({ environment = 'development' } = {}) => {
meta: {
category: 'RecordingMetadataUpdated',
type: { type: 'application', subType: 'json' },
serverTime: +Date.now(),
},
message: {
recordingName: variables.recordingName,
Expand Down
4 changes: 3 additions & 1 deletion src/test/Agent/AgentLiveProbes.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ import { of } from 'rxjs';
import { renderWithServiceContext } from '../Common';

const mockConnectUrl = 'service:jmx:rmi://someUrl';
const mockTarget = { connectUrl: mockConnectUrl, alias: 'fooTarget' };
const mockJvmId = 'id';
const mockTarget = { connectUrl: mockConnectUrl, alias: 'fooTarget', jvmId: mockJvmId };

const mockMessageType = { type: 'application', subtype: 'json' } as MessageType;

Expand Down Expand Up @@ -66,6 +67,7 @@ const mockApplyTemplateNotification = {
message: {
targetId: mockConnectUrl,
events: [mockAnotherProbe],
jvmId: mockJvmId,
},
} as NotificationMessage;

Expand Down
5 changes: 4 additions & 1 deletion src/test/RecordingMetadata/BulkEditLabels.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ jest.mock('@patternfly/react-core', () => ({
}));

const mockConnectUrl = 'service:jmx:rmi://someUrl';
const mockTarget = { connectUrl: mockConnectUrl, alias: 'fooTarget' };
const mockJvmId = 'id';
const mockTarget = { connectUrl: mockConnectUrl, alias: 'fooTarget', jvmId: mockJvmId };

const mockRecordingLabels = {
someLabel: 'someValue',
Expand Down Expand Up @@ -69,6 +70,7 @@ const mockActiveLabelsNotification = {
message: {
target: mockConnectUrl,
recordingName: 'someActiveRecording',
jvmId: mockJvmId,
metadata: { labels: { someLabel: 'someValue', someNewLabel: 'someNewValue' } },
},
} as NotificationMessage;
Expand All @@ -79,6 +81,7 @@ const mockArchivedLabelsNotification = {
message: {
target: mockConnectUrl,
recordingName: 'someArchivedRecording_some_random',
jvmId: mockJvmId,
metadata: { labels: { someLabel: 'someValue', someNewLabel: 'someNewValue' } },
},
} as NotificationMessage;
Expand Down
10 changes: 7 additions & 3 deletions src/test/Recordings/ActiveRecordingsTable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ import {
} from '../Common';

const mockConnectUrl = 'service:jmx:rmi://someUrl';
const mockTarget = { connectUrl: mockConnectUrl, alias: 'fooTarget' };
const mockJvmId = 'id';
const mockTarget = { connectUrl: mockConnectUrl, alias: 'fooTarget', jvmId: mockJvmId };
const mockRecordingLabels = {
someLabel: 'someValue',
};
Expand All @@ -59,16 +60,19 @@ const mockRecording: ActiveRecording = {
};
const mockAnotherRecording = { ...mockRecording, name: 'anotherRecording', id: 1 };
const mockCreateNotification = {
message: { target: mockConnectUrl, recording: mockAnotherRecording },
message: { target: mockConnectUrl, recording: mockAnotherRecording, jvmId: mockJvmId },
} as NotificationMessage;
const mockLabelsNotification = {
message: {
target: mockConnectUrl,
recordingName: 'someRecording',
jvmId: mockJvmId,
metadata: { labels: { someLabel: 'someUpdatedValue' } },
},
} as NotificationMessage;
const mockStopNotification = { message: { target: mockConnectUrl, recording: mockRecording } } as NotificationMessage;
const mockStopNotification = {
message: { target: mockConnectUrl, recording: mockRecording, jvmId: mockJvmId },
} as NotificationMessage;
const mockDeleteNotification = mockStopNotification;

const history = createMemoryHistory({ initialEntries: ['/recordings'] });
Expand Down
10 changes: 7 additions & 3 deletions src/test/Recordings/ArchivedRecordingsTable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ import {
} from '../Common';

const mockConnectUrl = 'service:jmx:rmi://someUrl';
const mockTarget = { connectUrl: mockConnectUrl, alias: 'fooTarget' };
const mockJvmId = 'id';
const mockTarget = { connectUrl: mockConnectUrl, alias: 'fooTarget', jvmId: mockJvmId };
const mockUploadsTarget = { connectUrl: UPLOADS_SUBDIRECTORY, alias: '' };
const mockRecordingLabels = {
someLabel: 'someValue',
Expand Down Expand Up @@ -73,16 +74,19 @@ const mockArchivedRecordingsResponse = {

const mockAnotherRecording = { ...mockRecording, name: 'anotherRecording' };
const mockCreateNotification = {
message: { target: mockConnectUrl, recording: mockAnotherRecording },
message: { target: mockConnectUrl, recording: mockAnotherRecording, jvmId: mockJvmId },
} as NotificationMessage;
const mockLabelsNotification = {
message: {
target: mockConnectUrl,
recordingName: 'someRecording',
jvmId: mockJvmId,
metadata: { labels: { someLabel: 'someUpdatedValue' } },
},
} as NotificationMessage;
const mockDeleteNotification = { message: { target: mockConnectUrl, recording: mockRecording } } as NotificationMessage;
const mockDeleteNotification = {
message: { target: mockConnectUrl, recording: mockRecording, jvmId: mockJvmId },
} as NotificationMessage;

const mockFileName = 'mock.jfr';
const mockFileUpload = new File([JSON.stringify(mockAnotherRecording)], mockFileName, { type: 'jfr' });
Expand Down
Loading