Skip to content

[event-hubs] Enable unit-test for node.js in CI#17492

Merged
20 commits merged intoAzure:mainfrom
chradek:eh-mock-hub-merger
Sep 17, 2021
Merged

[event-hubs] Enable unit-test for node.js in CI#17492
20 commits merged intoAzure:mainfrom
chradek:eh-mock-hub-merger

Conversation

@chradek
Copy link
Copy Markdown
Contributor

@chradek chradek commented Sep 7, 2021

Replaces #14568

Uses the @azure/mock-hub package to start a local mocked version of Event Hubs to run tests against.

There are a lot of whitespace changes (indentation) so I recommend viewing with whitespace changes hidden.

@ghost ghost added the Event Hubs label Sep 7, 2021
@richardpark-msft
Copy link
Copy Markdown
Member

CC: @jhendrixMSFT

(this is the CI-friendly eventhubs tester I mentioned the other day)

"-out",
`${resolvePath(certsDirectory, "my-server.crt.pem")}`,
"-days",
"5"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to work on our live test times.


for (const m of incomingMessages) {
if (m.body?.content) {
if (m.body.multiple && m.body?.content) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious what this is about. Is this the "message was too big for a single transfer frame" or similar condition?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for batched messages. When I initially wrote this, I noticed m.body.content was an array if an AMQP message contained multiple messages. But it turns out sequence bodies also cause content to be an array, so without the multiple check I was converting every item in content to a separate message when the body was a sequence.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment and I think you're good.

"EVENTHUB_NAME",
"IOTHUB_EH_COMPATIBLE_CONNECTION_STRING"
"IOTHUB_EH_COMPATIBLE_CONNECTION_STRING",
"TEST_TARGET"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make it TEST_MODE?

Copy link
Copy Markdown
Contributor Author

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.


await producerClient.close();
});
testWithServiceTypes("internal/auth.spec.ts", (serviceVersion) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need the file paths?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strictly speaking, they aren't needed. However I found it made it really easy to find out where a test that fails lives.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[NIT] Test objects/blocks do have the file path in them, which is what I used to locate the recordings folder in the recorder.
Since you have the wrapper and using describe blocks, I'm wondering if you can automate that instead of writing in each of the files.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean there's an API to get the file path? Does it also work for browsers?

Copy link
Copy Markdown
Contributor

@HarshaNalluru HarshaNalluru Sep 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

Something like this.
image

Here, the testConext is the this object of the function from it test.

Copy link
Copy Markdown
Contributor

@HarshaNalluru HarshaNalluru Sep 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An example
image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this does mean I need to wrap my describe(this.file, ...) in another describe so that I have access to the mocha suite context object when defining the describe that has the file path. I decided to go ahead and do that.

Unfortunately, that does not seem to work in browsers, but I'll accept that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting

Copy link
Copy Markdown
Member

@richardpark-msft richardpark-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Just that one spot where I think a comment is needed to explain the .content hoisting, but otherwise, no issues.

@chradek
Copy link
Copy Markdown
Contributor Author

chradek commented Sep 15, 2021

/azp run js - event-hubs - tests

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@chradek
Copy link
Copy Markdown
Contributor Author

chradek commented Sep 15, 2021

/azp run js - event-hubs - tests

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@chradek
Copy link
Copy Markdown
Contributor Author

chradek commented Sep 17, 2021

I had to use an additional environment variable/add a check since TEST_MODE was being set automatically in some of our live test jobs, but live tests also pass:
https://dev.azure.com/azure-sdk/internal/_build/results?buildId=1101647&view=results

@ghost
Copy link
Copy Markdown

ghost commented Sep 17, 2021

Hello @chradek!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit bcb1827 into Azure:main Sep 17, 2021
openapi-sdkautomation bot pushed a commit to AzureSDKAutomation/azure-sdk-for-js that referenced this pull request Feb 16, 2022
Microsoft.App version 2022-01-01-preview (Azure#17820)

* New Swagger Spec File

* New Swagger Example Spec File

* New Readme Config File

* New Azure AZ Readme Config File

* New Azure CLI Readme Config File

* New Go Language Readme Config File

* New Python Language Readme Config File

* New Typescript Language Readme Config File

* New C# Language Readme Config File

* Adding new API version 2022-01-01-preview for the new service Microsoft.App (Azure#17135)

* Adding swagger and examples

* Fix samples

* Fix linting errors

* fix errors

* fix more errors

* prettier fixes

* Fix the VNET properties

* fix the vnet props

* Attempt to remove x-ms-identifiers

* Add x-ms-identifiers back

* Revert "Add x-ms-identifiers back"

This reverts commit 44525ab5ace45d9cb1bc85bee2751f015dcaffc6.

* Addsourcecontrolapis (Azure#17287)

* add sourcecontrol apis

* remove space

* prettier fix

* typo

* avocado fix

* lint fix

* add replicas apis (Azure#17501)

* Remove Dapr components from ContainerApp spec. Not breaking because the version hasn't been released yet. (Azure#17479)

* Remove dapr components from the ContainerApp object

* Fix example

* add descriptions

* fix

* change the auto-rest parameters

* Support volume mounts for containerApp (Azure#17530)

* add volume mounts

* add identifier

* refine volume definition

* Fix samples (Azure#17534)

* Adding managed identity (Azure#17569)

* Adding managed identity

* prettier fix.

* Microsof.app 2022 01 01 preview/add custom domains (Azure#17385)

* add support for Custom domains and certificates

* add Certificates

* Ccertificate as child resource of Managed Env.

* Support default custom domain

* PUT/DELETE certificate are not long-running

* Add Custom Domain Verification Id

* domains for all revisions and adding examples

* missing examples

* one more missing example

* Examples+missing paths

* Adding missing envelope properties

* Addressing PR comments

* Removing AKV and Free cert related properties

* Prettier and semantic validation fixes

* Fixing semantic validations and examples

* More fixes

* Addressing more PR comments

* Updating examples

* fixing type

* fixing types

* Extra properties and responses

* misplaced response

* whitespace

* fix security section

* fixing ManageEnvironment securityDefinitions

* add 204 delete response

* Removing virtual IP and IP Based option

* change modelAsString

* Addressing ARM PR comments

* Removing 404 response from example

* renaming custom hostname analysis operation

* mark certificate as tracked resource

* fix sample

* Use Certificate Id instead of Certificate name

Co-authored-by: Ruslan Yakushev 🚴 <ruslany@microsoft.com>
Co-authored-by: vinisoto <vinisoto@hotmail.com>

* Add new properties for ContainerApp (Azure#17483)

* add ephemeral storage

* add outbound ip

* add listsecrets

* fix CI

* fix example

* fix

* add identifier

* fix

* add example

* mars as secret

* Add storages operation for managedEnvironment (Azure#17545)

* add storage

* fix

* fix typo

* Add EasyAuth configuration APIs for ContainerApp (Azure#17492)

* Add Easy Auth Config related APIs for ContainerApp

* Use common type ProxyResource

* Update description

* update per validation

* typo fix

* fix validation error

* Update sample and description

* Update because ARM prefer string than boolean

* Add static web identity provider

* Add container probes (Azure#17535)

* Add container probes

* minor fix

* Use execute instead of exec'd, add identifier

* remove exec from preview

* use integer instead of intorstring

* Add `internal` property under VnetConfiguration for internalOnly environments (Azure#17656)

* Add internal property under VnetConfiguration for internalOnly environments

* Update examples

* Add Dapr Components collection APIs (Azure#17552)

* Add daprComponents

* update readme

* Fix linting errors

* More lint fixes

* prettier fixes

* make dapr component a tracked resource

* fix the patch

* fix lint errors

* Revert "fix lint errors"

This reverts commit 045f1d94bddf3527eab98b7a376070ab30fdd760.

* Revert "fix the patch"

This reverts commit 14521103e848e09762185f832c0270c16ed16efd.

* Revert "make dapr component a tracked resource"

This reverts commit 239268eda070ff37f26e8a772adacdd26bbf0937.

* Fix linter issues

* fix wrong fix

* fix linter

* fix the operationids (Azure#17809)

* correct resource name (Azure#17846)

* Add custom open id providers support (Azure#17855)

* Add custom open id providers support

* Update description

Co-authored-by: Xingjian Wang <79332479+xwang971@users.noreply.github.com>
Co-authored-by: Zunli Hu <zuh@microsoft.com>
Co-authored-by: Vaclav Turecek <vturecek@microsoft.com>
Co-authored-by: Vini Soto <18271663+vinisoto@users.noreply.github.com>
Co-authored-by: vinisoto <vinisoto@hotmail.com>
Co-authored-by: erich-wang <eriwan@microsoft.com>
Co-authored-by: Mike Vu <mdhvu@uwaterloo.ca>
Co-authored-by: Sanchit Mehta <sanmeht@microsoft.com>
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants