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

e2e tests for s3,snowflake,supabase and ethereum #110

Merged
merged 58 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
557090d
added eth,s3,snowflake
supergi0 Sep 26, 2023
93911c2
updated ci
supergi0 Sep 28, 2023
89c9431
changed ci
supergi0 Sep 28, 2023
e2023d4
upated ci
supergi0 Sep 28, 2023
49db796
replaced ci
supergi0 Sep 28, 2023
8886ea6
1
supergi0 Sep 28, 2023
c3e8ee2
1
supergi0 Sep 28, 2023
ab18bc1
1
supergi0 Sep 28, 2023
15dc3ae
1
supergi0 Sep 28, 2023
8258e8c
1
supergi0 Sep 28, 2023
46a85a1
2
supergi0 Sep 28, 2023
c70d9b1
1
supergi0 Sep 28, 2023
4ea0f7e
2
supergi0 Sep 28, 2023
92d9c53
1
supergi0 Sep 28, 2023
42ae586
1
supergi0 Sep 28, 2023
ae8e20f
1
supergi0 Sep 28, 2023
a6046c6
1
supergi0 Sep 28, 2023
19e527b
1
supergi0 Sep 28, 2023
0568069
1
supergi0 Sep 28, 2023
97cfc3f
1
supergi0 Sep 29, 2023
958fdb4
1
supergi0 Sep 29, 2023
1807691
2
supergi0 Sep 29, 2023
5356120
1
supergi0 Sep 29, 2023
e3bfe32
1
supergi0 Sep 29, 2023
2849f89
1
supergi0 Sep 29, 2023
43d124a
2
supergi0 Sep 29, 2023
6086104
1
supergi0 Sep 29, 2023
6c12d18
1
supergi0 Sep 29, 2023
2259cc9
1
supergi0 Sep 29, 2023
71afba4
2
supergi0 Sep 29, 2023
b5179a8
2
supergi0 Sep 29, 2023
ad8851f
2
supergi0 Sep 29, 2023
943ad43
2
supergi0 Sep 29, 2023
873185d
Merge pull request #109 from supergi0/sample-tests
supergi0 Sep 29, 2023
19d0694
2
supergi0 Sep 29, 2023
b37ecb0
1
supergi0 Sep 29, 2023
543895a
2
supergi0 Sep 29, 2023
008f350
2
supergi0 Sep 29, 2023
584df64
3
supergi0 Sep 29, 2023
0814add
2
supergi0 Sep 29, 2023
5ab209d
2
supergi0 Sep 29, 2023
d67f206
3
supergi0 Sep 29, 2023
b8ff6b2
2
supergi0 Sep 29, 2023
b58fc6f
4
supergi0 Sep 29, 2023
4f7076f
4
supergi0 Sep 29, 2023
834562e
5
supergi0 Sep 29, 2023
7911604
7
supergi0 Sep 29, 2023
dd013b7
3
supergi0 Sep 30, 2023
1c63379
3
supergi0 Sep 30, 2023
664ead0
5
supergi0 Sep 30, 2023
b259d3d
4
supergi0 Sep 30, 2023
3cf3c67
5
supergi0 Sep 30, 2023
df6576c
2
supergi0 Sep 30, 2023
86512ed
3
supergi0 Sep 30, 2023
743d776
python pip added
supergi0 Oct 4, 2023
3500da6
added kafka in features
supergi0 Oct 4, 2023
27b29f8
added supabase test
supergi0 Oct 4, 2023
7f7e6e5
added supabase secrets
supergi0 Oct 4, 2023
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
103 changes: 87 additions & 16 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: CI

on:
pull_request:
branches: [main]
Expand All @@ -8,12 +9,77 @@ concurrency:
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install Protoc
uses: arduino/setup-protoc@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Rust cache
uses: swatinem/rust-cache@v2

- name: Clone Dozer
run: |
git clone http://github.com/getdozer/dozer.git

- name: Restore Dozer cache
uses: actions/cache@v3
with:
path: |
dozer/
key: ${{ runner.os }}-dozer-${{ hashFiles('**/dozer/Cargo.toml') }}
restore-keys: |
${{ runner.os }}-dozer-

- name: Build Dozer binary
run: |
cd dozer
cargo build --features ethereum,snowflake,kafka --bin dozer
mkdir -p $GITHUB_WORKSPACE/dozer-bin
cp target/debug/dozer $GITHUB_WORKSPACE/dozer-bin/dozer

- name: Archive Dozer binary
uses: actions/upload-artifact@v2
with:
name: dozer-bin-artifact
path: dozer-bin/dozer

test:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2
- name: Checkout code
uses: actions/checkout@v2

- uses: pnpm/action-setup@v2
- name: Download Dozer binary artifact
uses: actions/download-artifact@v2
with:
name: dozer-bin-artifact
path: dozer-bin

- name: Install Protoc, Snowflake ODBC Driver and Python3
run: |
curl -sLO https://github.com/protocolbuffers/protobuf/releases/download/v22.2/protoc-22.2-linux-x86_64.zip
unzip protoc-22.2-linux-x86_64.zip -d $HOME/.local
export PATH="$PATH:$HOME/.local/bin"
curl ${SNOWFLAKE_DRIVER_URL} -o snowflake_driver.deb && sudo dpkg -i snowflake_driver.deb
env:
SNOWFLAKE_DRIVER_URL: https://sfc-repo.snowflakecomputing.com/odbc/linux/2.25.7/snowflake-odbc-2.25.7.x86_64.deb

- name: Setup Dozer binary
run: |
mkdir -p $HOME/.cargo/bin
cp dozer-bin/dozer $HOME/.cargo/bin/
chmod +x $HOME/.cargo/bin/dozer

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
run_install: false
Expand All @@ -23,8 +89,8 @@ jobs:
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- uses: actions/cache@v3
name: Setup pnpm cache
- name: Restore pnpm cache
uses: actions/cache@v3
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
Expand All @@ -34,16 +100,21 @@ jobs:
- name: Install dependencies
run: pnpm install

- name: Install Dozer
run: |
# Install protoc
curl -sLO https://github.com/protocolbuffers/protobuf/releases/download/v22.2/protoc-22.2-linux-x86_64.zip
unzip protoc-22.2-linux-x86_64.zip -d $HOME/.local
export PATH="$PATH:$HOME/.local/bin"

curl -sLO https://github.com/getdozer/dozer/releases/latest/download/dozer-linux-amd64.deb
sudo dpkg -i dozer-linux-amd64.deb

- name: Run tests
run: |
pnpm test
env:
AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY }}
AWS_SECRET_KEY: ${{ secrets.AWS_SECRET_KEY }}
AWS_REGION_S3: ${{ secrets.AWS_REGION_S3 }}
AWS_BUCKET_NAME: ${{ secrets.AWS_BUCKET_NAME }}
SN_SERVER: ${{ secrets.SN_SERVER }}
SN_USER: ${{ secrets.SN_USER }}
SN_PASSWORD: ${{ secrets.SN_PASSWORD }}
SN_DATABASE: ${{ secrets.SN_DATABASE }}
SN_WAREHOUSE: ${{ secrets.SN_WAREHOUSE }}
SN_ROLE: ${{ secrets.SN_ROLE }}
ETH_WSS_URL: ${{ secrets.ETH_WSS_URL }}
PG_HOST: ${{ secrets.PG_HOST }}
PG_USER: ${{ secrets.PG_USER }}
PG_PASSWORD: ${{ secrets.PG_PASSWORD }}
PG_DB: ${{ secrets.PG_DB }}
run: pnpm test
13 changes: 6 additions & 7 deletions connectors/aws-s3/dozer-config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
app_name: aws-s3-sample
version: 1
connections:
- config : !S3Storage
- config: !S3Storage
details:
access_key_id: {{YOUR_ACCESS_KEY}}
secret_access_key: {{YOUR_SECRET_KEY}}
region: {{YOUR_REGION}}
bucket_name: {{YOUR_BUCKET_NAME}}
access_key_id: "{{AWS_ACCESS_KEY}}"
secret_access_key: "{{AWS_SECRET_KEY}}"
region: "{{AWS_REGION_S3}}"
bucket_name: "{{AWS_BUCKET_NAME}}"
tables:
- !Table
name: stocks
config: !CSV
path: . # path to files or folder inside a bucket
path: stock_data_monthly_100_rows #Change this to stock_data_monthly
extension: .csv
name: s3

Expand Down Expand Up @@ -62,6 +62,5 @@ endpoints:
- name: lowest_daily_close
path: /analysis/lowest_daily_close
table_name: lowest_daily_close

# telemetry:
# metrics: !Prometheus # You can check the metrics at http://localhost:9000
1 change: 1 addition & 0 deletions connectors/ethereum/dozer-config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
app_name: eth-smartcontracts-sample
version: 1
connections:
- config: !Ethereum
provider: !Log
Expand Down
4 changes: 0 additions & 4 deletions connectors/snowflake/dozer-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,3 @@ endpoints:
primary_key:
- C_CUSTKEY
- C_NAME

api:
app_grpc:
host: "{{APP_HOST}}"
4 changes: 0 additions & 4 deletions connectors/supabase/dozer-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,3 @@ endpoints:
- name: zone_data
path: /zone_data
table_name: zone_data

api:
app_grpc:
host: "{{APP_HOST}}"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "dozer-samples",
"version": "1.0.0",
"scripts": {
"test": "mocha -r ts-node/register test/**/*.ts",
"test": "mocha -r ts-node/register test/**/*.ts --timeout 60000 --exit",
"lint": "eslint test/**/*.js --quiet",
"lint:fix": "eslint test/**/*.js --fix --quiet",
"generate:grpc": "node ./test/scripts/proto.js"
Expand Down
27 changes: 27 additions & 0 deletions test/connectors/ethereum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { execSync } from 'child_process';
import path from 'path';

import {
assertEndpointsWithRetry, initDozer,
} from '../helper';

const TEST_PATH = './connectors/ethereum';

describe('Connectors: ethereum', async () => {
beforeEach(async () => {
const baseDir = path.join(__dirname, '../../');
const fullPath = path.join(baseDir, TEST_PATH);
process.chdir(fullPath);

console.log(`Current directory: ${process.cwd()}`);

execSync('rm -rf .dozer && rm -f dozer.lock', { stdio: 'inherit' });
});

it('should run and return API endpoints', async () => {
const dozer = await initDozer();
await assertEndpointsWithRetry();
dozer.kill();
console.log('Killed Dozer Ethereum');
});
});
13 changes: 9 additions & 4 deletions test/connectors/local-storage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { execSync } from 'child_process';
import path from 'path';
import {
assertEndpointsWithRetry, initDozer,
} from '../helper';
Expand All @@ -7,18 +8,22 @@ const TEST_PATH = './connectors/local-storage';

describe('Connectors: Local Storage', async () => {
beforeEach(async () => {
console.log(`Starting directory: ${process.cwd()}`);

// Copy test data to local-storage connector
execSync(`${__dirname}/init.sh`, { stdio: 'inherit' });

process.chdir(TEST_PATH);
const baseDir = path.join(__dirname, '../../');
const fullPath = path.join(baseDir, TEST_PATH);
process.chdir(fullPath);

console.log(`Current directory: ${process.cwd()}`);

execSync('rm -rf .dozer && rm -f dozer.lock', { stdio: 'inherit' });
});

it('should run and return API endpoints', async () => {
const dozer = await initDozer();
await assertEndpointsWithRetry();
dozer.kill(9);
dozer.kill();
console.log('Killed Dozer Local Storage');
});
});
27 changes: 27 additions & 0 deletions test/connectors/s3.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { execSync } from 'child_process';
import path from 'path';

import {
assertEndpointsWithRetry, initDozer,
} from '../helper';

const TEST_PATH = './connectors/aws-s3';

describe('Connectors: aws-s3', async () => {
beforeEach(async () => {
const baseDir = path.join(__dirname, '../../');
const fullPath = path.join(baseDir, TEST_PATH);
process.chdir(fullPath);

console.log(`Current directory: ${process.cwd()}`);

execSync('rm -rf .dozer && rm -f dozer.lock', { stdio: 'inherit' });
});

it('should run and return API endpoints', async () => {
const dozer = await initDozer();
await assertEndpointsWithRetry();
dozer.kill();
console.log('Killed Dozer aws-s3');
});
});
27 changes: 27 additions & 0 deletions test/connectors/snowflake.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { execSync } from 'child_process';
import path from 'path';

import {
assertEndpointsWithRetry, initDozer,
} from '../helper';

const TEST_PATH = './connectors/snowflake';

describe('Connectors: Snowflake', async () => {
beforeEach(async () => {
const baseDir = path.join(__dirname, '../../');
const fullPath = path.join(baseDir, TEST_PATH);
process.chdir(fullPath);

console.log(`Current directory: ${process.cwd()}`);

execSync('rm -rf .dozer && rm -f dozer.lock', { stdio: 'inherit' });
});

it('should run and return API endpoints', async () => {
const dozer = await initDozer();
await assertEndpointsWithRetry();
dozer.kill();
console.log('Killed Dozer Snowflake');
});
});
27 changes: 27 additions & 0 deletions test/connectors/supabase.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { execSync } from 'child_process';
import path from 'path';

import {
assertEndpointsWithRetry, initDozer,
} from '../helper';

const TEST_PATH = './connectors/supabase';

describe('Connectors: Supabase', async () => {
beforeEach(async () => {
const baseDir = path.join(__dirname, '../../');
const fullPath = path.join(baseDir, TEST_PATH);
process.chdir(fullPath);

console.log(`Current directory: ${process.cwd()}`);

execSync('rm -rf .dozer && rm -f dozer.lock', { stdio: 'inherit' });
});

it('should run and return API endpoints', async () => {
const dozer = await initDozer();
await assertEndpointsWithRetry();
dozer.kill();
console.log('Killed Dozer Supabase');
});
});
9 changes: 7 additions & 2 deletions test/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export class CommonGrpc {
): Promise<GetEndpointsResponse> {
return promisify(this.client.getEndpoints.bind(this.client, params, metadata, {}))();
}

public close() {
this.client.close();
}
}

export async function checkEndpoints() {
Expand All @@ -43,6 +47,7 @@ export async function checkEndpoints() {
const { endpoints } = endpointsRes;
console.log(endpoints);
assert(endpoints.length > 0);
client.close();
return true;
} catch (err) {
console.log('dozer is not up yet, retrying...');
Expand All @@ -51,8 +56,8 @@ export async function checkEndpoints() {
}

export async function assertEndpointsWithRetry(
maxRetries: number = 10,
retryInterval: number = 500,
maxRetries: number = 100,
retryInterval: number = 1000,
) {
let i = 0;
let endpointsReady = false;
Expand Down
Loading