Skip to content

Commit

Permalink
Bug fix: getRollups API, rollup jobs landing page (opensearch-project…
Browse files Browse the repository at this point in the history
…#154)

*  getRollups API fix: modify format of node API to take optional parameters.

*  Modify rollup jobs landing page to show fields correctly and have working sorting function.

* Modify rollups_spec.js cypress test to allow 60 seconds for sample data installation
  • Loading branch information
annie3431 authored Jan 28, 2021
1 parent 01bbb98 commit 3b32210
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 82 deletions.
2 changes: 1 addition & 1 deletion cypress/integration/rollups_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe("Rollups", () => {
cy.get(`button[data-test-subj="addSampleDataSetecommerce"]`).click({ force: true });

// Verify that sample data is add by checking toast notification
cy.contains("Sample eCommerce orders installed");
cy.contains("Sample eCommerce orders installed", { timeout: 60000 });

// Visit ISM Kibana
cy.visit(`${Cypress.env("kibana")}/app/${PLUGIN_NAME}#/rollups`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import ChangeManagedIndices from "./ChangeManagedIndices";
import { browserServicesMock } from "../../../../../test/mocks";
import coreServicesMock from "../../../../../test/mocks/coreServicesMock";
import { CoreServicesContext } from "../../../../components/core_services";
import RetryModal from "../../../ManagedIndices/components/RetryModal";

describe("<ChangeManagedIndices /> spec", () => {
it("renders the component", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,7 @@ import GeneralInformation from "../../components/GeneralInformation/GeneralInfor
import RollupStatus from "../../components/RollupStatus/RollupStatus";
import AggregationAndMetricsSettings from "../../components/AggregationAndMetricsSettings/AggregationAndMetricsSettings";
import { parseTimeunit } from "../../../CreateRollup/utils/helpers";
import {
DimensionItem,
MetricItem,
RollupDimensionItem,
RollupMetadata,
RollupMetricItem,
DateHistogramItem,
} from "../../../../../models/interfaces";
import { DimensionItem, MetricItem, RollupDimensionItem, RollupMetadata, RollupMetricItem } from "../../../../../models/interfaces";
import { renderTime } from "../../../Rollups/utils/helpers";
import DeleteModal from "../../../Rollups/components/DeleteModal";
import { CoreServicesContext } from "../../../../components/core_services";
Expand Down
8 changes: 4 additions & 4 deletions public/pages/Rollups/containers/Rollups/Rollups.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -346,14 +346,14 @@ export default class Rollups extends Component<RollupsProps, RollupsState> {
),
},
{
field: "rollup.rollup.source_index",
field: "rollup.source_index",
name: "Source index",
sortable: true,
textOnly: true,
truncateText: true,
},
{
field: "rollup.rollup.target_index",
field: "rollup.target_index",
name: "Target index",
sortable: true,
textOnly: true,
Expand All @@ -378,15 +378,15 @@ export default class Rollups extends Component<RollupsProps, RollupsState> {
{
field: "metadata.rollup_metadata.continuous",
name: "Next rollup window",
sortable: true,
sortable: false,
textOnly: true,
render: (metadata) =>
metadata == null ? "-" : renderTime(metadata.next_window_start_time) + " - " + renderTime(metadata.next_window_end_time),
},
{
field: "metadata",
name: "Rollup job status",
sortable: true,
sortable: false,
textOnly: true,
render: (metadata) => renderStatus(metadata),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,14 @@ exports[`<Rollups /> spec renders the component 1`] = `
</th>
<th
aria-live="polite"
aria-sort="none"
aria-sort="descending"
class="euiTableHeaderCell"
data-test-subj="tableHeaderCell__id_0"
role="columnheader"
scope="col"
>
<button
class="euiTableHeaderButton"
class="euiTableHeaderButton euiTableHeaderButton-isSorted"
data-test-subj="tableHeaderSortButton"
type="button"
>
Expand All @@ -277,10 +277,11 @@ exports[`<Rollups /> spec renders the component 1`] = `
>
<span
class="euiTableCellContent__text"
title="Name"
title="Name; Sorted in descending order"
>
Name
</span>
EuiIconMock
<span
class="euiScreenReaderOnly"
>
Expand All @@ -293,7 +294,7 @@ exports[`<Rollups /> spec renders the component 1`] = `
aria-live="polite"
aria-sort="none"
class="euiTableHeaderCell"
data-test-subj="tableHeaderCell_rollup.rollup.source_index_1"
data-test-subj="tableHeaderCell_rollup.source_index_1"
role="columnheader"
scope="col"
>
Expand Down Expand Up @@ -323,7 +324,7 @@ exports[`<Rollups /> spec renders the component 1`] = `
aria-live="polite"
aria-sort="none"
class="euiTableHeaderCell"
data-test-subj="tableHeaderCell_rollup.rollup.target_index_2"
data-test-subj="tableHeaderCell_rollup.target_index_2"
role="columnheader"
scope="col"
>
Expand Down Expand Up @@ -410,64 +411,38 @@ exports[`<Rollups /> spec renders the component 1`] = `
</button>
</th>
<th
aria-live="polite"
aria-sort="none"
class="euiTableHeaderCell"
data-test-subj="tableHeaderCell_metadata.rollup_metadata.continuous_5"
role="columnheader"
scope="col"
>
<button
class="euiTableHeaderButton"
data-test-subj="tableHeaderSortButton"
type="button"
<div
class="euiTableCellContent"
>
<span
class="euiTableCellContent"
class="euiTableCellContent__text"
title="Next rollup window"
>
<span
class="euiTableCellContent__text"
title="Next rollup window"
>
Next rollup window
</span>
<span
class="euiScreenReaderOnly"
>
Click to sort in ascending order
</span>
Next rollup window
</span>
</button>
</div>
</th>
<th
aria-live="polite"
aria-sort="none"
class="euiTableHeaderCell"
data-test-subj="tableHeaderCell_metadata_6"
role="columnheader"
scope="col"
>
<button
class="euiTableHeaderButton"
data-test-subj="tableHeaderSortButton"
type="button"
<div
class="euiTableCellContent"
>
<span
class="euiTableCellContent"
class="euiTableCellContent__text"
title="Rollup job status"
>
<span
class="euiTableCellContent__text"
title="Rollup job status"
>
Rollup job status
</span>
<span
class="euiScreenReaderOnly"
>
Click to sort in ascending order
</span>
Rollup job status
</span>
</button>
</div>
</th>
</tr>
</thead>
Expand Down
2 changes: 1 addition & 1 deletion public/pages/Rollups/utils/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ export const DEFAULT_QUERY_PARAMS = {
from: 0,
size: 20,
search: "",
sortField: "name",
sortField: "_id",
sortDirection: SortDirection.DESC,
};
21 changes: 0 additions & 21 deletions server/clusters/ism/ismPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,27 +174,6 @@ export default function ismPlugin(Client: any, config: any, components: any) {
ism.getRollups = ca({
url: {
fmt: `${API.ROLLUP_JOBS_BASE}`,
req: {
from: {
type: "number",
required: true,
},
size: {
type: "number",
required: true,
},
search: {
type: "string",
},
sortField: {
type: "string",
required: true,
},
sortDirection: {
type: "string",
required: true,
},
},
},
method: "GET",
});
Expand Down
13 changes: 10 additions & 3 deletions server/services/RollupService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,18 @@ export default class RollupService {
sortField: string;
};

const rollupSortMap: { [key: string]: string } = {
_id: "rollup.rollup_id.keyword",
"rollup.source_index": "rollup.source_index.keyword",
"rollup.target_index": "rollup.target_index.keyword",
"rollup.rollup.enabled": "rollup.enabled",
};

const params = {
from,
size,
from: parseInt(from, 10),
size: parseInt(size, 10),
search,
sortField,
sortField: rollupSortMap[sortField] || rollupSortMap._id,
sortDirection,
};

Expand Down

0 comments on commit 3b32210

Please sign in to comment.