Skip to content
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
13 changes: 11 additions & 2 deletions .github/workflows/feature.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,29 @@ on:
branches: [master]

jobs:
build:
featureTests:
name: FeatureTests
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x, 16.x, 18.x]
node-version: [18.x, 20.x, 22.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: Create database for tests
run: docker compose -f ./elastic-feature-tests.yml up -d

- name: Install dependencies
run: npm install

- name: Build
run: npm run build

- name: Run Cucumber Tests
run: npm run test:features
31 changes: 31 additions & 0 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Quality

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
quality:
name: Quality
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [22.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm install

- name: Prettier
run: npm run prettier:check

- name: Eslint
run: npm run eslint
7 changes: 4 additions & 3 deletions .github/workflows/ut.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ on:
branches: [master]

jobs:
build:
tests:
name: Tests
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x, 16.x, 18.x]
node-version: [18.x, 20.x, 22.x]

steps:
- uses: actions/checkout@v2
Expand All @@ -24,7 +25,7 @@ jobs:
run: npm install
- name: Run Unit Tests
run: npm test
- run: npm run coverage
- run: npm run test:coverage

- name: Coveralls
uses: coverallsapp/github-action@master
Expand Down
39 changes: 35 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,41 @@
![Unit Tests](https://github.com/monolithst/functional-models-orm-elastic/actions/workflows/ut.yml/badge.svg?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/monolithst/functional-models-orm-elastic/badge.svg?branch=master)](https://coveralls.io/github/monolithst/functional-models-orm-elastic?branch=master)

## Run Feature Tests
# How To Install

To run the feature tests, you need to set up an actual Elasticsearch cluster within AWS and then call cucumber like the following:
`npm install functional-models-orm-elastic`

`npm run feature-tests -- --world-parameters '{"elasticUsername":"USERNAME", "elasticPassword":"PASSWORD", "cloudId": "CLOUD_ID"}'`
# How To Use

IMPORTANT WORD OF CAUTION: I would not attempt to use this database for anything other than this feature tests, as the indexes are completely deleted without remorse.
```typescript
import { createOrm } from 'functional-models'
import { datastoreAdapter as elasticDatastore } from 'functional-models-orm-elastic'
import { Client } from '@opensearch-project/opensearch'

// Create your client.
const client = new Client({
node: 'http://localhost:9200',
})

// Create datastoreAdapter
const datastoreAdapter = elasticDatastore.create({
client,
})

// Create an orm for use with your models.
const orm = createOrm({ datastoreAdapter })
```

### Notes on Running with AWS OpenSearch

One way to use the client is with a username/password and the elastic url.

Here is an example:

```javascript
const url = `https://${elasticUsername}:${elasticPassword}@${elasticUrl}`

const client = new Client({
node: url,
})
```
20 changes: 20 additions & 0 deletions elastic-feature-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: '3.1'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.17.1
container_name: functional-models-orm-elastic-feature-tests
environment:
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- 'ES_JAVA_OPTS=-Xms512m -Xmx512m'
- xpack.security.enabled=false
- xpack.security.enrollment.enabled=false
- discovery.type=single-node
ulimits:
memlock:
soft: -1
hard: -1
#volumes:
# - esdata1:/usr/share/elasticsearch/data
ports:
- 5121:9200
Loading