Skip to content
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

Migrate integration tests for spring-data-cosmosdb #12609

Merged
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
4 changes: 2 additions & 2 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/sdk/core/ @alzimmermsft @jianghaolu @srnagar @hemanttanwar @anuchandy
/sdk/core/azure-core-tracing-opentelemetry/ @samvaity @alzimmermsft
/sdk/cosmos/ @moderakh @kushagraThapar @David-Noble-at-work @kirankumarkolli @mbhaskar
/sdk/cosmos/azure-spring-data-cosmosdb/ @kushagraThapar
/sdk/cosmos/azure-spring-data-cosmosdb/ @kushagraThapar @saragluna @yiliuTo @chenrujun @zhoufenqin @jialindai
/sdk/eventhubs/ @conniey @srnagar @mssfang
/sdk/formrecognizer/ @samvaity @mssfang @sima-zhu
/sdk/identity/ @schaabs @g2vinay @jianghaolu
Expand All @@ -27,7 +27,7 @@
/sdk/servicebus/ @yvgopal @nemakam @hemanttanwar @conniey
/sdk/storage/ @amishra-dev @rickle-msft @jaschrep-msft @gapra-msft @alzimmermsft @sima-zhu
/sdk/textanalytics/ @samvaity @mssfang @sima-zhu
/sdk/spring/ @saragluna @yiliuTo @chenrujun @jialindai
/sdk/spring/ @saragluna @yiliuTo @chenrujun @zhoufenqin @jialindai

# end to end tests
/sdk/e2e/ @jianghaolu @g2vinay
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,4 @@ package-lock.json
# VS Code
.vscode/
.factorypath
jacoco.exec
10 changes: 9 additions & 1 deletion eng/pipelines/templates/stages/cosmos-sdk-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,25 @@ stages:
DisplayName: 'Emulator only Integration Tests'
PROTOCOLS: '["Tcp"]'
DESIRED_CONSISTENCIES: '["Strong", "Session"]'
AdditionalArgs: '-DargLine="-DACCOUNT_HOST=https://localhost:8081/"'
Https_Integration_Tests_Java8:
OSVmImage: 'windows-2019'
JavaTestVersion: '1.8'
ProfileFlag: '-Pemulator'
DisplayName: 'Emulator only Integration Tests'
PROTOCOLS: '["Https"]'
DESIRED_CONSISTENCIES: '["Strong", "Session"]'
AdditionalArgs: '-DargLine="-DACCOUNT_HOST=https://localhost:8081/"'
Spring_Integration_Tests_Java8:
OSVmImage: 'windows-2019'
JavaTestVersion: '1.8'
ProfileFlag: '-P integration-test-emulator'
DisplayName: 'Spring Emulator only Integration Tests'
AdditionalArgs: '-DargLine="-DACCOUNT_HOST=https://localhost:8081/ -DACCOUNT_KEY=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw== -DSECONDARY_ACCOUNT_KEY=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="'
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there any security concerns here? Is this secret used anywhere else, can it be randomly generated?

Copy link
Member

Choose a reason for hiding this comment

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


TestStepMavenInputs:
goals: 'verify'
options: '$(ProfileFlag) -Dgpg.skip -DargLine="-DACCOUNT_HOST=https://localhost:8081/" -pl $(ProjectList)'
options: '$(ProfileFlag) -Dgpg.skip $(AdditionalArgs) -pl $(ProjectList)'
mavenAuthenticateFeed: true
jdkVersionOption: $(JavaTestVersion)

Expand Down
62 changes: 62 additions & 0 deletions sdk/cosmos/azure-spring-data-cosmosdb/Contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Contributing
This instruction is guideline for building and code contribution.

## Prequisites
- JDK 1.8 and above
- [Maven](http://maven.apache.org/) 3.0 and above

## Build from source
To build the project, run maven commands.

```bash
git clone https://github.com/Azure/azure-sdk-for-java.git
cd sdk/cosmos/azure-spring-data-cosmosdb
mvnw clean install
```

## Test
There're integration tests on azure and on emulator to trigger integration test execution against Azure Cosmos DB and against [Azure Cosmos DB Emulator](https://docs.microsoft.com/azure/cosmos-db/local-emulator), you need to follow the link to setup emulator before test execution.

- Run unit tests
```bash
mvnw clean install
```

- Run integration tests
- on Azure
>**NOTE** Please note that integration test against Azure requires Azure Cosmos DB Document API and will automatically create a Cosmos database in your Azure subscription, then there will be **Azure usage fee.**

Integration tests will require a Azure Subscription. If you don't already have an Azure subscription, you can activate your [MSDN subscriber benefits](https://azure.microsoft.com/pricing/member-offers/msdn-benefits-details/) or sign up for a [free Azure account](https://azure.microsoft.com/free/).

1. Create an Azure Cosmos DB on Azure.
- Go to [Azure portal](https://portal.azure.com/) and click +New.
- Click Databases, and then click Azure Cosmos DB to create your database.
- Navigate to the database you have created, and click Access keys and copy your URI and access keys for your database.

2. Set environment variables ACCOUNT_HOST, ACCOUNT_KEY and SECONDARY_ACCOUNT_KEY, where value of them are Cosmos account URI, primary key and secondary key.
3. Run maven command with `integration-test-azure` profile.

```bash
set ACCOUNT_HOST=your-cosmos-account-uri
set ACCOUNT_KEY=your-cosmos-account-primary-key
set SECONDARY_ACCOUNT_KEY=your-cosmos-account-secondary-key
mvnw -P integration-test-azure clean install
```
- on Emulator

Setup Azure Cosmos DB Emulator by following [this instruction](https://docs.microsoft.com/azure/cosmos-db/local-emulator), and set associated environment variables. Then run test with:
```bash
mvnw -P integration-test-emulator install
```


- Skip tests execution
```bash
mvnw clean install -DskipTests
```

## Version management
Developing version naming convention is like `0.1.2-beta.1`. Release version naming convention is like `0.1.2`.

## Contribute to code
Contribution is welcome. Please follow [this instruction](https://github.com/Azure/azure-sdk-for-java/blob/master/CONTRIBUTING.md) to contribute code.
Loading