-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
195 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export const DISABLE_PROXY = { | ||
env: { http_proxy: undefined, https_proxy: undefined, all_proxy: undefined }, | ||
}; | ||
export const ARTIFACTS = { | ||
ES: 'https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch', | ||
OS: 'https://artifacts.opensearch.org/releases/bundle/opensearch', | ||
ZINC: 'https://github.com/zinclabs/zinc/releases/download', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
import { startEngine, stopEngine, EngineType, EngineOptions } from './engine'; | ||
import path from 'path'; | ||
|
||
const globalSetup = startEngine; | ||
const globalSetup = async () => { | ||
const configPath = | ||
process.env.JEST_ELASTICSEARCH_CONFIG || path.resolve(__dirname + '/../jest-search-config.js'); | ||
const config = (await import(configPath))(); | ||
await startEngine(config); | ||
}; | ||
const globalTeardown = stopEngine; | ||
|
||
export { globalSetup, globalTeardown, EngineType, EngineOptions }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,66 @@ | ||
import { startEngine, stopEngine } from '../src/engine'; | ||
import { execSync } from 'child_process'; | ||
import { DISABLE_PROXY } from '../src/constants'; | ||
const indexes = [ | ||
{ | ||
name: 'books', | ||
body: { | ||
settings: { | ||
number_of_shards: '1', | ||
number_of_replicas: '1', | ||
}, | ||
mappings: { | ||
properties: { | ||
name: { | ||
type: 'text', | ||
}, | ||
author: { | ||
type: 'keyword', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
]; | ||
|
||
jest.setTimeout(10 * 60 * 1000); | ||
describe('unit test for elasticearch', () => { | ||
it('should start engine with default config', async () => { | ||
await startEngine(); | ||
const response = await execSync('curl -s "http://localhost:9200/?pretty"', { | ||
env: { http_proxy: undefined, https_proxy: undefined, all_proxy: undefined }, | ||
}); | ||
|
||
await stopEngine(); | ||
|
||
it('should start engine with default config', async () => { | ||
await startEngine(); | ||
const response = await execSync('curl -s "http://localhost:9200/?pretty"', { | ||
env: { http_proxy: undefined, https_proxy: undefined, all_proxy: undefined }, | ||
expect(JSON.parse(response.toString())).toMatchObject({ | ||
name: 'jest-search-local', | ||
cluster_name: 'jest-search-local', | ||
version: { | ||
number: '8.8.2', | ||
build_flavor: 'default', | ||
build_type: 'tar', | ||
build_snapshot: false, | ||
lucene_version: '9.6.0', | ||
minimum_wire_compatibility_version: '7.17.0', | ||
minimum_index_compatibility_version: '7.0.0', | ||
}, | ||
tagline: 'You Know, for Search', | ||
}); | ||
}); | ||
|
||
await stopEngine(); | ||
it('should start engine and create index when passing indexes', async () => { | ||
await startEngine({ indexes: [indexes[0]] }); | ||
|
||
expect(JSON.parse(response.toString())).toMatchObject({ | ||
name: 'jest-search-local', | ||
cluster_name: 'jest-search-local', | ||
version: { | ||
number: '8.8.2', | ||
build_flavor: 'default', | ||
build_type: 'tar', | ||
build_snapshot: false, | ||
lucene_version: '9.6.0', | ||
minimum_wire_compatibility_version: '7.17.0', | ||
minimum_index_compatibility_version: '7.0.0', | ||
}, | ||
tagline: 'You Know, for Search', | ||
const response = await execSync( | ||
'curl -s "http://localhost:9200/books/_mapping?pretty"', | ||
DISABLE_PROXY | ||
); | ||
|
||
await stopEngine(); | ||
|
||
expect(JSON.parse(response.toString())).toEqual({ | ||
books: { mappings: { properties: { author: { type: 'keyword' }, name: { type: 'text' } } } }, | ||
}); | ||
}); | ||
}); |