Skip to content

Commit c94851a

Browse files
Fix Docker config and enable tests on Linux
1 parent 4c907f0 commit c94851a

File tree

4 files changed

+34
-42
lines changed

4 files changed

+34
-42
lines changed

Build.ps1

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,8 @@ CheckLastExitCode
102102
RunInspectCode
103103
RunCleanupCode
104104

105-
# Owing to issues with the Azure Cosmos Emulator for Linux on appveyor, do not run the CosmosDbTests on Linux
106-
if ($isLinux) {
107-
dotnet test --filter 'FullyQualifiedName!~CosmosDbTests' -c Release --no-build --collect:"XPlat Code Coverage"
108-
CheckLastExitCode
109-
}
110-
else {
111-
dotnet test -c Release --no-build --collect:"XPlat Code Coverage"
112-
CheckLastExitCode
113-
}
105+
dotnet test -c Release --no-build --collect:"XPlat Code Coverage"
106+
CheckLastExitCode
114107

115108
ReportCodeCoverage
116109

appveyor.yml

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -108,32 +108,29 @@ for:
108108
- docker
109109
before_build:
110110
- sh: |
111-
# Do not run the Azure Cosmos Emulator for Linux for now
112-
echo "Azure Cosmos Emulator for Linux is not being run at the moment"
113-
114-
## Start Azure Cosmos Emulator on Linux
115-
## Pull Azure Cosmos Emulator Docker image
116-
#echo "Pulling Azure Cosmos Emulator Docker image for Linux ..."
117-
#bash ./pull-docker-azure-cosmos-emulator-linux.sh
118-
119-
## Start Azure Cosmos Emulator container
120-
#echo "Running Azure Cosmos Emulator Docker container ..."
121-
#nohup bash ./run-docker-azure-cosmos-emulator-linux.sh &
122-
123-
## Wait for Docker container being started in the background
124-
#echo "Waiting 60 seconds before trying to download Azure Cosmos Emulator SSL certificate ..."
125-
#sleep 60
126-
127-
## Print the background process output to see whether there are any errors
128-
#if [ -f "./nohup.out" ]; then
129-
# echo "--- BEGIN CONTENTS OF NOHUP.OUT ---"
130-
# cat ./nohup.out
131-
# echo "--- END CONTENTS OF NOHUP.OUT ---"
132-
#fi
133-
134-
## Install SSL certificate to be able to access the emulator
135-
#echo "Installing Azure Cosmos Emulator SSL certificate ..."
136-
#sudo bash ./install-azure-cosmos-emulator-linux-certificates.sh
111+
# Start Azure Cosmos Emulator on Linux
112+
# Pull Azure Cosmos Emulator Docker image
113+
echo "Pulling Azure Cosmos Emulator Docker image for Linux ..."
114+
bash ./pull-docker-azure-cosmos-emulator-linux.sh
115+
116+
# Start Azure Cosmos Emulator container
117+
echo "Running Azure Cosmos Emulator Docker container ..."
118+
nohup bash ./run-docker-azure-cosmos-emulator-linux.sh &
119+
120+
# Wait for Docker container being started in the background
121+
echo "Waiting 60 seconds before trying to download Azure Cosmos Emulator SSL certificate ..."
122+
sleep 60
123+
124+
# Print the background process output to see whether there are any errors
125+
if [ -f "./nohup.out" ]; then
126+
echo "--- BEGIN CONTENTS OF NOHUP.OUT ---"
127+
cat ./nohup.out
128+
echo "--- END CONTENTS OF NOHUP.OUT ---"
129+
fi
130+
131+
# Install SSL certificate to be able to access the emulator
132+
echo "Installing Azure Cosmos Emulator SSL certificate ..."
133+
sudo bash ./install-azure-cosmos-emulator-linux-certificates.sh
137134
138135
build_script:
139136
- pwsh: |

install-azure-cosmos-emulator-linux-certificates.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/bin/bash
22

3-
ipaddr="`ifconfig | grep "inet " | grep -Fv 127.0.0.1 | awk '{print $2}' | head -n 1`"
43
certfile=~/emulatorcert.crt
54
echo "Certificate file: ${certfile}"
65

@@ -9,7 +8,7 @@ count=0
98

109
while [[ "$result" != "0" && "$count" < "5" ]]; do
1110
echo "Trying to download certificate ..."
12-
curl -k https://$ipaddr:8081/_explorer/emulator.pem > $certfile
11+
curl -k https://localhost:8081/_explorer/emulator.pem > $certfile
1312
result=$?
1413
let "count++"
1514

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
#!/bin/bash
22

3-
# Determine the IP address of the local machine.
4-
# This step is required when Direct mode setting is configured using Cosmos DB SDKs.
5-
ipaddr="`ifconfig | grep "inet " | grep -Fv 127.0.0.1 | awk '{print $2}' | head -n 1`"
3+
# Run the Docker image that was previously pulled from the Docker repository, creating a container called
4+
# "azure-cosmos-emulator-linux". Do not (!) set
5+
#
6+
# AZURE_COSMOS_EMULATOR_IP_ADDRESS_OVERRIDE=$ipaddr
7+
#
8+
# as suggested in Microsoft's documentation at https://docs.microsoft.com/en-us/azure/cosmos-db/linux-emulator.
9+
# We would not be able to connect to the emulator at all on appveyor, regardless of the connection mode.
10+
# To connect to the emulator, we must use Gateway mode. Direct mode will not work.
611

7-
# Run the image, creating a container called "azure-cosmos-emulator-linux".
812
docker run \
913
-p 8081:8081 \
1014
-p 10251:10251 \
@@ -16,5 +20,4 @@ docker run \
1620
--name=azure-cosmos-emulator-linux \
1721
-e AZURE_COSMOS_EMULATOR_PARTITION_COUNT=3 \
1822
-e AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE=true \
19-
-e AZURE_COSMOS_EMULATOR_IP_ADDRESS_OVERRIDE=$ipaddr \
2023
mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator

0 commit comments

Comments
 (0)