Skip to content

refactor: add dapr 1.8.0 ci env and polish e2e tests #67

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

Merged
merged 4 commits into from
Jul 20, 2022
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
2 changes: 1 addition & 1 deletion .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
matrix:
node-version: [16]
dapr-version: [1.6.3, 1.7.4]
dapr-version: [1.6.3, 1.7.4, 1.8.0]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
Expand Down
5 changes: 3 additions & 2 deletions docs/generated/api.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"metadata": {
"toolPackage": "@microsoft/api-extractor",
"toolVersion": "7.27.0",
"schemaVersion": 1008,
"toolVersion": "7.28.4",
"schemaVersion": 1009,
"oldestForwardsCompatibleVersion": 1001,
"tsdocConfig": {
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
Expand Down Expand Up @@ -1602,6 +1602,7 @@
"text": ";"
}
],
"isReadonly": false,
"returnTypeTokenRange": {
"startIndex": 3,
"endIndex": 4
Expand Down
106 changes: 53 additions & 53 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
"express": "^4.18.1",
"express-interceptor": "^1.2.0",
"lodash": "^4.17.21",
"minimist": "^1.2.5",
"on-finished": "^2.3.0",
"minimist": "^1.2.6",
"on-finished": "^2.4.1",
"read-pkg-up": "^7.0.1",
"semver": "^7.3.5"
"semver": "^7.3.7"
},
"scripts": {
"test": "cross-env DEBUG=common:*,ofn:* mocha build/test -t 60000 --recursive --exit",
Expand Down Expand Up @@ -52,7 +52,7 @@
"author": "OpenFunction",
"license": "Apache-2.0",
"devDependencies": {
"@microsoft/api-extractor": "^7.27.0",
"@microsoft/api-extractor": "^7.28.4",
"@types/body-parser": "1.19.2",
"@types/debug": "^4.1.7",
"@types/express": "4.17.13",
Expand All @@ -65,16 +65,16 @@
"@types/on-finished": "2.3.1",
"@types/semver": "^7.3.10",
"@types/shelljs": "^0.8.11",
"@types/sinon": "^10.0.11",
"@types/sinon": "10.0.11",
"@types/supertest": "2.0.12",
"aedes": "^0.47.0",
"concurrently": "^7.2.2",
"concurrently": "^7.3.0",
"cross-env": "^7.0.3",
"env-cmd": "^10.1.0",
"gts": "^3.1.0",
"mocha": "10.0.0",
"pack-n-play": "^1.0.0-2",
"pre-push": "^0.1.2",
"pre-push": "^0.1.3",
"shelljs": "^0.8.5",
"sinon": "^14.0.0",
"supertest": "6.2.3",
Expand Down
40 changes: 24 additions & 16 deletions test/integration/async_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import {deepStrictEqual, ifError, ok} from 'assert';
import {createServer} from 'net';

import {get} from 'lodash';
import {get, isEmpty} from 'lodash';
import * as shell from 'shelljs';
import * as MQTT from 'aedes';

Expand Down Expand Up @@ -54,7 +54,16 @@ const TEST_CONTEXT: OpenFunctionContext = {
},
},
};

const TEST_PAYLOAD = {data: 'hello world'};
const TEST_CLOUD_EVENT = {
specversion: '1.0',
id: 'test-1234-1234',
type: 'ce.openfunction',
source: 'https://github.com/OpenFunction/functions-framework-nodejs',
traceparent: '00-65088630f09e0a5359677a7429456db7-97f23477fb2bf5ec-01',
data: TEST_PAYLOAD,
};

describe('OpenFunction - Async - Binding', () => {
const APPID = 'async.dapr';
Expand Down Expand Up @@ -139,15 +148,12 @@ describe('OpenFunction - Async - Binding', () => {

it('mqtt sub w/ pub output', done => {
const app = getAysncServer((ctx, data) => {
if (isEmpty(data)) return;

// Assert that user function receives correct data from input binding
try {
const recieved = JSON.parse(data as string);
deepStrictEqual(recieved, TEST_PAYLOAD);
} catch (err) {
ifError(err);
}
deepStrictEqual(data, TEST_PAYLOAD);

// Then write recived data to a local file
// Then forward received data to output channel
const output = 'mqtt_pub';
broker.subscribe(
get(TEST_CONTEXT, `outputs.${output}.uri`),
Expand All @@ -165,15 +171,17 @@ describe('OpenFunction - Async - Binding', () => {

// First, we start the async server
app.start().then(() => {
// Then, we publish a message via Dapr CLI
const formatted = JSON.stringify(TEST_PAYLOAD).replace(/"/g, '\\"');
shell.exec(
`dapr publish -i ${APPID} -p ${
TEST_CONTEXT.inputs!.mqtt_sub!.componentName
} -t ${TEST_CONTEXT.inputs!.mqtt_sub.uri} -d '"${formatted}"'`,
// Then, we send a cloudevent format message to server
broker.publish(
{
silent: true,
}
cmd: 'publish',
topic: TEST_CONTEXT.inputs!.mqtt_sub.uri!,
payload: JSON.stringify(TEST_CLOUD_EVENT),
qos: 0,
retain: false,
dup: false,
},
err => ifError(err)
);
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/integration/cloud_event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {FUNCTION_STATUS_HEADER_FIELD} from '../../src/types';
const TEST_CLOUD_EVENT = {
specversion: '1.0',
type: 'com.google.cloud.storage',
source: 'https://github.com/GoogleCloudPlatform/functions-framework-nodejs',
source: 'https://github.com/OpenFunction/functions-framework-nodejs',
subject: 'test-subject',
id: 'test-1234-1234',
time: '2020-05-13T01:23:45Z',
Expand Down