Skip to content

Commit

Permalink
Updates to github action workflows and some bug fix after upgrading t…
Browse files Browse the repository at this point in the history
…o Kibana 7.10 (opensearch-project#139)

- Upgrade `cypress` to 5.6.0, `cypress-io/github-action` to @v2 to avoid set environment variable errors. 

- Changes in workflow files to get Kibana version from `kibana.json` instead of `package.json`. This is a change due to where the Kibana version is defined after upgrading to Kibana 7.10.

- Update the `getRollups` API to prevent error getting metadata when there are no rollup jobs present. 

- Add a `null` check in `ApplyPolicyModal` since sometimes `this.context` is found to be `null` before adding toast notification. So far this did not occurred in other parts adding toast notification.
  • Loading branch information
annie3431 authored Dec 9, 2020
1 parent cb13446 commit f0d27c0
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 22 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/cypress-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Get Kibana version
id: kibana_version
run: |
echo "::set-output name=kibana_version::$(node -p "(require('./index-management-kibana-plugin/package.json').kibana.version).match(/[.0-9]+/)[0]")"
echo "::set-output name=kibana_version::$(node -p "(require('./index-management-kibana-plugin/kibana.json').kibanaVersion).match(/[.0-9]+/)[0]")"
- name: Checkout Kibana
uses: actions/checkout@v2
with:
Expand Down Expand Up @@ -69,16 +69,17 @@ jobs:
yarn kbn bootstrap
- name: Run kibana server
run: |
cd kibana/plugins/index-management-kibana-plugin
cd kibana
yarn start --no-base-path --no-watch &
sleep 300
# timeout 300 bash -c 'while [[ "$(curl -s localhost:5601/api/status | jq -r '.status.overall.state')" != "green" ]]; do sleep 5; done'
# for now just chrome, use matrix to do all browsers later
- name: Cypress tests
uses: cypress-io/github-action@v1
uses: cypress-io/github-action@v2
with:
working-directory: kibana/plugins/index-management-kibana-plugin
command: yarn run cypress run
wait-on: 'http://localhost:5601'
browser: chrome
# Screenshots are only captured on failure, will change this once we do visual regression tests
- uses: actions/upload-artifact@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Get Kibana version
id: kibana_version
run: |
echo "::set-output name=kibana_version::$(node -p "(require('./index-management-kibana-plugin/package.json').kibana.version).match(/[.0-9]+/)[0]")"
echo "::set-output name=kibana_version::$(node -p "(require('./index-management-kibana-plugin/kibana.json').kibanaVersion).match(/[.0-9]+/)[0]")"
- name: Checkout Kibana
uses: actions/checkout@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Get Kibana version
id: kibana_version
run: |
echo "::set-output name=kibana_version::$(node -p "(require('./index-management-kibana-plugin/package.json').kibana.version).match(/[.0-9]+/)[0]")"
echo "::set-output name=kibana_version::$(node -p "(require('./index-management-kibana-plugin/kibana.json').kibanaVersion).match(/[.0-9]+/)[0]")"
- name: Checkout Kibana
uses: actions/checkout@v2
with:
Expand Down
5 changes: 4 additions & 1 deletion cypress/integration/indices_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ describe("Indices", () => {
// Click apply policy button
cy.get(`[data-test-subj="Apply policyButton"]`).click({ force: true });

cy.get(`input[data-test-subj="comboBoxSearchInput"]`).focus().type(POLICY_ID, { parseSpecialCharSequences: false, delay: 1 });
cy.get(`input[data-test-subj="comboBoxSearchInput"]`).focus().type(POLICY_ID, {
parseSpecialCharSequences: false,
delay: 1,
});

// Click the policy option
cy.get(`button[role="option"]`).first().click({ force: true });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export default class ApplyPolicyModal extends Component<ApplyPolicyModalProps, A
}
}
} catch (err) {
this.context.notifications.toasts.addDanger(err.message);
if (this.context != null) this.context.notifications.toasts.addDanger(err.message);
}

this.setState({ isLoading: false });
Expand Down
36 changes: 21 additions & 15 deletions server/services/RollupService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,21 +361,27 @@ export default class RollupService {
rollup: hit._source,
metadata: null,
}));
const ids = rollups.map((rollup) => rollup._id).join(",");
const explainResponse = await this.explainRollup(context, request, response, ids);
if (explainResponse.payload.ok) {
rollups.map((item) => {
item.metadata = explainResponse.payload.response[item._id];
});
return response.custom({
statusCode: 200,
body: { ok: true, response: { rollups: rollups, totalRollups: totalRollups, metadata: explainResponse } },
});
} else
return response.custom({
statusCode: 200,
body: { ok: false, error: explainResponse.payload.error },
});
if (totalRollups) {
const ids = rollups.map((rollup) => rollup._id).join(",");
const explainResponse = await this.explainRollup(context, request, response, ids);
if (explainResponse.payload.ok) {
rollups.map((item) => {
item.metadata = explainResponse.payload.response[item._id];
});
return response.custom({
statusCode: 200,
body: { ok: true, response: { rollups: rollups, totalRollups: totalRollups, metadata: explainResponse } },
});
} else
return response.custom({
statusCode: 200,
body: { ok: false, error: explainResponse.payload.error },
});
}
return response.custom({
statusCode: 200,
body: { ok: true, response: { rollups: rollups, totalRollups: totalRollups, metadata: {} } },
});
} catch (err) {
if (err.statusCode === 404 && err.body.error.type === "index_not_found_exception") {
return response.custom({
Expand Down

0 comments on commit f0d27c0

Please sign in to comment.