Skip to content

Commit

Permalink
added eth,s3,snowflake
Browse files Browse the repository at this point in the history
  • Loading branch information
supergi0 committed Sep 26, 2023
1 parent f71f4db commit 557090d
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 16 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,17 @@ jobs:
sudo dpkg -i dozer-linux-amd64.deb
- name: Run tests
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
BUCKET_NAME: ${{ secrets.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 }}
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_ID}}"
secret_access_key: "{{AWS_SECRET_ACCESS_KEY}}"
region: "{{AWS_DEFAULT_REGION}}"
bucket_name: "{{BUCKET_NAME}}"
tables:
- !Table
name: stocks
config: !CSV
path: . # path to files or folder inside a bucket
path: stock_data_monthly_100_rows
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}}"
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(9);
console.log('Killed dozer ethereum');
});
});
11 changes: 8 additions & 3 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);
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(9);
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(9);
console.log('Killed dozer snowflake');
});
});
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 = 60,
retryInterval: number = 1000,
) {
let i = 0;
let endpointsReady = false;
Expand Down

0 comments on commit 557090d

Please sign in to comment.