Skip to content

Commit

Permalink
Seed data into test container (#42)
Browse files Browse the repository at this point in the history
* fix test

* setup data only when --setup-data option is provided

* set up the azure cosmos emulator

* fix syntax errors

* use the emulator values

* setup emulator data

* fix issues

* use await

* disable tls

* fix typo

* fix syntax

* add indexing bit while creating the container

* fail the process when encountering any error
  • Loading branch information
codingkarthik authored Sep 11, 2024
1 parent 83ce105 commit 03d8ba1
Show file tree
Hide file tree
Showing 4 changed files with 325 additions and 153 deletions.
30 changes: 26 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,28 @@ jobs:
with:
path: cosmos

- name: Set up Docker
uses: docker-practice/actions-setup-docker@master

- name: Pull and run Azure Cosmos DB Emulator
run: |
docker pull mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator
docker run -d --name=cosmos-emulator -p 8081:8081 -p 10251:10251 -p 10252:10252 -p 10253:10253 -p 10254:10254 \
-e AZURE_COSMOS_EMULATOR_PARTITION_COUNT=10 \
-e AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE=false \
mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator
- name: Wait for Cosmos DB Emulator to be ready
run: |
timeout 300 bash -c 'until curl -ks https://localhost:8081/_explorer/emulator.pem > /dev/null; do sleep 5; done'
echo "Cosmos DB Emulator is ready"
- name: Download Cosmos DB Emulator certificate
run: |
curl -k https://localhost:8081/_explorer/emulator.pem > emulatorcert.crt
sudo cp emulatorcert.crt /usr/local/share/ca-certificates/
sudo update-ca-certificates
- name: Build connector
run: |
cd cosmos
Expand All @@ -33,9 +55,9 @@ jobs:
- name: Run tests
env:
AZURE_COSMOS_KEY: ${{ secrets.AZURE_COSMOS_KEY }}
AZURE_COSMOS_ENDPOINT: ${{ secrets.AZURE_COSMOS_ENDPOINT }}
AZURE_COSMOS_DB_NAME: ${{ secrets.AZURE_COSMOS_DB_NAME }}
AZURE_COSMOS_KEY: C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==
AZURE_COSMOS_ENDPOINT: https://localhost:8081
AZURE_COSMOS_DB_NAME: TestNobelLaureates
run: |
cd cosmos
npm run ndc-test
npm run ndc-test -- --setup-emulator-data
Original file line number Diff line number Diff line change
@@ -1,134 +1,132 @@
[
{
"rows": [
{
"laureates": [
{
"firstName": "James P.",
"id": "958"
},
{
"firstName": "Tasuku",
"id": "959"
}
]
},
{
"laureates": [
{
"firstName": "Oliver",
"id": "935"
},
{
"firstName": "Bengt",
"id": "936"
}
]
},
{
"laureates": [
{
"firstName": "David J.",
"id": "928"
},
{
"firstName": "F. Duncan M.",
"id": "929"
},
{
"firstName": "J. Michael",
"id": "930"
}
]
},
{
"laureates": [
{
"firstName": "Arthur",
"id": "960"
},
{
"firstName": "Gérard",
"id": "961"
},
{
"firstName": "Donna",
"id": "962"
}
]
},
{
"laureates": [
{
"firstName": "Katalin",
"id": "1024"
},
{
"firstName": "Drew",
"id": "1025"
}
]
},
{
"laureates": [
{
"firstName": "Abiy",
"id": "981"
}
]
},
{
"laureates": [
{
"firstName": "Serge",
"id": "876"
},
{
"firstName": "David J.",
"id": "877"
}
]
},
{
"laureates": [
{
"firstName": "Intergovernmental Panel on Climate Change",
"id": "818"
},
{
"firstName": "Al",
"id": "819"
}
]
},
{
"laureates": [
{
"firstName": "François",
"id": "887"
},
{
"firstName": "Peter",
"id": "888"
}
]
},
{
"laureates": [
{
"firstName": "Bruce A.",
"id": "861"
},
{
"firstName": "Jules A.",
"id": "862"
},
{
"firstName": "Ralph M.",
"id": "863"
}
]
}
{
"rows": [
{
"year": 2023,
"laureates": [
{
"firstName": "Katalin",
"id": "1024"
},
{
"firstName": "Drew",
"id": "1025"
}
]
}
},
{
"year": 2023,
"laureates": [
{
"firstName": "Pierre",
"id": "1026"
},
{
"firstName": "Ferenc",
"id": "1027"
},
{
"firstName": "Anne",
"id": "1028"
}
]
},
{
"year": 2023,
"laureates": [
{
"firstName": "Narges",
"id": "1033"
}
]
},
{
"year": 2023,
"laureates": [
{
"firstName": "Jon",
"id": "1032"
}
]
},
{
"year": 2023,
"laureates": [
{
"firstName": "Claudia",
"id": "1034"
}
]
},
{
"year": 2023,
"laureates": [
{
"firstName": "Moungi",
"id": "1029"
},
{
"firstName": "Louis",
"id": "1030"
},
{
"firstName": "Aleksey",
"id": "1031"
}
]
},
{
"year": 2022,
"laureates": [
{
"firstName": "Svante",
"id": "1011"
}
]
},
{
"year": 2022,
"laureates": [
{
"firstName": "Alain",
"id": "1012"
},
{
"firstName": "John ",
"id": "1013"
},
{
"firstName": "Anton",
"id": "1014"
}
]
},
{
"year": 2022,
"laureates": [
{
"firstName": "Ales",
"id": "1018"
},
{
"firstName": "Memorial",
"id": "1019"
},
{
"firstName": "Center for Civil Liberties",
"id": "1020"
}
]
},
{
"year": 2022,
"laureates": [
{
"firstName": "Annie",
"id": "1017"
}
]
}
]
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,30 @@
"collection": "TestNobelLaureates",
"query": {
"fields": {
"year": {
"type": "column",
"column": "year"
},
"laureates": {
"type": "column",
"column": "laureates",
"fields": {
"type": "array",
"type": "array",
"fields": {
"type": "object",
"fields": {
"type": "object",
"fields": {
"firstName": {
"type": "column",
"column": "firstname"
},
"id": {
"type": "column",
"column": "id"
}
}
"firstName": {
"type": "column",
"column": "firstname"
},
"id": {
"type": "column",
"column": "id"
}
}
}
}
}
}
},
"limit": 10,
"order_by": {
Expand All @@ -30,7 +34,7 @@
"order_direction": "desc",
"target": {
"type": "column",
"name": "id",
"name": "year",
"path": []
}
}
Expand Down
Loading

0 comments on commit 03d8ba1

Please sign in to comment.