-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into review-result-reaction
- Loading branch information
Showing
58 changed files
with
2,677 additions
and
1,831 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Copyright 2024 The Drasi Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
name: Download and Publish Visual Studio Code Extension | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'Version of the extension' | ||
required: true | ||
|
||
|
||
jobs: | ||
build-and-publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Install Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
- name: Install VSCE | ||
run: npm install @vscode/vsce --save-dev | ||
- name: Download VSIX from GitHub Release | ||
run: | | ||
curl -L -o drasi.vsix https://github.com/drasi-project/drasi-platform/releases/download/${{ github.event.inputs.version }}/drasi-${{ github.event.inputs.version }}.vsix | ||
- name: Publish | ||
run: | | ||
npx vsce publish -p ${{ secrets.VSCE_TOKEN }} --packagePath drasi.vsix | ||
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions
11
e2e-tests/03-gremlin-reaction-scenario/gremlin-reaction-deletion.yaml
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,11 @@ | ||
kind: Reaction | ||
apiVersion: v1 | ||
name: e2e-gremlin-reaction | ||
spec: | ||
kind: Gremlin | ||
queries: | ||
query3-deletion: | ||
properties: | ||
deletedResultCommand: g.addV('Item').property('ItemId', @Id).property('Name',@Name) | ||
gremlinHost: gremlin-server.default.svc.cluster.local | ||
gremlinPort: 8182 |
137 changes: 137 additions & 0 deletions
137
e2e-tests/03-gremlin-reaction-scenario/gremlin-reaction.test.js
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,137 @@ | ||
/** | ||
* Copyright 2024 The Drasi Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
const yaml = require('js-yaml'); | ||
const fs = require('fs'); | ||
const PortForward = require('../fixtures/port-forward'); | ||
const deployResources = require("../fixtures/deploy-resources"); | ||
const deleteResources = require("../fixtures/delete-resources"); | ||
const pg = require('pg'); | ||
const gremlin = require('gremlin'); | ||
|
||
|
||
let postgresPortForward = new PortForward("postgres03", 5432); | ||
|
||
let postgresClient = new pg.Client({ | ||
database: "test-db", | ||
host: "127.0.0.1", | ||
user: "test", | ||
password: "test", | ||
}); | ||
let gremlinPortForward = new PortForward("gremlin-server", 8182); | ||
let gremlinClient; | ||
let gremlinDriverConnection; | ||
|
||
beforeAll(async () => { | ||
// Setting up the postgres database for the Source | ||
const postgresResources = yaml.loadAll(fs.readFileSync(__dirname + '/resources.yaml', 'utf8')); | ||
await deployResources(postgresResources); | ||
|
||
postgresClient.port = await postgresPortForward.start(); | ||
await postgresClient.connect(); | ||
await new Promise(r => setTimeout(r, 15000)); | ||
|
||
|
||
|
||
// Setting up the Gremlin database | ||
const gremlinResources = yaml.loadAll(fs.readFileSync(__dirname + '/gremlin-resources.yaml', 'utf8')); | ||
await deployResources(gremlinResources); | ||
await new Promise(r => setTimeout(r, 15000)); | ||
|
||
|
||
let gremlinPort = await gremlinPortForward.start(); | ||
|
||
// gremlin-server-service.default.svc.cluster.local | ||
const traversal = gremlin.process.AnonymousTraversalSource.traversal; | ||
gremlinDriverConnection = new gremlin.driver.DriverRemoteConnection(`ws://localhost:${gremlinPort}/gremlin`, {}); | ||
gremlinClient = traversal().withRemote(gremlinDriverConnection); | ||
}, 150000); | ||
|
||
|
||
test('Test Gremlin Reaction - AddedResultCommand', async () => { | ||
const gremlinReaction = yaml.loadAll(fs.readFileSync(__dirname + '/gremlin-reaction.yaml', 'utf8')); | ||
await deployResources(gremlinReaction); | ||
|
||
await postgresClient.query(`INSERT INTO "Item" ("ItemId", "Name", "Category") VALUES (4, 'Drasi', '3')`); | ||
await waitForCondition(async () => { | ||
const result = await gremlinClient.V().has('ItemId', '4').hasNext(); | ||
return result; | ||
}, 1000,30000) | ||
.then(() => { | ||
expect(true).toBeTruthy(); | ||
}) | ||
.catch(() => { | ||
expect(false).toBeTruthy(); | ||
}); | ||
}, 140000); | ||
|
||
test('Test Gremlin Reaction - deletedResultCommand', async () => { | ||
const gremlinReaction = yaml.loadAll(fs.readFileSync(__dirname + '/gremlin-reaction-deletion.yaml', 'utf8')); | ||
await deployResources(gremlinReaction); | ||
|
||
await postgresClient.query(`DELETE FROM "Item" WHERE "ItemId" = 5`); | ||
await waitForCondition(async () => { | ||
const result = await gremlinClient.V().has('ItemId', '5').hasNext(); | ||
return result; | ||
}, 1000,30000) | ||
.then(() => { | ||
expect(true).toBeTruthy(); | ||
}) | ||
.catch(() => { | ||
expect(false).toBeTruthy(); | ||
}); | ||
}, 140000); | ||
|
||
|
||
afterAll(async () => { | ||
await postgresClient.end(); | ||
postgresPortForward.stop(); | ||
|
||
gremlinPortForward.stop(); | ||
gremlinDriverConnection.close(); | ||
|
||
const postgresResources = yaml.loadAll(fs.readFileSync(__dirname + '/resources.yaml', 'utf8')); | ||
await deleteResources(postgresResources); | ||
|
||
|
||
const gremlinResources = yaml.loadAll(fs.readFileSync(__dirname + '/gremlin-resources.yaml', 'utf8')); | ||
await deleteResources(gremlinResources); | ||
|
||
const gremlinReaction = yaml.loadAll(fs.readFileSync(__dirname + '/gremlin-reaction.yaml', 'utf8')); | ||
await deleteResources(gremlinReaction); | ||
|
||
const gremlinReactionDeletion = yaml.loadAll(fs.readFileSync(__dirname + '/gremlin-reaction-deletion.yaml', 'utf8')); | ||
await deleteResources(gremlinReactionDeletion); | ||
}); | ||
|
||
|
||
function waitForCondition(checkFn, interval = 1000, timeout = 30000) { | ||
return new Promise((resolve, reject) => { | ||
let elapsedTime = 0; | ||
|
||
const intervalId = setInterval(async () => { | ||
if (await checkFn()) { | ||
clearInterval(intervalId); | ||
resolve(); | ||
} else if (elapsedTime >= timeout) { | ||
clearInterval(intervalId); | ||
reject(new Error("Timed out waiting for condition to be met")); | ||
} | ||
|
||
elapsedTime += interval; | ||
}, interval); | ||
}); | ||
} |
11 changes: 11 additions & 0 deletions
11
e2e-tests/03-gremlin-reaction-scenario/gremlin-reaction.yaml
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,11 @@ | ||
kind: Reaction | ||
apiVersion: v1 | ||
name: e2e-gremlin-reaction-deletion | ||
spec: | ||
kind: Gremlin | ||
queries: | ||
query3: | ||
properties: | ||
addedResultCommand: g.addV('Item').property('ItemId', @Id).property('Name',@Name) | ||
gremlinHost: gremlin-server.default.svc.cluster.local | ||
gremlinPort: 8182 |
Oops, something went wrong.