Skip to content
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
37 changes: 0 additions & 37 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -150,43 +150,6 @@ Task("TestSocks5Proxy")
action: (BuildConfig buildConfig, Path testProject) =>
RunTests(buildConfig, testProject, filter: "Category=\"Socks5Proxy\""));

Task("SmokeTests")
.DoesForEach(
GetFiles("./**/SmokeTests/**/*.SmokeTests*.csproj"),
action: (BuildConfig buildConfig, Path testProject) =>
{
var environmentVariables = new Dictionary<string, string>
{
{ "SmokeTestsPackageSha", gitVersion.Sha }
};

var toolSettings = new DotNetToolSettings { EnvironmentVariables = environmentVariables };

Information($"Updating MongoDB package: {buildConfig.PackageVersion} sha: {gitVersion.Sha}");

DotNetTool(
testProject.FullPath,
"add package MongoDB.Driver",
$"--no-restore --version [{buildConfig.PackageVersion}]",
toolSettings);

DotNetTool(
testProject.FullPath,
"add package MongoDB.Driver.Encryption",
$"--no-restore --version [{buildConfig.PackageVersion}]",
toolSettings);

RunTests(
buildConfig,
testProject,
settings =>
{
settings.NoBuild = false;
settings.NoRestore = false;
settings.EnvironmentVariables = environmentVariables;
});
});

Setup<BuildConfig>(
setupContext =>
{
Expand Down
22 changes: 22 additions & 0 deletions evergreen/append-myget-package-source.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

# add/adjust nuget.config pointing to myget so intermediate versions could be restored
if [ -f "./nuget.config" ]; then
echo "Adding myget into nuget.config"
NUGET_SOURCES=$(dotnet nuget list source --format short)
if [[ ${NUGET_SOURCES} != *"https://www.myget.org/F/mongodb/api/v3/index.json"* ]];then
dotnet nuget add source https://www.myget.org/F/mongodb/api/v3/index.json -n myget.org --configfile ./nuget.config
fi
else
echo "Creating custom nuget.config"
cat > "nuget.config" << EOL
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="myget.org" value="https://www.myget.org/F/mongodb/api/v3/index.json" />
</packageSources>
</configuration>
EOL
fi
5 changes: 3 additions & 2 deletions evergreen/compile-sources.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env bash
set -o errexit # Exit the script with error if any of the commands fail

SOURCE_PROJECT=${1:-CSharpDriver.sln}
if [ -z "$PACKAGE_VERSION" ]; then
PACKAGE_VERSION=$(bash ./evergreen/get-version.sh)
echo Calculated PACKAGE_VERSION value: "$PACKAGE_VERSION"
Expand All @@ -13,7 +14,7 @@ for (( ATTEMPT=1; ATTEMPT<=RESTORE_MAX_RETRIES; ATTEMPT++ ))
do
echo "Attempt $ATTEMPT of $RESTORE_MAX_RETRIES to run dotnet restore..."
exit_status=0
dotnet restore || exit_status=$?
dotnet restore "${SOURCE_PROJECT}" --verbosity normal || exit_status=$?
if [[ "$exit_status" -eq 0 ]]; then
echo "dotnet restore succeeded."
break
Expand All @@ -29,4 +30,4 @@ do
sleep $DELAY
done

dotnet build -c Release --no-restore -p:Version="$PACKAGE_VERSION"
dotnet build "${SOURCE_PROJECT}" -c Release --no-restore -p:Version="$PACKAGE_VERSION"
10 changes: 1 addition & 9 deletions evergreen/evergreen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -728,17 +728,9 @@ functions:
script: |
set +x
${PREPARE_SHELL}
AUTH=${AUTH} \
SSL=${SSL} \
MONGODB_URI="${MONGODB_URI}" \
TOPOLOGY=${TOPOLOGY} \
OS=${OS} \
COMPRESSOR=${COMPRESSOR} \
CLIENT_PEM=${DRIVERS_TOOLS}/.evergreen/x509gen/client.pem \
REQUIRE_API_VERSION=${REQUIRE_API_VERSION} \
TARGET="SmokeTests" \
FRAMEWORK=${FRAMEWORK} \
evergreen/run-tests.sh
evergreen/run-smoke-tests.sh "${PACKAGE_VERSION}"

run-test-SK:
- command: shell.exec
Expand Down
20 changes: 1 addition & 19 deletions evergreen/run-external-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,7 @@ echo "Cloning the remote repo..."
git clone -b "${GIT_BRANCH:-main}" --single-branch "${GIT_REPO}" .

# add/adjust nuget.config pointing to myget so intermediate versions could be restored
if [ -f "./nuget.config" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

+1

echo "Adding myget into nuget.config"
NUGET_SOURCES=$(dotnet nuget list source --format short)
if [[ ${NUGET_SOURCES} != *"https://www.myget.org/F/mongodb/api/v3/index.json"* ]];then
dotnet nuget add source https://www.myget.org/F/mongodb/api/v3/index.json -n myget.org --configfile ./nuget.config
fi
else
echo "Creating custom nuget.config"
cat > "nuget.config" << EOL
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="myget.org" value="https://www.myget.org/F/mongodb/api/v3/index.json" />
</packageSources>
</configuration>
EOL
fi
. "${PROJECT_DIRECTORY}/evergreen/append-myget-package-source.sh"

# make files executable
echo "Making files executable"
Expand Down
16 changes: 16 additions & 0 deletions evergreen/run-smoke-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

SMOKE_TESTS_PROJECT="./tests/SmokeTests/MongoDB.Driver.SmokeTests.Sdk/MongoDB.Driver.SmokeTests.Sdk.csproj"
Copy link
Contributor

Choose a reason for hiding this comment

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

We'll probably need few smoke tests projects, so need to be ready for that.

Copy link
Member Author

Choose a reason for hiding this comment

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

The idea is: we should not build another projects (like a driver or bson library). For now we have only one project, in case we will have more then one - we can make a loop in bash script, and maintain either list of projects, or we can do a glob-filter by folder.


DRIVER_PACKAGE_VERSION="$1"
if [ -z "$DRIVER_PACKAGE_VERSION" ]; then
echo "Driver package version should be provided."
exit 1
fi

. ./evergreen/append-myget-package-source.sh

export DRIVER_PACKAGE_VERSION="${DRIVER_PACKAGE_VERSION}"
. ./evergreen/compile-sources.sh "$SMOKE_TESTS_PROJECT"

dotnet test "$SMOKE_TESTS_PROJECT" -c Release --no-build -f "$FRAMEWORK" --results-directory ./build/test-results --logger "junit;verbosity=detailed;LogFileName=TEST-{assembly}.xml;FailureBodyFormat=Verbose" --logger "console;verbosity=detailed"
20 changes: 0 additions & 20 deletions evergreen/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,26 +141,6 @@ if [ -f "$DRIVERS_TOOLS/.evergreen/csfle/secrets-export.sh" ]; then
source $DRIVERS_TOOLS/.evergreen/csfle/secrets-export.sh
fi

if [[ "$TARGET" =~ "SmokeTests" ]]; then
# add/adjust nuget.config pointing to myget so intermediate versions could be restored
if [ -f "./nuget.config" ]; then
echo "Adding myget into nuget.config"
dotnet nuget add source https://www.myget.org/F/mongodb/api/v3/index.json -n myget.org --configfile ./nuget.config
else
echo "Creating custom nuget.config"
cat > "nuget.config" << EOL
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="myget.org" value="https://www.myget.org/F/mongodb/api/v3/index.json" />
</packageSources>
</configuration>
EOL
fi
fi

. ./evergreen/compile-sources.sh
if [[ "$OS" =~ Windows|windows ]]; then
powershell.exe .\\build.ps1 --target=$TARGET
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using FluentAssertions;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using MongoDB.Driver.Encryption;

namespace MongoDB.Driver.SmokeTests.Sdk
{
Expand All @@ -31,23 +29,6 @@ internal static class InfrastructureUtilities
Environment.GetEnvironmentVariable("MONGO_URI") ??
"mongodb://localhost";

public static void ValidateMongoDBPackageVersion()
{
var packageShaExpected = Environment.GetEnvironmentVariable("SmokeTestsPackageSha");

if (!string.IsNullOrEmpty(packageShaExpected))
{
var driverFileVersionInfo = FileVersionInfo.GetVersionInfo(typeof(MongoClient).Assembly.Location);
var libmongocryptFileVersionInfo = FileVersionInfo.GetVersionInfo(typeof(ClientEncryption).Assembly.Location);

driverFileVersionInfo.ProductVersion?.Contains(packageShaExpected)
.Should().BeTrue("Expected package sha {0} in {1} for driver package version.", packageShaExpected, driverFileVersionInfo.ProductVersion);

libmongocryptFileVersionInfo.ProductVersion?.Contains(packageShaExpected)
.Should().BeTrue("Expected package sha {0} in {1} for libmongocrypt package version.", packageShaExpected, libmongocryptFileVersionInfo.ProductVersion);
}
}

public static void AssertLogs(LogEntry[] expectedLogs, LogEntry[] actualLogs)
{
var actualLogIndex = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public class LibmongocryptTests

public LibmongocryptTests(ITestOutputHelper output)
{
InfrastructureUtilities.ValidateMongoDBPackageVersion();
MongoClientSettings.Extensions.AddAutoEncryption();
_output = output;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public sealed class LoggingTests

public LoggingTests(ITestOutputHelper output)
{
InfrastructureUtilities.ValidateMongoDBPackageVersion();
_output = output;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,11 @@
<CodeAnalysisRuleSet>..\..\..\MongoDBTest.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

<PropertyGroup Condition="'$(SmokeTestsPackageSha)' != ''">
<UsePackageReferences>true</UsePackageReferences>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MongoDB.Driver" Version="[0.0.0.0]" Condition="'$(UsePackageReferences)' == 'true'" />
<PackageReference Include="MongoDB.Driver.Encryption" Version="[0.0.0.0]" Condition="'$(UsePackageReferences)' == 'true'" />
<ProjectReference Include="..\..\..\src\MongoDB.Driver\MongoDB.Driver.csproj" Condition="'$(UsePackageReferences)' != 'true'" />
<ProjectReference Include="..\..\..\src\MongoDB.Driver.Encryption\MongoDB.Driver.Encryption.csproj" Condition="'$(UsePackageReferences)' != 'true'" />
<PackageReference Include="MongoDB.Driver" Version="$(DRIVER_PACKAGE_VERSION)" Condition="'$(DRIVER_PACKAGE_VERSION)' != ''" />
<PackageReference Include="MongoDB.Driver.Encryption" Version="$(DRIVER_PACKAGE_VERSION)" Condition="'$(DRIVER_PACKAGE_VERSION)' != ''" />
<ProjectReference Include="..\..\..\src\MongoDB.Driver\MongoDB.Driver.csproj" Condition="'$(DRIVER_PACKAGE_VERSION)' == ''" />
<ProjectReference Include="..\..\..\src\MongoDB.Driver.Encryption\MongoDB.Driver.Encryption.csproj" Condition="'$(DRIVER_PACKAGE_VERSION)' == ''" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/* Copyright 2010-present MongoDB Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

using System;
using System.Reflection;
using FluentAssertions;
using MongoDB.Driver.Encryption;
using Xunit;
using Xunit.Sdk;

namespace MongoDB.Driver.SmokeTests.Sdk
{
public class ValidatePackagesVersionTests
{
private readonly string _packageVersion;

public ValidatePackagesVersionTests()
{
_packageVersion = Environment.GetEnvironmentVariable("DRIVER_PACKAGE_VERSION");
}

[Fact]
public void ValidateDriverPackageVersion() =>
ValidateAssemblyInformationalVersion(typeof(MongoClient).Assembly, _packageVersion);

[Fact]
public void ValidateEncryptionPackageVersion() =>
ValidateAssemblyInformationalVersion(typeof(ClientEncryption).Assembly, _packageVersion);

private static void ValidateAssemblyInformationalVersion(Assembly assembly, string expectedVersion)
{
if (string.IsNullOrEmpty(expectedVersion))
{
return;
}

var assemblyInformationAttribute = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
assemblyInformationAttribute.Should().NotBeNull();
assemblyInformationAttribute.InformationalVersion.Should().StartWith(expectedVersion);
}
}
}