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

[WIP] use cosmos db emulator #941

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 9 additions & 15 deletions azure-pipelines.yml
Expand Up @@ -34,26 +34,20 @@ steps:
displayName: 'start minio'

- powershell: |
$downloadURL = "https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-4.0.4-signed.msi"
Write-Host "download mongo from $downloadURL - start"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -Uri $downloadURL -OutFile "mongo.msi"
Write-Host "download mongo - end"
Write-Host "install mongo - start"
Start-Process msiexec -Wait -ArgumentList @('/i', 'mongo.msi', '/quiet', '/qn', 'INSTALLLOCATION=C:\mongodb', 'ADDLOCAL=all')
$env:PATH = 'C:\mongodb\bin;' + $env:PATH
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine)
mkdir C:\data\db | out-null
mkdir C:\data\configdb | out-null
Write-Host "install mongo - end"
Start-Process -NoNewWindow mongod.exe '--bind_ip_all --dbpath="C:\data\db"'
displayName: 'install & start mongo'
$emulatorBin = "C:\Program Files\Azure Cosmos DB Emulator\CosmosDB.Emulator.exe"
if (!(Test-Path $emulatorBin)) {
Write-Error "$emulatorBin not found"
}
else {
Start-Process -NoNewWindow -FilePath $emulatorBin '/NoUI /NoExplorer'
}
displayName: 'start cosmos db emulator'

- powershell: |
go test -mod=vendor -race ./...
env:
ATHENS_MINIO_ENDPOINT: "127.0.0.1:9001"
ATHENS_MONGO_STORAGE_URL: "127.0.0.1:27017"
ATHENS_MONGO_STORAGE_URL: "mongodb://localhost:C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==@localhost:10255/admin?ssl=false"
workingDirectory: '$(modulePath)'
displayName: 'run tests'

2 changes: 1 addition & 1 deletion pkg/storage/mongo/mongo.go
Expand Up @@ -56,7 +56,7 @@ func (m *ModuleStore) connect() error {

func (m *ModuleStore) initDatabase() error {
// TODO: database and collection as env vars, or params to New()? together with user/mongo
m.d = "athens"
m.d = "admin"
Copy link
Member

Choose a reason for hiding this comment

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

What do you think about fixing up the TODO above instead of changing this? I know that this would break a lot of deployments that already use mongo storage (including https://athens.azurefd.net)

Copy link
Member Author

Choose a reason for hiding this comment

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

👍 Sure, I couldn't figure out how to talk to the emulator and I tried things out. It wasn't meant to stay here like this.

m.c = "modules"

index := mgo.Index{
Expand Down