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

Fix database sid display #1639

Merged
merged 4 commits into from
Jul 18, 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
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ describe('ClusterDetails ClusterDetailsPage component', () => {
const initialState = {
clustersList: { clusters: [cluster] },
hostsList: { hosts: [] },
sapSystemsList: { sapSystems: [] },
sapSystemsList: { sapSystems: [], applicationInstances: [] },
databasesList: { databases: [], databaseInstances: [] },
lastExecutions: {
[cluster.id]: { data: null, loading: false, error: null },
},
Expand Down
6 changes: 3 additions & 3 deletions assets/js/components/ClusterDetails/HanaClusterDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ function HanaClusterDetails({
}) {
const enrichedNodes = enrichNodes(details?.nodes, hosts);
const enrichedSapSystem = {
tenant: sid,
...sapSystems.find(({ tenant }) => tenant === sid),
sid,
...sapSystems.find(({ sid: currentSid }) => currentSid === sid),
};

const { loading: executionLoading } = lastExecution || { loading: true };
Expand Down Expand Up @@ -166,7 +166,7 @@ function HanaClusterDetails({
sapSystemId={content?.id}
systemType="databases"
>
{content?.tenant}
{content?.sid}
</SapSystemLink>
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const hosts = [
hostFactory.build({ hostname: details.nodes[1].name }),
];

const sapSystems = sapSystemFactory.buildList(1, { tenant: sid });
const sapSystems = sapSystemFactory.buildList(1, { sid });

function ContainerWrapper({ children }) {
return (
Expand Down
10 changes: 3 additions & 7 deletions assets/js/components/ClusterDetails/HanaClusterDetails.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ describe('HanaClusterDetails component', () => {

const hosts = hostFactory.buildList(2, { cluster_id: clusterID });

const sapSystems = sapSystemFactory.buildList(2, { tenant: sid });

renderWithRouter(
<HanaClusterDetails
clusterID={clusterID}
Expand All @@ -94,7 +92,7 @@ describe('HanaClusterDetails component', () => {
cibLastWritten={cibLastWritten}
sid={sid}
provider={provider}
sapSystems={sapSystems}
sapSystems={[]}
details={details}
lastExecution={lastExecution}
/>
Expand All @@ -119,7 +117,7 @@ describe('HanaClusterDetails component', () => {

const hosts = hostFactory.buildList(2, { cluster_id: clusterID });

const sapSystems = sapSystemFactory.buildList(2, { tenant: sid });
const sapSystems = sapSystemFactory.buildList(2, { sid });

renderWithRouter(
<HanaClusterDetails
Expand Down Expand Up @@ -201,8 +199,6 @@ describe('HanaClusterDetails component', () => {
cluster_id: clusterID,
});

const sapSystems = sapSystemFactory.buildList(2, { tenant: sid });

renderWithRouter(
<HanaClusterDetails
clusterID={clusterID}
Expand All @@ -214,7 +210,7 @@ describe('HanaClusterDetails component', () => {
cibLastWritten={cibLastWritten}
sid={sid}
provider={provider}
sapSystems={sapSystems}
sapSystems={[]}
details={details}
lastExecution={null}
/>
Expand Down
5 changes: 2 additions & 3 deletions assets/js/components/HostsList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ const removeTag = (tag, hostId) => {
function HostsList() {
const hosts = useSelector((state) => state.hostsList.hosts);
const clusters = useSelector((state) => state.clustersList.clusters);
const { applicationInstances, databaseInstances } = useSelector(
(state) => state.sapSystemsList
);
const { applicationInstances } = useSelector((state) => state.sapSystemsList);
const { databaseInstances } = useSelector((state) => state.databasesList);

const [searchParams, setSearchParams] = useSearchParams();
const [cleanUpModalOpen, setCleanUpModalOpen] = useState(false);
Expand Down
67 changes: 46 additions & 21 deletions assets/js/components/HostsList.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ describe('HostsLists component', () => {
provider: 'Azure',
cluster: 'hana_cluster_1',
sid: 'HDD',
sap_system_id: 'f534a4ad-cef7-5234-b196-e67082ffb50c',
sap_system_type: 'databases',
version: '1.1.0+git.dev17.1660137228.fe5ba8a',
},
{
Expand All @@ -33,29 +35,48 @@ describe('HostsLists component', () => {
provider: '',
cluster: '',
sid: 'NWQ',
sap_system_id: 'cd52e571-c897-5bba-b0f9-e155ceca1fff',
sap_system_type: 'sap_systems',
version: '1.1.0+git.dev17.1660137228.fe5ba8a',
},
].forEach(({ host, ip, provider, cluster, sid, version }) => {
it(`should show the correct values in the hosts list for host ${host}`, () => {
const [StatefulHostsList] = withDefaultState(<HostsList />);
const params = { route: `/hosts?hostname=${host}` };
renderWithRouter(StatefulHostsList, params);

const table = screen.getByRole('table');
expect(table.querySelector('td:nth-child(2)')).toHaveTextContent(host);
expect(table.querySelector('td:nth-child(3)')).toHaveTextContent(ip);
expect(table.querySelector('td:nth-child(4)')).toHaveTextContent(
provider
);
expect(table.querySelector('td:nth-child(5)')).toHaveTextContent(
cluster
);
expect(table.querySelector('td:nth-child(6)')).toHaveTextContent(sid);
expect(table.querySelector('td:nth-child(7)')).toHaveTextContent(
version
);
});
});
].forEach(
({
host,
ip,
provider,
cluster,
sid,
sap_system_id,
sap_system_type,
version,
}) => {
it(`should show the correct values in the hosts list for host ${host}`, () => {
const [StatefulHostsList] = withDefaultState(<HostsList />);
const params = { route: `/hosts?hostname=${host}` };
renderWithRouter(StatefulHostsList, params);

const table = screen.getByRole('table');
expect(table.querySelector('td:nth-child(2)')).toHaveTextContent(
host
);
expect(table.querySelector('td:nth-child(3)')).toHaveTextContent(ip);
expect(table.querySelector('td:nth-child(4)')).toHaveTextContent(
provider
);
expect(table.querySelector('td:nth-child(5)')).toHaveTextContent(
cluster
);
expect(table.querySelector('td:nth-child(6)')).toHaveTextContent(sid);
expect(table.querySelector('td:nth-child(6) > a')).toHaveAttribute(
'href',
`/${sap_system_type}/${sap_system_id}`
);
expect(table.querySelector('td:nth-child(7)')).toHaveTextContent(
version
);
});
}
);

it('should show a warning state if the agent version is not compatible', () => {
const user = userEvent.setup();
Expand Down Expand Up @@ -203,6 +224,10 @@ describe('HostsLists component', () => {
applicationInstances: [],
databaseInstances: [],
},
databasesList: {
databases: [],
databaseInstances: [],
},
};

const scenarios = [
Expand Down
116 changes: 116 additions & 0 deletions assets/js/lib/test-utils/data/databases.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
export default [
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The databases slice default state added, as this is how it is loaded in the initial fetch (and next updates)

{
database_instances: [
{
features: 'HDB|HDB_WORKER',
health: 'passing',
host_id: '0a055c90-4cb6-54ce-ac9c-ae3fedaf40d4',
http_port: 51013,
https_port: 51014,
instance_hostname: 'vmhdbdev02',
instance_number: '10',
sap_system_id: 'f534a4ad-cef7-5234-b196-e67082ffb50c',
sid: 'HDD',
start_priority: '0.3',
system_replication: 'Secondary',
system_replication_status: 'ACTIVE',
tenant: 'HDD',
},
{
features: 'HDB|HDB_WORKER',
health: 'passing',
host_id: '13e8c25c-3180-5a9a-95c8-51ec38e50cfc',
http_port: 51013,
https_port: 51014,
instance_hostname: 'vmhdbdev01',
instance_number: '10',
sap_system_id: 'f534a4ad-cef7-5234-b196-e67082ffb50c',
sid: 'HDD',
start_priority: '0.3',
system_replication: 'Primary',
system_replication_status: '',
tenant: 'HDD',
},
],
health: 'passing',
id: 'f534a4ad-cef7-5234-b196-e67082ffb50c',
sid: 'HDD',
tags: [],
},
{
database_instances: [
{
features: 'HDB|HDB_WORKER',
health: 'passing',
host_id: '9cd46919-5f19-59aa-993e-cf3736c71053',
http_port: 51013,
https_port: 51014,
instance_hostname: 'vmhdbprd01',
instance_number: '10',
sap_system_id: '6c9208eb-a5bb-57ef-be5c-6422dedab602',
sid: 'HDP',
start_priority: '0.3',
system_replication: 'Primary',
system_replication_status: '',
tenant: 'HDP',
},
{
features: 'HDB|HDB_WORKER',
health: 'passing',
host_id: 'b767b3e9-e802-587e-a442-541d093b86b9',
http_port: 51013,
https_port: 51014,
instance_hostname: 'vmhdbprd02',
instance_number: '10',
sap_system_id: '6c9208eb-a5bb-57ef-be5c-6422dedab602',
sid: 'HDP',
start_priority: '0.3',
system_replication: 'Secondary',
system_replication_status: 'ACTIVE',
tenant: 'HDP',
},
],
health: 'passing',
id: '6c9208eb-a5bb-57ef-be5c-6422dedab602',
sid: 'HDP',
tags: [],
},
{
database_instances: [
{
features: 'HDB|HDB_WORKER',
health: 'passing',
host_id: '99cf8a3a-48d6-57a4-b302-6e4482227ab6',
http_port: 51013,
https_port: 51014,
instance_hostname: 'vmhdbqas01',
instance_number: '10',
sap_system_id: 'cd52e571-c897-5bba-b0f9-e155ceca1fff',
sid: 'HDQ',
start_priority: '0.3',
system_replication: 'Primary',
system_replication_status: '',
tenant: 'HDQ',
},
{
features: 'HDB|HDB_WORKER',
health: 'passing',
host_id: 'e0c182db-32ff-55c6-a9eb-2b82dd21bc8b',
http_port: 51013,
https_port: 51014,
instance_hostname: 'vmhdbqas02',
instance_number: '10',
sap_system_id: 'cd52e571-c897-5bba-b0f9-e155ceca1fff',
sid: 'HDQ',
start_priority: '0.3',
system_replication: 'Secondary',
system_replication_status: 'ACTIVE',
tenant: 'HDQ',
},
],
health: 'passing',
id: 'cd52e571-c897-5bba-b0f9-e155ceca1fff',
sid: 'HDQ',
tags: [],
},
];
7 changes: 7 additions & 0 deletions assets/js/lib/test-utils/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { runSaga } from 'redux-saga';
import hosts from './data/hosts';
import clusters from './data/clusters';
import sapSystems from './data/sapSystems';
import databases from './data/databases';

const middlewares = [];
const mockStore = configureStore(middlewares);
Expand All @@ -26,6 +27,12 @@ export const defaultInitialState = {
(sapSystem) => sapSystem.database_instances
),
},
databasesList: {
databases,
databaseInstances: databases.flatMap(
(database) => database.database_instances
),
},
clusterChecksSelection: {},
hostChecksSelection: {},
catalog: { loading: false, data: [], error: null },
Expand Down
10 changes: 6 additions & 4 deletions assets/js/state/selectors/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ export const getClusterName =
export const getClusterSapSystems = (clusterID) => (state) => {
const clusterHostIDs = getClusterHostIDs(clusterID)(state);
const {
sapSystemsList: { sapSystems, applicationInstances, databaseInstances },
sapSystemsList: { sapSystems, applicationInstances },
databasesList: { databases, databaseInstances },
} = state;

return sapSystems.filter((sapSystem) =>
const instances = applicationInstances.concat(databaseInstances);

return sapSystems.concat(databases).filter((sapSystem) =>
clusterHostIDs.some((hostID) =>
applicationInstances
.concat(databaseInstances)
instances
.filter(({ sap_system_id }) => sap_system_id === sapSystem.id)
.map(({ host_id }) => host_id)
.includes(hostID)
Expand Down
Loading