Skip to content

Commit

Permalink
Fix tests and document cleanup (#754)
Browse files Browse the repository at this point in the history
* remove unused files

* fix and rename intg. tests

* rename unit tests

* Update audit-logging.test.tsx.snap

* singular names

* Update unit-test.yml

* fix tests

* change workflow name

* Update README.md

* update step name

* use opensearch dashboards release tag
  • Loading branch information
hsiang9431-amzn authored May 4, 2021
1 parent e6ca043 commit 3aec2a2
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 211 deletions.
81 changes: 39 additions & 42 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,81 +13,78 @@ jobs:
name: Run integration tests
runs-on: ubuntu-latest
steps:
- name: Set up JDK 14
uses: actions/setup-java@v1
with:
java-version: 14

- name: Checkout Kibana
- name: Run OpenSearch with plugin
run: |
docker build -t opensearch-test:1.0.0-beta1 -<<EOF
FROM opensearchstaging/opensearch:1.0.0-beta1
RUN echo "opendistro_security.unsupported.restapi.allow_securityconfig_modification: true" >> config/opensearch.yml
RUN echo "discovery.type: single-node" >> config/opensearch.yml
ENTRYPOINT bin/opensearch
EOF
docker run -d -p 9200:9200 -p 9600:9600 -i opensearch-test:1.0.0-beta1
- name: Checkout OpenSearch Dashboard
uses: actions/checkout@v2
with:
path: kibana
repository: elastic/kibana
path: OpenSearch-Dashboards
repository: opensearch-project/OpenSearch-Dashboards
fetch-depth: 0

- name: Create plugins dir
run: |
cd ./kibana
cd ./OpenSearch-Dashboards
mkdir -p plugins
- name: Checkout security kibana plugin
- name: Checkout OpenSearch Dashboard Security plugin
uses: actions/checkout@v2
with:
path: kibana/plugins/opendistro_security
path: OpenSearch-Dashboards/plugins/security-dashboards-plugin
ref: ${{ github.ref }}

- name: Get Kibana version
id: kbn_version
run: |
echo "::set-output name=kbn_version::$(jq -r '.kibana.version' ./kibana/plugins/opendistro_security/package.json)"
- name: Get Opendistro version
id: opendistro_version
run: |
echo "::set-output name=opendistro_version::$(jq -r '.version' ./kibana/plugins/opendistro_security/package.json | sed 's/[0-9]*$/0/')"

- name: Run elasticsearch with plugin
- name: Check OpenSearch Running
continue-on-error: true
run: curl -XGET https://localhost:9200 -u 'admin:admin' -k

- name: Get OpenSearch Dashboards version
id: osd_version
run: |
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-oss-${{ steps.kbn_version.outputs.kbn_version }}-linux-x86_64.tar.gz
tar -xzf elasticsearch-oss-${{ steps.kbn_version.outputs.kbn_version }}-linux-x86_64.tar.gz
cd elasticsearch-${{ steps.kbn_version.outputs.kbn_version }}/
bin/elasticsearch-plugin install -b https://d3g5vo6xdbdb9a.cloudfront.net/downloads/elasticsearch-plugins/opendistro-security/opendistro-security-${{ steps.opendistro_version.outputs.opendistro_version }}.zip
bash plugins/opendistro_security/tools/install_demo_configuration.sh -y -i
echo 'opendistro_security.unsupported.restapi.allow_securityconfig_modification: true' >> config/elasticsearch.yml
echo $(curl -s -o /dev/null -w ''%{http_code}'' https://localhost:9200 -u admin:admin -k)
bin/elasticsearch &
sleep 30
timeout 900 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' https://localhost:9200 -u admin:admin -k)" != "200" ]]; do echo "ping ElasticSearch..."; sleep 5; done'
echo "::set-output name=osd_version::$(jq -r '.opensearchDashboards.version' ./OpenSearch-Dashboards/plugins/security-dashboards-plugin/package.json)"
- name: Use kibana release commit
- name: Check OpenSearch Dashboards release tag
run: |
cd ./kibana
git checkout tags/v${{ steps.kbn_version.outputs.kbn_version }} -b v${{ steps.kbn_version.outputs.kbn_version }}
cd ./OpenSearch-Dashboards
git checkout tags/${{ steps.osd_version.outputs.osd_version }} -b v${{ steps.osd_version.outputs.osd_version }}
- name: Get node and yarn versions
id: versions
run: |
echo "::set-output name=node_version::$(cat ./kibana/.node-version)"
echo "::set-output name=yarn_version::$(jq -r '.engines.yarn' ./kibana/package.json)"
echo "::set-output name=node_version::$(cat ./OpenSearch-Dashboards/.node-version)"
echo "::set-output name=yarn_version::$(jq -r '.engines.yarn' ./OpenSearch-Dashboards/package.json)"
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: ${{ steps.versions.outputs.node_version }}
registry-url: 'https://registry.npmjs.org'

- name: Install correct yarn version for Kibana
- name: Install correct yarn version for OpenSearch Dashboards
run: |
npm uninstall -g yarn
echo "Installing yarn ${{ steps.versions_step.outputs.yarn_version }}"
npm i -g yarn@${{ steps.versions.outputs.yarn_version }}
- name: Bootstrap Kibana
- name: Check OpenSearch Running
continue-on-error: true
run: curl -XGET https://localhost:9200 -u 'admin:admin' -k

- name: Bootstrap OpenSearch Dashboards
run: |
cd ./kibana
yarn kbn bootstrap --oss
cd ./OpenSearch-Dashboards
yarn osd bootstrap
- name: Run integration tests
run: |
cd ./kibana/plugins/opendistro_security
echo "check if elasticsearch is ready"
curl -XGET https://localhost:9200 -u 'admin:admin' -k
cd ./OpenSearch-Dashboards/plugins/security-dashboards-plugin
yarn test:jest_server --coverage
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml → .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: Unit Tests

on:
pull_request:
Expand All @@ -10,7 +10,8 @@ on:
- main

jobs:
build:
tests:
name: Run unit tests
runs-on: ubuntu-latest

steps:
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[![CI](https://github.com/opensearch-project/security-dashboards-plugin/workflows/CI/badge.svg?branch=main)](https://github.com/opensearch-project/security-dashboards-plugin/actions)
[![Unit tests](https://github.com/opensearch-project/security-dashboards-plugin/workflows/Unit%20Tests/badge.svg?branch=main)](https://github.com/opensearch-project/security-dashboards-plugin/actions)
[![Integration tests](https://github.com/opensearch-project/security-dashboards-plugin/workflows/Integration%20Tests/badge.svg?branch=main)](https://github.com/opensearch-project/security-dashboards-plugin/actions)
[![codecov](https://codecov.io/gh/opensearch-project/security-dashboards-plugin/branch/main/graphs/badge.svg)](https://github.com/opensearch-project/security-dashboards-plugin)

# OpenSearch-Dashboards Security Plugin
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.0.0.0-beta1",
"main": "target/plugins/opensearch_security_dashboards",
"opensearchDashboards": {
"version": "1.0.0",
"version": "1.0.0-beta1",
"templateVersion": "1.0.0"
},
"license": "Apache-2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,15 +273,15 @@ exports[`Audit logs render when AuditLoggingSettings.enabled is true 1`] = `
grow={false}
>
<FormattedMessage
defaultMessage="Configure the output location and storage types in {elasticsearchCode}. The default storage location is {internalElasticsearchCode}, which stores the logs in an index on this cluster."
defaultMessage="Configure the output location and storage types in {opensearchCode}. The default storage location is {internalOpenSearchCode}, which stores the logs in an index on this cluster."
id="audit.logs.storageInstruction"
values={
Object {
"elasticsearchCode": <EuiCode>
elasticsearch.yml
"internalOpenSearchCode": <EuiCode>
internal_opensearch
</EuiCode>,
"internalElasticsearchCode": <EuiCode>
internal_elasticsearch
"opensearchCode": <EuiCode>
opensearch.yml
</EuiCode>,
}
}
Expand Down
136 changes: 0 additions & 136 deletions test/es/elasticsearch_helper.ts

This file was deleted.

20 changes: 0 additions & 20 deletions test/es/setup_es.js

This file was deleted.

4 changes: 2 additions & 2 deletions test/jest_integration/basic_auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('start OpenSearch Dashboards server', () => {
username: OPENSEARCH_DASHBOARDS_SERVER_USER,
password: OPENSEARCH_DASHBOARDS_SERVER_PASSWORD,
},
opendistro_security: {
opensearch_security: {
auth: {
anonymous_auth_enabled: true,
},
Expand All @@ -70,7 +70,7 @@ describe('start OpenSearch Dashboards server', () => {
username: OPENSEARCH_DASHBOARDS_SERVER_USER,
password: OPENSEARCH_DASHBOARDS_SERVER_PASSWORD,
},
opendistro_security: {
opensearch_security: {
auth: {
anonymous_auth_enabled: false,
},
Expand Down
2 changes: 1 addition & 1 deletion test/jest_integration/multi_tenancy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('start OpenSearch Dashboards server', () => {
username: OPENSEARCH_DASHBOARDS_SERVER_USER,
password: OPENSEARCH_DASHBOARDS_SERVER_PASSWORD,
},
opendistro_security: {
opensearch_security: {
multitenancy: { enabled: true, tenants: { preferred: ['Private', 'Global'] } },
},
},
Expand Down
2 changes: 1 addition & 1 deletion test/jest_integration/security_entity_api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('start OpenSearch Dashboards server', () => {
username: OPENSEARCH_DASHBOARDS_SERVER_USER,
password: OPENSEARCH_DASHBOARDS_SERVER_PASSWORD,
},
opendistro_security: {
opensearch_security: {
multitenancy: { enabled: true, tenants: { preferred: ['Private', 'Global'] } },
},
},
Expand Down

0 comments on commit 3aec2a2

Please sign in to comment.