Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
53bf124
feat: mongodb-azure-cosmosdb-emulator
janpio Feb 17, 2022
8b7cf7b
update test
janpio Feb 17, 2022
90675d4
switch action
janpio Feb 17, 2022
ae2dd76
url encode password
janpio Feb 17, 2022
a8d7c0f
test emulator manually
janpio Feb 17, 2022
7fa37be
install deps
janpio Feb 17, 2022
b9dfb79
install correct deps
janpio Feb 17, 2022
29ea4e5
log cosmosclient results
janpio Feb 17, 2022
ec6d1e5
switch to action fork that enables mongodb
janpio Feb 17, 2022
1a37200
disable ssl validation in mongo client
janpio Feb 17, 2022
bf3b9ae
disable ssl validation in prisma
janpio Feb 17, 2022
28f8590
start emulator directly
janpio Feb 17, 2022
980d66c
tmate
janpio Feb 17, 2022
871b35f
meh
janpio Feb 17, 2022
c2fc6aa
ls
janpio Feb 17, 2022
843cd75
quote the path
janpio Feb 17, 2022
3284879
yaml block for command and quotes
janpio Feb 17, 2022
e52bca5
path different
janpio Feb 18, 2022
9670025
explicitly use cmd
janpio Feb 18, 2022
15172f8
remove all but databases-windows and re-enable tmate action
janpio Feb 19, 2022
9faa90d
asdasd
janpio Feb 19, 2022
e0cfe58
trying things
janpio Feb 19, 2022
a8030c3
copy correct file instead
janpio Feb 19, 2022
b4ce9d0
vanilla start instead
janpio Feb 19, 2022
053a5d5
create dummy data first
janpio Feb 19, 2022
54561a3
insert entry via mongoclient first
janpio Feb 19, 2022
a7dad37
retryWrites=false
janpio Feb 19, 2022
58186b5
asdfsadf
janpio Feb 20, 2022
36419a4
rmove file
janpio Feb 20, 2022
ead8090
undo temp changes
janpio Feb 20, 2022
5835ecb
READMEs
janpio Feb 20, 2022
99e4472
no scripts to mess with emulator database
janpio Feb 20, 2022
24b1bfa
Run a simple MongoDB query to create entry in database and collection…
janpio Feb 20, 2022
0853692
yarn install
janpio Feb 20, 2022
b7151fd
Remove @azure/cosmos and cosmosclient.js
janpio Feb 20, 2022
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
6 changes: 6 additions & 0 deletions .github/workflows/detect-jobs-to-run.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Object {
"core-features": true,
"databases": true,
"databases-macos": true,
"databases-windows": true,
"dataproxy": true,
"docker": true,
"engines": true,
Expand Down Expand Up @@ -49,6 +50,7 @@ Object {
"core-features": false,
"databases": false,
"databases-macos": false,
"databases-windows": false,
"dataproxy": false,
"docker": false,
"engines": false,
Expand Down Expand Up @@ -79,6 +81,7 @@ Object {
"core-features": false,
"databases": true,
"databases-macos": false,
"databases-windows": false,
"dataproxy": false,
"docker": false,
"engines": false,
Expand Down Expand Up @@ -111,6 +114,7 @@ Object {
"core-features": true,
"databases": true,
"databases-macos": true,
"databases-windows": true,
"dataproxy": true,
"docker": true,
"engines": true,
Expand Down Expand Up @@ -141,6 +145,7 @@ Object {
"core-features": true,
"databases": true,
"databases-macos": true,
"databases-windows": true,
"dataproxy": true,
"docker": true,
"engines": true,
Expand Down Expand Up @@ -171,6 +176,7 @@ Object {
"core-features": true,
"databases": true,
"databases-macos": true,
"databases-windows": true,
"dataproxy": true,
"docker": true,
"engines": true,
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ jobs:
- libraries
- databases
- databases-macos
- databases-windows
- process-managers
- test-runners
- docker
Expand Down Expand Up @@ -121,6 +122,7 @@ jobs:
- libraries
- databases
- databases-macos
- databases-windows
- process-managers
- test-runners
- docker
Expand Down Expand Up @@ -1055,6 +1057,56 @@ jobs:
if: failure()
run: bash .github/slack/notify-failure.sh ${{ github.job }} ${{ matrix.database }}

databases-windows:
needs: [start-time, detect_jobs_to_run]
if: ${{ fromJson(needs.detect_jobs_to_run.outputs.jobs)['databases-windows'] == true }}

strategy:
fail-fast: false
matrix:
clientEngine: [library] # ['library', 'binary']
database:
- mongodb-azure-cosmosdb-emulator
os: [windows-latest]
runs-on: ${{ matrix.os }}

env:
START_TIME: ${{ needs.start-time.outputs.start-time }}

steps:
- uses: actions/checkout@v2

- uses: janpio/azure-cosmos-db-emulator-github-action@main
with:
parameter_string: "-EnableMongoDb 4.0"

# Run a simple MongoDB query to create entry in database and collection (as other non-create queries [like the initial deleteMany in the test script] will otherwise get an error message)
- run: yarn install && node mongoclient.js
working-directory: ${{ github.job }}/${{ matrix.database }}

- name: Define Client Engine Type to test
run: echo "PRISMA_CLIENT_ENGINE_TYPE=${{ matrix.clientEngine }}" >> $GITHUB_ENV

- name: Install Dependencies
run: yarn install

- name: use node 12
uses: actions/setup-node@v2
with:
node-version: 12

- name: test ${{ matrix.database }} - ${{ matrix.clientEngine }}
id: run-test
uses: nick-invision/retry@v2
with:
timeout_minutes: 10
max_attempts: 3
command: bash .github/scripts/test-project.sh ${{ github.job }} ${{ matrix.database }}

- name: notify-slack
if: failure()
run: bash .github/slack/notify-failure.sh ${{ github.job }} ${{ matrix.database }}

test-runners:
needs: [start-time, detect_jobs_to_run]
if: ${{ fromJson(needs.detect_jobs_to_run.outputs.jobs)['test-runners'] == true }}
Expand Down
8 changes: 8 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This configuration file was automatically generated by Gitpod.
# Please adjust to your needs (see https://www.gitpod.io/docs/config-gitpod-file)
# and commit this file to your remote git repository to share the goodness with others.

tasks:
- init: yarn install


5 changes: 5 additions & 0 deletions databases-windows/mongodb-azure-cosmosdb-emulator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# MongoDB at Azure CosmosDB Emulator

Prisma Client with MongoDB at Azure CosmosDB, using the [local emulator](https://docs.microsoft.com/en-us/azure/cosmos-db/local-emulator?tabs=ssl-netstd21).

⚠️ Note that [support for Azure Cosmos DB is spotty in Prisma](https://github.com/prisma/prisma/issues/11921) and only works in very limited cases (like the minimal tests that are run here)
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const { MongoClient } = require('mongodb')

const uri = "mongodb://localhost:C2y6yDjf5%2FR%2Bob0N8A7Cgv30VRDJIWEHLM%2B4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw%2FJw%3D%3D@localhost:10255/e2e-tests?ssl=true&retryWrites=false";
var options = {
sslValidate: false
}
const client = new MongoClient(uri, options);
async function run() {
try {
await client.connect();
const database = client.db("e2e-tests");
const collection = database.collection("User");
const entry = await collection.insertOne({ email: "foo@bar.org", name: "Foo" });
console.log(entry);
} finally {
await client.close();
}
}
run().catch(console.dir);
19 changes: 19 additions & 0 deletions databases-windows/mongodb-azure-cosmosdb-emulator/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "mongodb-azure-cosmosdb-emulator",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"devDependencies": {
"@types/node": "15.12.5",
"prisma": "3.10.0-dev.54",
"ts-node": "10.5.0",
"typescript": "4.5.5"
},
"scripts": {
"cmd": "ts-node ./script.ts"
},
"dependencies": {
"@prisma/client": "3.10.0-dev.54",
"mongodb": "^4.3.1"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
datasource db {
provider = "mongodb"
// non url encoded password: C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==
url = "mongodb://localhost:C2y6yDjf5%2FR%2Bob0N8A7Cgv30VRDJIWEHLM%2B4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw%2FJw%3D%3D@localhost:10255/e2e-tests?ssl=true&tlsAllowInvalidCertificates=true&retryWrites=false"
}

generator client {
provider = "prisma-client-js"
previewFeatures = ["mongodb"]
}

model User {
id String @id @default(auto()) @map("_id") @db.ObjectId
email String @unique
name String?
}

model Post {
id String @id @map("_id")
title String
}
6 changes: 6 additions & 0 deletions databases-windows/mongodb-azure-cosmosdb-emulator/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

set -eux

yarn install
yarn prisma generate
59 changes: 59 additions & 0 deletions databases-windows/mongodb-azure-cosmosdb-emulator/script.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { PrismaClient } from '@prisma/client'

const client = new PrismaClient()

// A `main` function so that we can use async/await
async function main() {

// On CosmosDB the first delete will fail if you do not make sure the database and collection actually exist, so creating so dummy data first
// await client.user.create({
// data: {
// id: '6d795f757365725f69643031',
// email: 'foo@prisma.io',
// name: 'Foo',
// },
// })


await client.user.deleteMany({})

const objectId = '6d795f757365725f69643030'

await client.user.create({
data: {
id: objectId,
email: 'alice@prisma.io',
name: 'Alice',
},
})

const user = await client.user.findUnique({
where: {
id: objectId,
},
})

const expect = JSON.stringify({
id: objectId,
email: 'alice@prisma.io',
name: 'Alice',
})

if (JSON.stringify(user) !== expect) {
console.error('expected', expect, 'got', user)
process.exit(1)
}

console.log('success')

await client.$disconnect()
}

main()
.catch(async (e) => {
console.error(e)
process.exit(1)
})
.finally(async () => {
await client.$disconnect()
})
5 changes: 5 additions & 0 deletions databases-windows/mongodb-azure-cosmosdb-emulator/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

set -eux

yarn cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"sourceMap": true,
"outDir": "dist",
"strict": true,
"lib": ["esnext", "dom"],
"esModuleInterop": true
}
}
Loading