From 3b3221002cd64b9e47f062d0fb72b898b32541c4 Mon Sep 17 00:00:00 2001
From: Annie Lee <71157062+leeyun-amzn@users.noreply.github.com>
Date: Thu, 28 Jan 2021 14:13:14 +0800
Subject: [PATCH] Bug fix: getRollups API, rollup jobs landing page (#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
---
cypress/integration/rollups_spec.js | 2 +-
.../ChangeManagedIndices.test.tsx | 1 -
.../RollupDetails/RollupDetails.tsx | 9 +--
.../Rollups/containers/Rollups/Rollups.tsx | 8 +--
.../__snapshots__/Rollups.test.tsx.snap | 61 ++++++-------------
public/pages/Rollups/utils/constants.tsx | 2 +-
server/clusters/ism/ismPlugin.ts | 21 -------
server/services/RollupService.ts | 13 +++-
8 files changed, 35 insertions(+), 82 deletions(-)
diff --git a/cypress/integration/rollups_spec.js b/cypress/integration/rollups_spec.js
index a97ea3105..e3abb2d1d 100644
--- a/cypress/integration/rollups_spec.js
+++ b/cypress/integration/rollups_spec.js
@@ -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`);
diff --git a/public/pages/ChangePolicy/components/ChangeManagedIndices/ChangeManagedIndices.test.tsx b/public/pages/ChangePolicy/components/ChangeManagedIndices/ChangeManagedIndices.test.tsx
index 86e597e66..5e60a8d76 100644
--- a/public/pages/ChangePolicy/components/ChangeManagedIndices/ChangeManagedIndices.test.tsx
+++ b/public/pages/ChangePolicy/components/ChangeManagedIndices/ChangeManagedIndices.test.tsx
@@ -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(" spec", () => {
it("renders the component", async () => {
diff --git a/public/pages/RollupDetails/containers/RollupDetails/RollupDetails.tsx b/public/pages/RollupDetails/containers/RollupDetails/RollupDetails.tsx
index c39f26f63..7554b466e 100644
--- a/public/pages/RollupDetails/containers/RollupDetails/RollupDetails.tsx
+++ b/public/pages/RollupDetails/containers/RollupDetails/RollupDetails.tsx
@@ -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";
diff --git a/public/pages/Rollups/containers/Rollups/Rollups.tsx b/public/pages/Rollups/containers/Rollups/Rollups.tsx
index b6fba955e..2b0d46284 100644
--- a/public/pages/Rollups/containers/Rollups/Rollups.tsx
+++ b/public/pages/Rollups/containers/Rollups/Rollups.tsx
@@ -346,14 +346,14 @@ export default class Rollups extends Component {
),
},
{
- 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,
@@ -378,7 +378,7 @@ export default class Rollups extends Component {
{
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),
@@ -386,7 +386,7 @@ export default class Rollups extends Component {
{
field: "metadata",
name: "Rollup job status",
- sortable: true,
+ sortable: false,
textOnly: true,
render: (metadata) => renderStatus(metadata),
},
diff --git a/public/pages/Rollups/containers/Rollups/__snapshots__/Rollups.test.tsx.snap b/public/pages/Rollups/containers/Rollups/__snapshots__/Rollups.test.tsx.snap
index 916f3d15b..be63148fb 100644
--- a/public/pages/Rollups/containers/Rollups/__snapshots__/Rollups.test.tsx.snap
+++ b/public/pages/Rollups/containers/Rollups/__snapshots__/Rollups.test.tsx.snap
@@ -261,14 +261,14 @@ exports[` spec renders the component 1`] = `
diff --git a/public/pages/Rollups/utils/constants.tsx b/public/pages/Rollups/utils/constants.tsx
index 9776ae112..222d0aff6 100644
--- a/public/pages/Rollups/utils/constants.tsx
+++ b/public/pages/Rollups/utils/constants.tsx
@@ -21,6 +21,6 @@ export const DEFAULT_QUERY_PARAMS = {
from: 0,
size: 20,
search: "",
- sortField: "name",
+ sortField: "_id",
sortDirection: SortDirection.DESC,
};
diff --git a/server/clusters/ism/ismPlugin.ts b/server/clusters/ism/ismPlugin.ts
index 2d942308c..27ae08af7 100644
--- a/server/clusters/ism/ismPlugin.ts
+++ b/server/clusters/ism/ismPlugin.ts
@@ -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",
});
diff --git a/server/services/RollupService.ts b/server/services/RollupService.ts
index 9f94cd358..b5d59840f 100644
--- a/server/services/RollupService.ts
+++ b/server/services/RollupService.ts
@@ -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,
};