Skip to content

Commit

Permalink
Merge branch 'opensearch-project:main' into shorten-import-statements
Browse files Browse the repository at this point in the history
  • Loading branch information
waynehamadi authored Oct 10, 2021
2 parents dfaa3c6 + e4c40db commit 0faf364
Show file tree
Hide file tree
Showing 56 changed files with 1,504 additions and 184 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.git
Dockerfile
node_modules
packages/
18 changes: 18 additions & 0 deletions .github/workflows/dco.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Developer Certificate of Origin Check

on: [pull_request]

jobs:
check:
runs-on: ubuntu-latest

steps:
- name: Get PR Commits
id: 'get-pr-commits'
uses: tim-actions/get-pr-commits@v1.1.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: DCO Check
uses: tim-actions/dco@v1.1.0
with:
commits: ${{ steps.get-pr-commits.outputs.commits }}
83 changes: 78 additions & 5 deletions DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,94 @@
# OpenSearch Dashboards Developer Guide
<p align="center"><img src="https://opensearch.org/assets/brand/SVG/Logo/opensearch_logo_darkmode.svg" height="64px"/></p>
<h1 align="center">OpenSearch Dashboards Developer Guide</h1>

This guide applies to all development within the OpenSearch Dashboards project and is
recommended for the development of all OpenSearch Dashboards plugins.
This guide applies to all development within the OpenSearch Dashboards project and is recommended for the development of all OpenSearch Dashboards plugins.

- [Getting Started](#getting-started)
- [General](#general)
- [HTML](#html)
- [API endpoints](#api-endpoints)
- [TypeScript/JavaScript](#typeScript/javaScript)
- [SASS files](#sass-files)
- [React](#react)

Besides the content in this developer guide, the following developer guides may also apply
to all development within the OpenSearch Dashboards project. Please make sure to also read them:
Besides the content in this developer guide, the following developer guides may also apply to all development within the OpenSearch Dashboards project. Please make sure to also read them:

- [Accessibility developer guide (EUI Docs)](https://elastic.github.io/eui/#/guidelines/accessibility)
- [SASS developer guide (EUI Docs)](https://elastic.github.io/eui/#/guidelines/sass)

## Getting Started

If you would like to install and run this project, please see the [Downloads Page](https://opensearch.org/downloads.html).

#### Prerequisites

You need to have an OpenSearch server up and running to be able to run OpenSearch
Dashboards. The easiest way to do it is [using Docker](https://opensearch.org/docs/opensearch/install/docker).

We recommend using [Node Version Manager](https://github.com/nvm-sh/nvm) to install
the node version we need.

### Bootstrap OpenSearch Dashboards

While OpenSearch is starting, you can already bootstrap OpenSearch Dashboards:
```bash
$ git clone https://github.com/opensearch-project/OpenSearch-Dashboards.git
$ cd OpenSearch-Dashboards
$ nvm use
$ npm i -g yarn
$ yarn osd bootstrap # This command will also install npm dependencies
```

### Configure OpenSearch Dashboards

*This step is only mandatory if you have https/authentication enabled, or if you use the OpenSearch Docker image in its default configuration.*

Once the bootstrap of OpenSearch Dashboards is finished, you need to apply some
changes to `opensearch_dashboards.yml` in order to connect to OpenSearch.

```yml
opensearch.hosts: ["https://localhost:9200"]
opensearch.username: "admin" # Default username on the docker image
opensearch.password: "admin" # Default password on the docker image
opensearch.ssl.verificationMode: none
```
### Run OpenSearch Dashboards
After you've installed OpenSearch Dashboards and configured it, you can start
the development server:
```bash
$ yarn start
```

When the server is up and ready, click on the link displayed in your terminal to
access it.

### Building the artifacts

To build the artifacts for all supported platforms, run the following:

```
yarn build --skip-os-packages
```

If you want to build a specific platform, pass the platform flag after `yarn build-platform`. For example, to build darwin x64, run the following:

```
yarn build-platform --darwin
```

You could pass one or multiple flags. If you don't pass any flag, `yarn build-platform` will use your local environment. Currenly we only support `darwin` (darwin x64), `linux` (linux x64) and `linux-arm` (linux arm64).

### Building the Docker Image

To build the Docker image, run the following:

```
yarn osd bootstrap
yarn build --docker
```

## General

### Filenames
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

OpenSearch Dashboards is an open source search and analytics visualization. We aim to to be the best community-driven platform and provide all the contributors a great open source experience.

Feel free to take a look at what the community has been up to, and then head over to the [Project Board](https://github.com/opensearch-project/OpenSearch-Dashboards/projects) to track release targets, or jump in and [start opening issues](https://github.com/opensearch-project/OpenSearch-Dashboards/issues/new/choose) or [contributing](https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/CONTRIBUTING.md).
Feel free to take a look at what the community has been up to, and then head over to the [Project Board](https://github.com/opensearch-project/OpenSearch-Dashboards/projects) to track release targets, or jump in and [start opening issues](https://github.com/opensearch-project/OpenSearch-Dashboards/issues/new/choose), [set up your development environment](DEVELOPER_GUIDE.md#getting-started), or [start contributing](CONTRIBUTING.md).

## Project Resources

Expand All @@ -19,10 +19,10 @@ Feel free to take a look at what the community has been up to, and then head ove
* [Documentation](https://opensearch.org/docs/)
* Need help? Try [Forums](https://discuss.opendistrocommunity.dev/)
* [Project Principles](https://opensearch.org/#principles)
* [Developer Guide](DEVELOPER_GUIDE.md)
* [Contributing to OpenSearch](CONTRIBUTING.md)
* [Maintainer Responsibilities](MAINTAINERS.md)
* [Release Management](RELEASING.md)
* [Admin Responsibilities](ADMINS.md)
* [Testing](TESTING.md)
* [Security](SECURITY.md)

Expand All @@ -36,4 +36,4 @@ This project is licensed under the [Apache v2.0 License](LICENSE.txt).

## Copyright

Copyright 2020-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Copyright OpenSearch Contributors. See [NOTICE](NOTICE.txt) for details.
3 changes: 3 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Reporting a Vulnerability

If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/) or directly via email to aws-security@amazon.com. Please do **not** create a public GitHub issue.
68 changes: 68 additions & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
Overview
---
- [General information](#general-information)
- [Requirements](#requirements)
- [Running tests](#running-tests)
- [Unit tests](#unit-tests)
- [Integration tests](#integration-tests)
- [Functional tests](#functional-tests)
- [Continuous Integration](#continuous-integration)
- [Environment misc](#environment-misc)
- [Misc](#misc)

# General information
OpenSearch Dashboards uses [Jest](https://jestjs.io/) for unit and integration tests and [Selenium](https://www.selenium.dev/) for functional tests.

In general, we recommend three tiers of tests:
* Unit tests: Unit tests: small and modular tests that utilize mocks for external dependencies.
* Integration tests: higher-level tests that verify interactions between systems (eg. HTTP APIs, OpenSearch API calls, calling other plugin).
* End-to-end tests (e2e): functional tests that verify behavior in a web browser.

# Requirements
* Install the latest NodeJS, [NPM](https://www.npmjs.com/get-npm) and [Yarn](https://classic.yarnpkg.com/en/docs/install/#mac-stable)
* `nvm install v10.24.1`
* `npm install -g yarn`

# Running tests
The following is a cheatsheet of options for running the tests for OpenSearch Dashboards.

### Unit tests
To run all the unit tests:
`yarn test:jest`
To run specific unit tests, pass the path to the test:
`yarn test:jest [test path]`

### Integration tests
To run all the integration tests:
`yarn test:jest_integration`
To run specific integration tests, pass the path to the test:
`yarn test:jest_integration [test path]`

### Functional tests
To run all functional tests:
`yarn test:ftr`
To run specific functional tests, you can run by CI group:
`node scripts/functional_tests.js --include ciGroup1`

To debug functional tests:
Say that you would want to debug a test in CI group 1, you can run the following command in your environment:
`node --debug-brk --inspect scripts/functional_tests.js --config test/functional/config.js --include ciGroup1 --debug`

This will print of an address, to which you could open your chrome browser on your instance and navigate to `chrome://inspect/#devices` and inspect the functional test runner `scripts/functional_tests.js`.

# Continuous Integration
Automated testing is provided with Jenkins for Continuous Integration. Jenkins enables developers to build, deploy, and automate projects and provides us to run groups of tests quickly. CI groups are ran from the [Jenkinsfile](https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/Jenkinsfile).

# Environment misc
Selenium tests are run in headless mode on CI. Locally the same tests will be executed in a real browser. You can activate headless mode by setting the environment variable:
`export TEST_BROWSER_HEADLESS=1`

By default the version of OpenSearch Dashboards will pull the snapshot of the same version of OpenSearch if available while running a few integration tests and for running functional tests. However, if the version of OpenSearch Dashboards is not available, you can build OpenSearch locally and point the functional test runner to the executable with:
`export TEST_OPENSEARCH_FROM=[local directory of OpenSearch executable]`

# Misc
Although Jest is the standard for this project, there are a few Mocha tests that still exist. You can run these tests by running:
`yarn test:mocha`

However, these tests will eventually be migrated. Please avoid writing new Mocha tests. For further questions or to check the status please see this [issue](https://github.com/opensearch-project/OpenSearch-Dashboards/issues/215).

11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"dashboarding"
],
"private": true,
"version": "1.0.0",
"version": "1.2.0",
"branch": "main",
"types": "./opensearch_dashboards.d.ts",
"tsdocMetadata": "./build/tsdoc-metadata.json",
Expand Down Expand Up @@ -50,6 +50,7 @@
"test:ftr:runner": "node scripts/functional_test_runner",
"test:coverage": "grunt test:coverage",
"checkLicenses": "node scripts/check_licenses --dev",
"build-platform": "node scripts/build",
"build": "node scripts/build --all-platforms",
"start": "node scripts/opensearch_dashboards --dev",
"debug": "node --nolazy --inspect scripts/opensearch_dashboards --dev",
Expand All @@ -75,11 +76,12 @@
},
"resolutions": {
"**/@types/node": ">=10.17.17 <10.20.0",
"**/axios": "^0.21.4",
"**/ejs": "^3.1.6",
"**/front-matter": "^4.0.2",
"**/glob-parent": "^6.0.0",
"**/hoist-non-react-statics": "^3.3.2",
"**/immer": "^8.0.1",
"**/immer": "^9.0.6",
"**/istanbul-instrumenter-loader/schema-utils": "^1.0.0",
"**/kind-of": ">=6.0.3",
"**/lodash": "^4.17.21",
Expand All @@ -92,6 +94,7 @@
"**/react-syntax-highlighter/**/highlight.js": "^10.4.1",
"**/request": "^2.88.2",
"**/ssri": "^6.0.2",
"**/tar": "^6.1.11",
"**/trim": "^0.0.3",
"**/trim-newlines": "^3.0.1",
"**/typescript": "4.0.2"
Expand Down Expand Up @@ -205,7 +208,7 @@
"semver": "^5.7.0",
"source-map-support": "^0.5.19",
"symbol-observable": "^1.2.0",
"tar": "4.4.13",
"tar": "^6.1.11",
"tinygradient": "0.4.3",
"tinymath": "1.2.1",
"tslib": "^2.0.0",
Expand Down Expand Up @@ -395,7 +398,7 @@
"gulp-sourcemaps": "2.6.5",
"has-ansi": "^3.0.0",
"history": "^4.9.0",
"immer": "^8.0.1",
"immer": "^9.0.6",
"intl-messageformat-parser": "^1.4.0",
"jest": "^26.4.2",
"jest-canvas-mock": "^2.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/osd-dev-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"dependencies": {
"@babel/core": "^7.11.6",
"@osd/utils": "1.0.0",
"axios": "^0.21.1",
"axios": "^0.21.4",
"chalk": "^4.1.0",
"cheerio": "0.22.0",
"dedent": "^0.7.0",
Expand Down
13 changes: 9 additions & 4 deletions packages/osd-opensearch/src/artifact.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ async function getArtifactSpecForSnapshotFromUrl(urlVersion, log) {
throw createCliError(`Snapshots are only available for Linux`);
}

const latestUrl = `${DAILY_SNAPSHOTS_BASE_URL}/${desiredVersion}`;
const latestFile = `opensearch-${desiredVersion}-SNAPSHOT-${platform}-${arch}-latest.tar.gz`;
const latestUrl = `${DAILY_SNAPSHOTS_BASE_URL}/${desiredVersion}-SNAPSHOT`;
const latestFile = `opensearch-min-${desiredVersion}-SNAPSHOT-${platform}-${arch}-latest.tar.gz`;
const completeLatestUrl = `${latestUrl}/${latestFile}`;

let { abc, resp } = await verifySnapshotUrl(completeLatestUrl, log);
Expand All @@ -208,8 +208,13 @@ async function getArtifactSpecForSnapshotFromUrl(urlVersion, log) {
let completeUrl = null;
let snapshotFile = null;

// This checks and uses an RC if a RC exists at a higher increment than RC1 or it tries to use RC1
// This is in replacement of having a manifest URL, so the exact RC number is unknown but expect it not to be a large number
/**
* TODO: This might not be relevant anymore. After a few iterations if RC builds are no longer being built
* then we can remove this logic.
*
* This checks and uses an RC if a RC exists at a higher increment than RC1 or it tries to use RC1
* This is in replacement of having a manifest URL, so the exact RC number is unknown but expect it not to be a large number
*/
let rcCheck = MAX_RC_CHECK;
do {
const secondaryLatestUrl = `${DAILY_SNAPSHOTS_BASE_URL}/${desiredVersion}-rc${rcCheck}`;
Expand Down
2 changes: 1 addition & 1 deletion packages/osd-release-notes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": {
"@osd/utils": "1.0.0",
"@osd/dev-utils": "1.0.0",
"axios": "^0.21.1",
"axios": "^0.21.4",
"cheerio": "0.22.0",
"dedent": "^0.7.0",
"graphql": "^0.13.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@
font-size: 14px;
}

.guideNav__elasticLogo {
// TODO: [RENAMEME] replacement background-image might be needed
.guideNav__opensearchLogo {
position: absolute;
background-image: url("images/elastic-logo.svg");
background-image: url("images/react-logo.svg");
width: 106px;
height: 36px;
background-repeat: no-repeat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ export class GuideNav extends Component {
</Link>
<a
href="http://opensearch.org"
className="guideNav__elasticLogo"
aria-label="Go to the Elastic website"
className="guideNav__opensearchLogo"
aria-label="Go to the OpenSearch website"
/>

{this.renderPagination()}
Expand Down
14 changes: 13 additions & 1 deletion packages/osd-ui-framework/doc_site/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,19 @@ module.exports = {
},
{
test: /\.scss$/,
loaders: ['style-loader', 'css-loader', 'postcss-loader', 'sass-loader'],
loaders: [
'style-loader',
'css-loader',
{
loader: 'postcss-loader',
options: {
config: {
path: require.resolve('@osd/optimizer/postcss.config.js'),
},
},
},
'sass-loader',
],
exclude: /node_modules/,
},
{
Expand Down
Loading

0 comments on commit 0faf364

Please sign in to comment.