-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[event-hubs] Enable unit-test for node.js in CI #17492
Merged
Merged
Changes from 12 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
c768669
[mock-hub] make updates and fixes to pass JavaScript CI tests
chradek bb18612
[event-hubs] add wrapper and mock service for testing
chradek f9ecef6
[event-hubs] update npm scripts and dependencies to support running m…
chradek 6eaee29
[event-hubs] update tests to use test target wrapper
chradek ba970cf
[event-hubs] enable unit-test in ci
chradek 9b9951f
[event-hubs] fix eslint errors
chradek 0691e8f
[event-hubs] tests now inject environment variables when running agai…
chradek 1e172da
[mock-hub] update samples
chradek cdcd0e6
[event-hubs] improve token credential mock
chradek 702e273
[event-hubs] fix lint errors
chradek d5c5739
[event-hubs] rename "wrapper" test helper to "testWithServiceTypes"
chradek 564f72c
fix imports
chradek 26fa11c
[event-hubs] improve testWithServiceTypes helper to get filepath base…
chradek 565dd30
[mock-hub] add context around message.body.multiple check
chradek c0a57c8
Merge remote-tracking branch 'upstream/main' into eh-mock-hub-merger
chradek e0c63fd
debugging - add console logs
chradek 4a6a66f
debugging - more logs
chradek 2a1b174
[event-hubs] disable testing multiple service types when TEST_MODE is…
chradek 8763cb3
[event-hubs] add additional serviceVersion check in test wrapper for …
chradek d93496a
[event-hubs] remove console.log from test
chradek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
const { execFileSync } = require("child_process"); | ||
const { mkdirSync } = require("fs"); | ||
const { resolve: resolvePath } = require("path"); | ||
|
||
const cwd = process.cwd(); | ||
const certsDirectory = resolvePath(cwd, "certs"); | ||
|
||
// Create `certs` directory. | ||
console.log(`Creating ${certsDirectory}`); | ||
try { | ||
mkdirSync(certsDirectory); | ||
} catch (err) { | ||
if (err.code !== "EEXIST") { | ||
throw err; | ||
} | ||
} | ||
|
||
// Create own Root Certificate Authority | ||
execFileSync("openssl", [ | ||
"genrsa", | ||
"-out", | ||
`${resolvePath(certsDirectory, "my-private-root-ca.key.pem")}`, | ||
"2048" | ||
]); | ||
|
||
// Self-sign Root Certificate Authority | ||
execFileSync("openssl", [ | ||
"req", | ||
"-x509", | ||
"-new", | ||
"-nodes", | ||
"-key", | ||
`${resolvePath(certsDirectory, "my-private-root-ca.key.pem")}`, | ||
"-days", | ||
"5", | ||
"-out", | ||
`${resolvePath(certsDirectory, "my-private-root-ca.crt.pem")}`, | ||
"-subj", | ||
"/C=US/ST=Washington/L=Seattle/O=Fake Signing Authority/CN=fake.foo" | ||
]); | ||
|
||
// Create a certificate for localhost | ||
execFileSync("openssl", [ | ||
"genrsa", | ||
"-out", | ||
`${resolvePath(certsDirectory, "my-server.key.pem")}`, | ||
"2048" | ||
]); | ||
|
||
// Create a request which the Root Certificate Authority will sign | ||
execFileSync("openssl", [ | ||
"req", | ||
"-new", | ||
"-key", | ||
`${resolvePath(certsDirectory, "my-server.key.pem")}`, | ||
"-out", | ||
`${resolvePath(certsDirectory, "my-server.csr.pem")}`, | ||
"-subj", | ||
"/C=US/ST=Washington/L=Seattle/O=Fake Hubs/CN=localhost" | ||
]); | ||
|
||
// Sign the request with the Root Certificate Authority | ||
execFileSync("openssl", [ | ||
"x509", | ||
"-req", | ||
"-in", | ||
`${resolvePath(certsDirectory, "my-server.csr.pem")}`, | ||
"-CA", | ||
`${resolvePath(certsDirectory, "my-private-root-ca.crt.pem")}`, | ||
"-CAkey", | ||
`${resolvePath(certsDirectory, "my-private-root-ca.key.pem")}`, | ||
"-CAcreateserial", | ||
"-out", | ||
`${resolvePath(certsDirectory, "my-server.crt.pem")}`, | ||
"-days", | ||
"5" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to work on our live test times. |
||
]); | ||
|
||
console.log(`Certs created.`); |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make it TEST_MODE?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The multiversion test helper makes some assumptions with
TEST_MODE
that causes issue with what we're trying to do. I'm using the multiversion test helper to facilitate testing mock and live versions of the service, not multiple API versions of the service.This works fine if I don't set TEST_MODE at all, but things break if I set TEST_MODE to live because it assumes I want different behavior than just running my tests against the live service. So, that's why I made TEST_TARGET instead.