Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Rename] kbn-es to osd-opensearch #79

Merged
merged 1 commit into from
Mar 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 0 additions & 62 deletions packages/kbn-es/README.md

This file was deleted.

62 changes: 62 additions & 0 deletions packages/osd-opensearch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# @osd/opensearch

> A command line utility for running opensearch from source or archive.

## Getting started
If running opensearch from source, opensearch needs to be cloned to a sibling directory of OpenSearch Dashboards.

To run, go to the OpenSearch Dashboards root and run `node scripts/opensearch --help` to get the latest command line options.

### Examples

Run a snapshot install with a trial license
```
node scripts/opensearch snapshot --license=trial
```

Run from source with a configured data directory
```
node scripts/opensearch source --Epath.data=/home/me/opensearch_data
```

## API

### run
Start a cluster
```
var opensearch = require('@osd/opensearch');
opensearch.run({
license: 'basic',
version: 7.0,
})
.catch(function (e) {
console.error(e);
process.exitCode = 1;
});
```

#### Options

##### options.license

Type: `String`

License type, one of: trial, basic, gold, platinum

##### options.version

Type: `String`

Desired opensearch version

##### options['source-path']

Type: `String`

Cloned location of opensearch repository, used when running from source

##### options['base-path']

Type: `String`

Location where snapshots are cached
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"name": "@kbn/es",
"name": "@osd/opensearch",
"main": "./target/index.js",
"version": "1.0.0",
"license": "Apache-2.0",
"private": true,
"kibana": {
"opensearchDashboards": {
"devOnly": true
},
"scripts": {
"kbn:bootstrap": "node scripts/build",
"kbn:watch": "node scripts/build --watch"
"osd:bootstrap": "node scripts/build",
"osd:watch": "node scripts/build --watch"
},
"dependencies": {
"@elastic/elasticsearch": "7.10.0-rc.1",
"@kbn/dev-utils": "1.0.0",
"@osd/dev-utils": "1.0.0",
"abort-controller": "^3.0.0",
"chalk": "^4.1.0",
"dedent": "^0.7.0",
Expand All @@ -28,7 +28,7 @@
"yauzl": "^2.10.0"
},
"devDependencies": {
"@kbn/babel-preset": "1.0.0",
"@osd/babel-preset": "1.0.0",
"@babel/cli": "^7.10.5",
"del": "^5.1.0"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ const { createHash } = require('crypto');
const path = require('path');

const asyncPipeline = promisify(pipeline);
const DAILY_SNAPSHOTS_BASE_URL = 'https://storage.googleapis.com/kibana-ci-es-snapshots-daily';
const DAILY_SNAPSHOTS_BASE_URL = 'https://storage.googleapis.com/opensearch-dashboards-ci-opensearch-snapshots-daily';
const PERMANENT_SNAPSHOTS_BASE_URL =
'https://storage.googleapis.com/kibana-ci-es-snapshots-permanent';
'https://storage.googleapis.com/opensearch-dashboards-ci-opensearch-snapshots-permanent';

const { cache } = require('./utils');
const { resolveCustomSnapshotUrl } = require('./custom_snapshots');
Expand Down Expand Up @@ -71,7 +71,7 @@ async function retry(log, fn) {

// Setting this flag provides an easy way to run the latest un-promoted snapshot without having to look it up
function shouldUseUnverifiedSnapshot() {
return !!process.env.KBN_ES_SNAPSHOT_USE_UNVERIFIED;
return !!process.env.OSD_OPENSEARCH_SNAPSHOT_USE_UNVERIFIED;
}

async function fetchSnapshotManifest(url, log) {
Expand All @@ -88,7 +88,7 @@ async function getArtifactSpecForSnapshot(urlVersion, license, log) {
const desiredVersion = urlVersion.replace('-SNAPSHOT', '');
const desiredLicense = license === 'oss' ? 'oss' : 'default';

const customManifestUrl = process.env.ES_SNAPSHOT_MANIFEST;
const customManifestUrl = process.env.OPENSEARCH_SNAPSHOT_MANIFEST;
const primaryManifestUrl = `${DAILY_SNAPSHOTS_BASE_URL}/${desiredVersion}/manifest-latest${
shouldUseUnverifiedSnapshot() ? '' : '-verified'
}.json`;
Expand Down Expand Up @@ -161,7 +161,7 @@ exports.Artifact = class Artifact {
}

/**
* Fetch an Artifact from the Elasticsearch past releases url
* Fetch an Artifact from the OpenSearch past releases url
* @param {string} url
* @param {ToolingLog} log
*/
Expand Down Expand Up @@ -261,7 +261,7 @@ exports.Artifact = class Artifact {
if (!resp.ok) {
abc.abort();
throw new Error(
`Unable to download elasticsearch snapshot: ${resp.statusText}${headersToString(
`Unable to download opensearch snapshot: ${resp.statusText}${headersToString(
resp.headers,
' '
)}`
Expand Down Expand Up @@ -323,7 +323,7 @@ exports.Artifact = class Artifact {
if (!resp.ok) {
abc.abort();
throw new Error(
`Unable to download elasticsearch checksum: ${resp.statusText}${headersToString(
`Unable to download opensearch checksum: ${resp.statusText}${headersToString(
resp.headers,
' '
)}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { ToolingLog } from '@kbn/dev-utils';
import { ToolingLog } from '@osd/dev-utils';
jest.mock('node-fetch');
import fetch from 'node-fetch';
const { Response } = jest.requireActual('node-fetch');
Expand All @@ -33,9 +33,9 @@ const MOCK_VERSION = 'test-version';
const MOCK_URL = 'http://127.0.0.1:12345';
const MOCK_FILENAME = 'test-filename';

const DAILY_SNAPSHOT_BASE_URL = 'https://storage.googleapis.com/kibana-ci-es-snapshots-daily';
const DAILY_SNAPSHOT_BASE_URL = 'https://storage.googleapis.com/opensearch-dashboards-ci-opensearch-snapshots-daily';
const PERMANENT_SNAPSHOT_BASE_URL =
'https://storage.googleapis.com/kibana-ci-es-snapshots-permanent';
'https://storage.googleapis.com/opensearch-dashboards-ci-opensearch-snapshots-permanent';

const createArchive = (params = {}) => {
const license = params.license || 'default';
Expand All @@ -56,7 +56,7 @@ const mockFetch = (mock) =>
fetch.mockReturnValue(Promise.resolve(new Response(JSON.stringify(mock))));

const previousEnvVars = {};
const ENV_VARS_TO_RESET = ['ES_SNAPSHOT_MANIFEST', 'KBN_ES_SNAPSHOT_USE_UNVERIFIED'];
const ENV_VARS_TO_RESET = ['OPENSEARCH_SNAPSHOT_MANIFEST', 'OSD_OPENSEARCH_SNAPSHOT_USE_UNVERIFIED'];

beforeAll(() => {
ENV_VARS_TO_RESET.forEach((key) => {
Expand Down Expand Up @@ -177,7 +177,7 @@ describe('Artifact', () => {
const CUSTOM_URL = 'http://www.creedthoughts.gov.www/creedthoughts';

beforeEach(() => {
process.env.ES_SNAPSHOT_MANIFEST = CUSTOM_URL;
process.env.OPENSEARCH_SNAPSHOT_MANIFEST = CUSTOM_URL;
mockFetch(MOCKS.valid);
});

Expand All @@ -187,13 +187,13 @@ describe('Artifact', () => {
});

afterEach(() => {
delete process.env.ES_SNAPSHOT_MANIFEST;
delete process.env.OPENSEARCH_SNAPSHOT_MANIFEST;
});
});

describe('with latest unverified snapshot', () => {
beforeEach(() => {
process.env.KBN_ES_SNAPSHOT_USE_UNVERIFIED = 1;
process.env.OSD_OPENSEARCH_SNAPSHOT_USE_UNVERIFIED = 1;
mockFetch(MOCKS.valid);
});

Expand All @@ -205,7 +205,7 @@ describe('Artifact', () => {
});

afterEach(() => {
delete process.env.KBN_ES_SNAPSHOT_USE_UNVERIFIED;
delete process.env.OSD_OPENSEARCH_SNAPSHOT_USE_UNVERIFIED;
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ function help() {
);

console.log(dedent`
usage: es <command> [<args>]
usage: opensearch <command> [<args>]

Assists with running Elasticsearch for Kibana development
Assists with running OpenSearch for Opensearch Dashboards development

Available commands:

Expand Down Expand Up @@ -65,14 +65,14 @@ exports.run = async (defaults = {}) => {
const command = commands[commandName];

if (command === undefined) {
log.error(chalk.red(`[${commandName}] is not a valid command, see 'es --help'`));
log.error(chalk.red(`[${commandName}] is not a valid command, see 'opensearch --help'`));
process.exitCode = 1;
return;
}

if (commandName && options.help) {
log.write(dedent`
usage: ${command.usage || `es ${commandName} [<args>]`}
usage: ${command.usage || `opensearch ${commandName} [<args>]`}

${command.description}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ const getopts = require('getopts');
const { Cluster } = require('../cluster');
const { createCliError } = require('../errors');

exports.description = 'Install and run from an Elasticsearch tar';
exports.description = 'Install and run from an OpenSearch tar';

exports.usage = 'es archive <path> [<args>]';
exports.usage = 'opensearch archive <path> [<args>]';

exports.help = (defaults = {}) => {
const { password = 'changeme', 'base-path': basePath } = defaults;
Expand All @@ -34,14 +34,14 @@ exports.help = (defaults = {}) => {

--base-path Path containing cache/installations [default: ${basePath}]
--install-path Installation path, defaults to 'source' within base-path
--password Sets password for elastic user [default: ${password}]
--password Sets password for opensearch user [default: ${password}]
--password.[user] Sets password for native realm user [default: ${password}]
--ssl Sets up SSL on Elasticsearch
-E Additional key=value settings to pass to Elasticsearch
--ssl Sets up SSL on OpenSearch
-E Additional key=value settings to pass to OpenSearch

Example:

es archive ../elasticsearch.tar.gz -E cluster.name=test -E path.data=/tmp/es-data
opensearch archive ../opensearch.tar.gz -E cluster.name=test -E path.data=/tmp/opensearch-data
`;
};

Expand All @@ -51,7 +51,7 @@ exports.run = async (defaults = {}) => {
alias: {
basePath: 'base-path',
installPath: 'install-path',
esArgs: 'E',
opensearchArgs: 'E',
},

default: defaults,
Expand All @@ -61,7 +61,7 @@ exports.run = async (defaults = {}) => {
const [, path] = options._;

if (!path || !path.endsWith('tar.gz')) {
throw createCliError('you must provide a path to an ES tar file');
throw createCliError('you must provide a path to an OpenSearcch tar file');
}

const { installPath } = await cluster.installArchive(path, options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const { buildSnapshot, log } = require('../utils');

const pipelineAsync = promisify(pipeline);

exports.description = 'Build and collect ES snapshots';
exports.description = 'Build and collect OpenSearch snapshots';

exports.help = () => ``;

Expand All @@ -42,7 +42,7 @@ exports.run = async (defaults = {}) => {
},
default: {
...defaults,
output: 'es_snapshots',
output: 'opensearch_snapshots',
},
});

Expand Down
Loading