diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a844530e3..41381aac3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -94,7 +94,7 @@ In both cases, the `CASSANDRA_VERSION` environment variable determines which ser ## Building the driver and running tests -DataStax C# drivers target .NET Framework 4.5.2 and .NET Standard 2.0. The test projects target .NET Framework 4.6.2, 4.7.2, 4.8.1 and .NET 6, 7 and 8. To run the code analyzers you need the .NET 8 SDK. +DataStax C# drivers target .NET Standard 2.0. The test projects target .NET 6, 7 and 8. To run the code analyzers you need the .NET 8 SDK. ### Prerequisites @@ -115,7 +115,7 @@ dotnet restore src dotnet build src/Cassandra.sln ``` -On Windows, the command `dotnet build src/Cassandra.sln` should succeed while on macOS / Linux it may fail due to the lack of support for .NET Framework builds on non-Windows platforms. In these environments you need to specify a .NET target framework in order to successfully build the project. +The command `dotnet build src/Cassandra.sln` should succeed. Otherwise, you need to specify a .NET target framework in order to successfully build the project. You can build specific projects against specific target frameworks on any platform like this: @@ -133,11 +133,8 @@ Alternatively you can set the `BuildCoreOnly` environment variable which will ca dotnet test src/Cassandra.Tests/Cassandra.Tests.csproj -f net8 ``` -The target frameworks supported by the test projects are `net8` and `net481` (by default). If you set the `BuildAllTargets` environment variable, the test projects will support these targets: +The target framework supported by the test projects is `net8` (by default). If you set the `BuildAllTargets` environment variable, the test projects will support these targets: -- `net462` -- `net472` -- `net481` - `net6` - `net7`(not LTS, might be removed at some point) - `net8` diff --git a/Jenkinsfile b/Jenkinsfile index 4b9fc80e9..11dfeaccb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -150,7 +150,7 @@ ENVIRONMENT_EOF ''' } - if (env.SERVER_VERSION == env.SERVER_VERSION_SNI && env.DOTNET_VERSION != 'mono') { + if (env.SERVER_VERSION == env.SERVER_VERSION_SNI) { sh label: 'Update environment for SNI proxy tests', script: '''#!/bin/bash -le # Load CCM and driver configuration environment variables set -o allexport @@ -172,11 +172,7 @@ ENVIRONMENT_EOF . ${HOME}/environment.txt set +o allexport - if [ ${DOTNET_VERSION} = 'mono' ]; then - mono --version - else - dotnet --version - fi + dotnet --version printenv | sort ''' } @@ -201,18 +197,6 @@ def installDependencies() { mkdir saxon curl -L -o saxon/saxon9he.jar https://repo1.maven.org/maven2/net/sf/saxon/Saxon-HE/9.8.0-12/Saxon-HE-9.8.0-12.jar ''' - - if (env.DOTNET_VERSION == 'mono') { - sh label: 'Install required packages for mono builds', script: '''#!/bin/bash -le - # Define alias for Nuget - nuget() { - mono /usr/local/bin/nuget.exe "$@" - } - export -f nuget - - nuget install NUnit.Runners -Version 3.6.1 -OutputDirectory testrunner - ''' - } } } @@ -223,26 +207,14 @@ def buildDriver() { dotnet restore src ''' } else { - if (env.DOTNET_VERSION == 'mono') { - sh label: 'Build the driver for mono', script: '''#!/bin/bash -le - export BuildMonoOnly=True - export RunCodeAnalyzers=False - export MSBuildSDKsPath=/home/jenkins/dotnetcli/sdk/$(dotnet --version)/Sdks - msbuild /t:restore /v:m /p:RestoreDisableParallel=true src/Cassandra.sln || true - msbuild /t:restore /v:m /p:RestoreDisableParallel=true src/Cassandra.sln - msbuild /p:Configuration=Release /v:m /p:RestoreDisableParallel=true /p:DynamicConstants=LINUX src/Cassandra.sln || true - msbuild /p:Configuration=Release /v:m /p:RestoreDisableParallel=true /p:DynamicConstants=LINUX src/Cassandra.sln - ''' - } else { - sh label: "Work around nuget issue", script: '''#!/bin/bash -le - mkdir -p /tmp/NuGetScratch - chmod -R ugo+rwx /tmp/NuGetScratch - ''' - sh label: "Install required packages and build the driver for ${env.DOTNET_VERSION}", script: '''#!/bin/bash -le - dotnet restore src || true - dotnet restore src - ''' - } + sh label: "Work around nuget issue", script: '''#!/bin/bash -le + mkdir -p /tmp/NuGetScratch + chmod -R ugo+rwx /tmp/NuGetScratch + ''' + sh label: "Install required packages and build the driver for ${env.DOTNET_VERSION}", script: '''#!/bin/bash -le + dotnet restore src || true + dotnet restore src + ''' } } @@ -250,10 +222,8 @@ def executeTests(perCommitSchedule) { if (perCommitSchedule) { env.DOTNET_TEST_FILTER = "(TestCategory!=long)&(TestCategory!=memory)&(TestCategory!=realclusterlong)" - env.MONO_TEST_FILTER = "cat != long && cat != memory && cat != realclusterlong" } else { env.DOTNET_TEST_FILTER = "(TestCategory!=long)&(TestCategory!=memory)" - env.MONO_TEST_FILTER = "cat != long && cat != memory" } if (env.OS_VERSION.split('/')[0] == 'win') { @@ -268,50 +238,28 @@ def executeTests(perCommitSchedule) { java -jar saxon/saxon9he.jar -o:TestResult.xml TestResult_xunit.xml tools/JUnitXml.xslt ''' } else { - if (env.DOTNET_VERSION == 'mono') { - catchError { - sh label: 'Execute tests for mono', script: '''#!/bin/bash -le - # Load CCM and driver configuration environment variables - set -o allexport - . ${HOME}/environment.txt - set +o allexport - - # Fix Java version at Java8 for now because of dependencies in DSE. - # TODO: This should last us through testing against Cassandra 4.1.x at least but - # will eventually need to be made more generic. - . ${JABBA_SHELL} - jabba use 1.8 - - mono ./testrunner/NUnit.ConsoleRunner.3.6.1/tools/nunit3-console.exe src/Cassandra.IntegrationTests/bin/Release/net462/Cassandra.IntegrationTests.dll --where "$MONO_TEST_FILTER" --labels=All --result:"TestResult_nunit.xml" - ''' - } - sh label: 'Convert the test results using saxon', script: '''#!/bin/bash -le - java -jar saxon/saxon9he.jar -o:TestResult.xml TestResult_nunit.xml tools/nunit3-junit.xslt - ''' - } else { - catchError { - sh label: "Execute tests for ${env.DOTNET_VERSION}", script: '''#!/bin/bash -le - # Load CCM and driver configuration environment variables - set -o allexport - . ${HOME}/environment.txt - set +o allexport - - # Fix Java version at Java8 for now because of dependencies in DSE. - # TODO: This should last us through testing against Cassandra 4.1.x at least but - # will eventually need to be made more generic. - . ${JABBA_SHELL} - jabba use 1.8 - - export OPENSSL_CONF=/home/jenkins/openssl.cnf - - dotnet test src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj -v n -f ${DOTNET_VERSION} -c Release --filter $DOTNET_TEST_FILTER --logger "xunit;LogFilePath=../../TestResult_xunit.xml" - ''' - } - sh label: 'Convert the test results using saxon', script: '''#!/bin/bash -le - java -jar saxon/saxon9he.jar -o:TestResult.xml TestResult_xunit.xml tools/JUnitXml.xslt + catchError { + sh label: "Execute tests for ${env.DOTNET_VERSION}", script: '''#!/bin/bash -le + # Load CCM and driver configuration environment variables + set -o allexport + . ${HOME}/environment.txt + set +o allexport + + # Fix Java version at Java8 for now because of dependencies in DSE. + # TODO: This should last us through testing against Cassandra 4.1.x at least but + # will eventually need to be made more generic. + . ${JABBA_SHELL} + jabba use 1.8 + + export OPENSSL_CONF=/home/jenkins/openssl.cnf + + dotnet test src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj -v n -f ${DOTNET_VERSION} -c Release --filter $DOTNET_TEST_FILTER --logger "xunit;LogFilePath=../../TestResult_xunit.xml" ''' - } - } + } + sh label: 'Convert the test results using saxon', script: '''#!/bin/bash -le + java -jar saxon/saxon9he.jar -o:TestResult.xml TestResult_xunit.xml tools/JUnitXml.xslt + ''' + } } def notifySlack(status = 'started') { @@ -448,27 +396,13 @@ pipeline { values '3.11', // latest 3.11.x Apache Cassandra� '4.1', // latest 4.x Apache Cassandra� '5.0', // Development Apache Cassandra� - 'dse-5.1.35', // latest 5.1.x DataStax Enterprise - 'dse-6.8.30', // latest 6.7.x DataStax Enterprise - 'dse-6.9.3', // latest DataStax Enterprise - 'hcd-1.0.0' // Hyper-Converged Database } axis { name 'DOTNET_VERSION' - values 'mono', 'net8', 'net6' + values 'net8', 'net6' } } excludes { - exclude { - axis { - name 'DOTNET_VERSION' - values 'mono' - } - axis { - name 'SERVER_VERSION' - values '3.11', '4.1', 'dse-5.1.35', 'dse-6.8.30' - } - } exclude { axis { name 'DOTNET_VERSION' @@ -476,7 +410,7 @@ pipeline { } axis { name 'SERVER_VERSION' - values '3.11', '5.0', 'dse-6.9.3', 'hcd-1.0.0' + values '3.11', '5.0' } } } diff --git a/Jenkinsfile.scheduled b/Jenkinsfile.scheduled index 581bd4f49..9911a6cdf 100644 --- a/Jenkinsfile.scheduled +++ b/Jenkinsfile.scheduled @@ -6,9 +6,6 @@ def initializeEnvironment() { if (env.GIT_URL.contains('riptano/csharp-driver')) { env.DRIVER_DISPLAY_NAME = 'private ' + env.DRIVER_DISPLAY_NAME env.DRIVER_METRIC_TYPE = 'oss-private' - } else if (env.GIT_URL.contains('csharp-dse-driver')) { - env.DRIVER_DISPLAY_NAME = 'DSE C# Driver' - env.DRIVER_METRIC_TYPE = 'dse' } env.GIT_SHA = "${env.GIT_COMMIT.take(7)}" @@ -43,19 +40,6 @@ def initializeEnvironment() { "$newData" | Out-File -filepath $Env:HOME\\driver-environment.ps1 ''' - if (env.SERVER_VERSION.split('-')[0] == 'dse') { - powershell label: 'Update environment for DataStax Enterprise', script: ''' - . $Env:HOME\\driver-environment.ps1 - - $newData = "`r`n`$Env:DSE_BRANCH=`"$Env:CCM_BRANCH`"" - $newData += "`r`n`$Env:DSE_VERSION=`"$Env:CCM_VERSION`"" - $newData += "`r`n`$Env:DSE_INITIAL_IPPREFIX=`"127.0.0.`"" - $newData += "`r`n`$Env:DSE_IN_REMOTE_SERVER=`"false`"" - - "$newData" | Out-File -filepath $Env:HOME\\driver-environment.ps1 -append - ''' - } - if (env.SERVER_VERSION == env.SERVER_VERSION_SNI_WINDOWS) { powershell label: 'Update environment for SNI proxy tests', script: ''' $newData = "`r`n`$Env:SNI_ENABLED=`"true`"" @@ -109,47 +93,8 @@ Ciphersuites = TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_G OPENSSL_EOF echo "OPENSSL_CONF=/home/jenkins/openssl.cnf" >> ${HOME}/environment.txt ''' - if (env.SERVER_VERSION.split('-')[0] == 'dse') { - env.DSE_FIXED_VERSION = env.SERVER_VERSION.split('-')[1] - sh label: 'Update environment for DataStax Enterprise', script: '''#!/bin/bash -le - rm ${HOME}/.ccm/config - cat > ${HOME}/.ccm/config << CONF_EOL -[repositories] -cassandra = https://repo.aws.dsinternal.org/artifactory/apache-mirror/cassandra -dse = http://repo-public.aws.dsinternal.org/tar/enterprise/dse-%s-bin.tar.gz -ddac = http://repo-public.aws.dsinternal.org/tar/enterprise/ddac-%s-bin.tar.gz -CONF_EOL - - cat >> ${HOME}/environment.txt << ENVIRONMENT_EOF -CCM_PATH=${HOME}/ccm -DSE_INITIAL_IPPREFIX=127.0.0. -DSE_IN_REMOTE_SERVER=false -CCM_CASSANDRA_VERSION=${DSE_FIXED_VERSION} # maintain for backwards compatibility -CCM_VERSION=${DSE_FIXED_VERSION} -CCM_SERVER_TYPE=dse -DSE_VERSION=${DSE_FIXED_VERSION} -CCM_DISTRIBUTION=dse -CASSANDRA_VERSION=${DSE_FIXED_VERSION} -CCM_BRANCH=${DSE_FIXED_VERSION} -DSE_BRANCH=${DSE_FIXED_VERSION} -JDK=1.8 -ENVIRONMENT_EOF - ''' - } - - if (env.SERVER_VERSION.split('-')[0] == 'hcd') { - env.HCD_FIXED_VERSION = env.SERVER_VERSION.split('-')[1] - sh label: 'Update environment for HCD', script: '''#!/bin/bash -le - cat >> ${HOME}/environment.txt << ENVIRONMENT_EOF -CCM_PATH=${HOME}/ccm -CCM_CASSANDRA_VERSION=${HCD_FIXED_VERSION} # maintain for backwards compatibility -CASSANDRA_VERSION=${HCD_FIXED_VERSION} -CCM_DISTRIBUTION=hcd -ENVIRONMENT_EOF - ''' - } - if (env.SERVER_VERSION == env.SERVER_VERSION_SNI && env.DOTNET_VERSION != 'mono') { + if (env.SERVER_VERSION == env.SERVER_VERSION_SNI) { sh label: 'Update environment for SNI proxy tests', script: '''#!/bin/bash -le # Load CCM and driver configuration environment variables set -o allexport @@ -171,11 +116,7 @@ ENVIRONMENT_EOF . ${HOME}/environment.txt set +o allexport - if [ ${DOTNET_VERSION} = 'mono' ]; then - mono --version - else - dotnet --version - fi + dotnet --version printenv | sort ''' } @@ -200,18 +141,6 @@ def installDependencies() { mkdir saxon curl -L -o saxon/saxon9he.jar https://repo1.maven.org/maven2/net/sf/saxon/Saxon-HE/9.8.0-12/Saxon-HE-9.8.0-12.jar ''' - - if (env.DOTNET_VERSION == 'mono') { - sh label: 'Install required packages for mono builds', script: '''#!/bin/bash -le - # Define alias for Nuget - nuget() { - mono /usr/local/bin/nuget.exe "$@" - } - export -f nuget - - nuget install NUnit.Runners -Version 3.6.1 -OutputDirectory testrunner - ''' - } } } @@ -222,26 +151,14 @@ def buildDriver() { dotnet restore src ''' } else { - if (env.DOTNET_VERSION == 'mono') { - sh label: 'Build the driver for mono', script: '''#!/bin/bash -le - export BuildMonoOnly=True - export RunCodeAnalyzers=False - export MSBuildSDKsPath=/home/jenkins/dotnetcli/sdk/$(dotnet --version)/Sdks - msbuild /t:restore /v:m /p:RestoreDisableParallel=true src/Cassandra.sln || true - msbuild /t:restore /v:m /p:RestoreDisableParallel=true src/Cassandra.sln - msbuild /p:Configuration=Release /v:m /p:RestoreDisableParallel=true /p:DynamicConstants=LINUX src/Cassandra.sln || true - msbuild /p:Configuration=Release /v:m /p:RestoreDisableParallel=true /p:DynamicConstants=LINUX src/Cassandra.sln - ''' - } else { - sh label: "Work around nuget issue", script: '''#!/bin/bash -le - mkdir -p /tmp/NuGetScratch - chmod -R ugo+rwx /tmp/NuGetScratch - ''' - sh label: "Install required packages and build the driver for ${env.DOTNET_VERSION}", script: '''#!/bin/bash -le - dotnet restore src || true - dotnet restore src - ''' - } + sh label: "Work around nuget issue", script: '''#!/bin/bash -le + mkdir -p /tmp/NuGetScratch + chmod -R ugo+rwx /tmp/NuGetScratch + ''' + sh label: "Install required packages and build the driver for ${env.DOTNET_VERSION}", script: '''#!/bin/bash -le + dotnet restore src || true + dotnet restore src + ''' } } @@ -249,10 +166,8 @@ def executeTests(perCommitSchedule) { if (perCommitSchedule) { env.DOTNET_TEST_FILTER = "(TestCategory!=long)&(TestCategory!=memory)&(TestCategory!=realclusterlong)" - env.MONO_TEST_FILTER = "cat != long && cat != memory && cat != realclusterlong" } else { env.DOTNET_TEST_FILTER = "(TestCategory!=long)&(TestCategory!=memory)" - env.MONO_TEST_FILTER = "cat != long && cat != memory" } if (env.OS_VERSION.split('/')[0] == 'win') { @@ -267,49 +182,27 @@ def executeTests(perCommitSchedule) { java -jar saxon/saxon9he.jar -o:TestResult.xml TestResult_xunit.xml tools/JUnitXml.xslt ''' } else { - if (env.DOTNET_VERSION == 'mono') { - catchError { - sh label: 'Execute tests for mono', script: '''#!/bin/bash -le - # Load CCM and driver configuration environment variables - set -o allexport - . ${HOME}/environment.txt - set +o allexport - - # Fix Java version at Java8 for now because of dependencies in DSE. - # TODO: This should last us through testing against Cassandra 4.1.x at least but - # will eventually need to be made more generic. - . ${JABBA_SHELL} - jabba use 1.8 - - mono ./testrunner/NUnit.ConsoleRunner.3.6.1/tools/nunit3-console.exe src/Cassandra.IntegrationTests/bin/Release/net462/Cassandra.IntegrationTests.dll --where "$MONO_TEST_FILTER" --labels=All --result:"TestResult_nunit.xml" - ''' - } - sh label: 'Convert the test results using saxon', script: '''#!/bin/bash -le - java -jar saxon/saxon9he.jar -o:TestResult.xml TestResult_nunit.xml tools/nunit3-junit.xslt - ''' - } else { - catchError { - sh label: "Execute tests for ${env.DOTNET_VERSION}", script: '''#!/bin/bash -le - # Load CCM and driver configuration environment variables - set -o allexport - . ${HOME}/environment.txt - set +o allexport - - # Fix Java version at Java8 for now because of dependencies in DSE. - # TODO: This should last us through testing against Cassandra 4.1.x at least but - # will eventually need to be made more generic. - . ${JABBA_SHELL} - jabba use 1.8 - - export OPENSSL_CONF=/home/jenkins/openssl.cnf - - dotnet test src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj -v n -f ${DOTNET_VERSION} -c Release --filter $DOTNET_TEST_FILTER --logger "xunit;LogFilePath=../../TestResult_xunit.xml" - ''' - } - sh label: 'Convert the test results using saxon', script: '''#!/bin/bash -le - java -jar saxon/saxon9he.jar -o:TestResult.xml TestResult_xunit.xml tools/JUnitXml.xslt + catchError { + sh label: "Execute tests for ${env.DOTNET_VERSION}", script: '''#!/bin/bash -le + # Load CCM and driver configuration environment variables + set -o allexport + . ${HOME}/environment.txt + set +o allexport + + # Fix Java version at Java8 for now because of dependencies in DSE. + # TODO: This should last us through testing against Cassandra 4.1.x at least but + # will eventually need to be made more generic. + . ${JABBA_SHELL} + jabba use 1.8 + + export OPENSSL_CONF=/home/jenkins/openssl.cnf + + dotnet test src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj -v n -f ${DOTNET_VERSION} -c Release --filter $DOTNET_TEST_FILTER --logger "xunit;LogFilePath=../../TestResult_xunit.xml" ''' - } + } + sh label: 'Convert the test results using saxon', script: '''#!/bin/bash -le + java -jar saxon/saxon9he.jar -o:TestResult.xml TestResult_xunit.xml tools/JUnitXml.xslt + ''' } } @@ -481,29 +374,13 @@ pipeline { '4.0', // Previous 4.0.x Apache Cassandra� '4.1', // Latest 4.1.x Apache Cassandra� '5.0', // Development Apache Cassandra� - 'dse-5.1.35', // Legacy DataStax Enterprise - 'dse-6.0.18', // Previous DataStax Enterprise - 'dse-6.7.17', // Previous DataStax Enterprise - 'dse-6.8.30', // Previous DataStax Enterprise - 'dse-6.9.3', // Latest DataStax Enterprise - 'hcd-1.0.0' // Hyper-Converged Database } axis { name 'DOTNET_VERSION' - values 'mono', 'net6', 'net7', 'net8' + values 'net6', 'net7', 'net8' } } excludes { - exclude { - axis { - name 'DOTNET_VERSION' - values 'mono' - } - axis { - name 'SERVER_VERSION' - values '2.1', '3.0', 'dse-6.0.18' - } - } exclude { axis { name 'DOTNET_VERSION' @@ -511,17 +388,7 @@ pipeline { } axis { name 'SERVER_VERSION' - values '2.1', '2.2', '3.0', '5.0', 'dse-5.1.35', 'dse-6.0.18' - } - } - exclude { - axis { - name 'DOTNET_VERSION' - values 'net7' - } - axis { - name 'SERVER_VERSION' - values 'dse-6.7.17' + values '2.1', '2.2', '3.0', '5.0' } } } @@ -594,14 +461,9 @@ pipeline { } // # Building on Windows - // # - Do not build using mono - // # - Target Apache Cassandra� v3.11.x for net8 and net481 - // # - Target Apache Cassandra� v2.1.x, v2.2.x, v3.11.x for net462 - // # - Target Apache Cassandra� v2.2.x, v3.11.x for net472 + // # - Target Apache Cassandra� v3.11.x for net8 // ## // H 2 * * 1-5 %CI_SCHEDULE=NIGHTLY;CI_SCHEDULE_DOTNET_VERSION=netcoreapp2.1;CI_SCHEDULE_SERVER_VERSION=3.11;CI_SCHEDULE_OS_VERSION=win/cs - // H 2 * * 1-5 %CI_SCHEDULE=NIGHTLY;CI_SCHEDULE_DOTNET_VERSION=net452;CI_SCHEDULE_SERVER_VERSION=2.1 2.2 3.11;CI_SCHEDULE_OS_VERSION=win/cs - // H 2 * * 1-5 %CI_SCHEDULE=NIGHTLY;CI_SCHEDULE_DOTNET_VERSION=net461;CI_SCHEDULE_SERVER_VERSION=2.2 3.11;CI_SCHEDULE_OS_VERSION=win/cs matrix { axes { axis { @@ -615,20 +477,10 @@ pipeline { } axis { name 'DOTNET_VERSION' - values 'net8', 'net462', 'net472', 'net481' + values 'net8' } } excludes { - exclude { - axis { - name 'DOTNET_VERSION' - values 'net472' - } - axis { - name 'SERVER_VERSION' - values '2.1', '3.11' - } - } exclude { axis { name 'DOTNET_VERSION' @@ -639,16 +491,6 @@ pipeline { values '2.1', '2.2' } } - exclude { - axis { - name 'DOTNET_VERSION' - values 'net481' - } - axis { - name 'SERVER_VERSION' - values '2.1', '2.2', '5.0' - } - } } agent { @@ -729,16 +571,10 @@ pipeline { '4.0', // Previous 4.0.x Apache Cassandra� '4.1', // Latest 4.1.x Apache Cassandra� '5.0', // Development Apache Cassandra� - 'dse-5.1.35', // Legacy DataStax Enterprise - 'dse-6.0.18', // Previous DataStax Enterprise - 'dse-6.7.17', // Previous DataStax Enterprise - 'dse-6.8.30', // Previous DataStax Enterprise - 'dse-6.9.3', // Latest DataStax Enterprise - 'hcd-1.0.0' // Hyper-Converged Database } axis { name 'DOTNET_VERSION' - values 'mono', 'net6', 'net7', 'net8' + values 'net6', 'net7', 'net8' } } excludes { @@ -749,7 +585,7 @@ pipeline { } axis { name 'SERVER_VERSION' - values '2.1', '2.2', 'dse-6.0.18', 'dse-5.1.35', '5.0' + values '2.1', '2.2', '5.0' } } exclude { @@ -759,7 +595,7 @@ pipeline { } axis { name 'SERVER_VERSION' - values '3.11', 'dse-6.7.17' + values '3.11' } } } @@ -844,14 +680,14 @@ pipeline { } axis { name 'DOTNET_VERSION' - values 'net6', 'net7', 'net8', 'net462', 'net472', 'net481' + values 'net6', 'net7', 'net8' } } excludes { exclude { axis { name 'DOTNET_VERSION' - values 'net472', 'net481', 'net6', 'net7' + values 'net6', 'net7' } axis { name 'SERVER_VERSION' @@ -861,7 +697,7 @@ pipeline { exclude { axis { name 'DOTNET_VERSION' - values 'net472', 'net481', 'net7' + values 'net7' } axis { name 'SERVER_VERSION' diff --git a/Makefile b/Makefile index 82a02f616..b1e225227 100644 --- a/Makefile +++ b/Makefile @@ -24,25 +24,25 @@ export SIMULACRON_PATH export SCYLLA_VERSION export SNK_FILE -check: .prepare-mono +check: dotnet format --verify-no-changes --severity warn --verbosity diagnostic src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj & \ dotnet format --verify-no-changes --severity warn --verbosity diagnostic src/Cassandra/Cassandra.csproj & \ dotnet format --verify-no-changes --severity warn --verbosity diagnostic src/Cassandra.Tests/Cassandra.Tests.csproj & \ wait -fix: .prepare-mono +fix: dotnet format --severity warn --verbosity diagnostic src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj & \ dotnet format --severity warn --verbosity diagnostic src/Cassandra/Cassandra.csproj & \ dotnet format --severity warn --verbosity diagnostic src/Cassandra.Tests/Cassandra.Tests.csproj & \ wait -test-unit: .use-development-snk .prepare-mono +test-unit: .use-development-snk dotnet test src/Cassandra.Tests/Cassandra.Tests.csproj -test-integration-scylla: .use-development-snk .prepare-mono .prepare-scylla-ccm +test-integration-scylla: .use-development-snk .prepare-scylla-ccm CCM_DISTRIBUTION=scylla dotnet test src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj -f net8 -l "console;verbosity=detailed" --filter "(FullyQualifiedName!~ClientWarningsTests & FullyQualifiedName!~CustomPayloadTests & FullyQualifiedName!~Connect_With_Ssl_Test & FullyQualifiedName!~Should_UpdateHosts_When_HostIpChanges & FullyQualifiedName!~Should_UseNewHostInQueryPlans_When_HostIsDecommissionedAndJoinsAgain & FullyQualifiedName!~Should_RemoveNodeMetricsAndDisposeMetricsContext_When_HostIsRemoved & FullyQualifiedName!~Virtual_Keyspaces_Are_Included & FullyQualifiedName!~Virtual_Table_Metadata_Test & FullyQualifiedName!~SessionAuthenticationTests & FullyQualifiedName!~TypeSerializersTests & FullyQualifiedName!~Custom_MetadataTest & FullyQualifiedName!~LinqWhere_WithVectors & FullyQualifiedName!~SimpleStatement_With_No_Compact_Enabled_Should_Reveal_Non_Schema_Columns & FullyQualifiedName!~SimpleStatement_With_No_Compact_Disabled_Should_Not_Reveal_Non_Schema_Columns & FullyQualifiedName!~ColumnClusteringOrderReversedTest & FullyQualifiedName!~GetMaterializedView_Should_Refresh_View_Metadata_Via_Events & FullyQualifiedName!~MaterializedView_Base_Table_Column_Addition & FullyQualifiedName!~MultipleSecondaryIndexTest & FullyQualifiedName!~RaiseErrorOnInvalidMultipleSecondaryIndexTest & FullyQualifiedName!~TableMetadataAllTypesTest & FullyQualifiedName!~TableMetadataClusteringOrderTest & FullyQualifiedName!~TableMetadataCollectionsSecondaryIndexTest & FullyQualifiedName!~TableMetadataCompositePartitionKeyTest & FullyQualifiedName!~TupleMetadataTest & FullyQualifiedName!~Udt_Case_Sensitive_Metadata_Test & FullyQualifiedName!~UdtMetadataTest & FullyQualifiedName!~Should_Retrieve_Table_Metadata & FullyQualifiedName!~CreateTable_With_Frozen_Key & FullyQualifiedName!~CreateTable_With_Frozen_Udt & FullyQualifiedName!~CreateTable_With_Frozen_Value & FullyQualifiedName!~Should_AllMetricsHaveValidValues_When_AllNodesAreUp & FullyQualifiedName!~SimpleStatement_Dictionary_Parameters_CaseInsensitivity_ExcessOfParams & FullyQualifiedName!~SimpleStatement_Dictionary_Parameters_CaseInsensitivity_NoOverload & FullyQualifiedName!~TokenAware_TransientReplication_NoHopsAndOnlyFullReplicas & FullyQualifiedName!~GetFunction_Should_Return_Most_Up_To_Date_Metadata_Via_Events & FullyQualifiedName!~LargeDataTests & FullyQualifiedName!~MetadataTests & FullyQualifiedName!~MultiThreadingTests & FullyQualifiedName!~PoolTests & FullyQualifiedName!~PrepareLongTests & FullyQualifiedName!~SpeculativeExecutionLongTests & FullyQualifiedName!~StressTests & FullyQualifiedName!~TransitionalAuthenticationTests & FullyQualifiedName!~ProxyAuthenticationTests & FullyQualifiedName!~CloudIntegrationTests & FullyQualifiedName!~CoreGraphTests & FullyQualifiedName!~GraphTests & FullyQualifiedName!~InsightsIntegrationTests & FullyQualifiedName!~DateRangeTests & FullyQualifiedName!~FoundBugTests & FullyQualifiedName!~GeometryTests & FullyQualifiedName!~LoadBalancingPolicyTests & FullyQualifiedName!~ConsistencyTests & FullyQualifiedName!~LoadBalancingPolicyTests & FullyQualifiedName!~ReconnectionPolicyTests & FullyQualifiedName!~RetryPolicyTests)" -test-integration-cassandra: .use-development-snk .prepare-mono .prepare-cassandra-ccm +test-integration-cassandra: .use-development-snk .prepare-cassandra-ccm CCM_DISTRIBUTION=cassandra dotnet test src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj -f net8 -l "console;verbosity=detailed" .prepare-cassandra-ccm: @@ -81,21 +81,6 @@ install-scylla-ccm: @echo SCYLLA > ${CCM_CONFIG_DIR}/ccm-type @echo ${CCM_SCYLLA_VERSION} > ${CCM_CONFIG_DIR}/ccm-version -.prepare-mono: - @if mono --version 2>/dev/null 1>&2; then \ - echo "Mono is already installed"; \ - else \ - echo "Installing Mono"; \ - sudo apt update; \ - sudo apt install -y mono-complete; \ - mono --version; \ - fi - -install-mono: - sudo apt update - sudo apt install -y mono-complete - mono --version - .use-development-snk: @[ -f build/scylladb.snk ] || ( cp build/scylladb-dev.snk build/scylladb.snk ) @@ -118,7 +103,7 @@ install-mono: grep 'ScyllaDBCSharpDriver.DRYRUN' $(PROJECT_PATH) || \ sed -Ei "s#ScyllaDBCSharpDriver(.*)#ScyllaDBCSharpDriver.DRYRUN\1#g" $(PROJECT_PATH) -.publish-proj-nuget: .prepare-mono .use-production-snk +.publish-proj-nuget: .use-production-snk ifndef DRY_RUN @echo "Publishing to NuGet with production SNK" else diff --git a/README.md b/README.md index 8f209d194..58085ea11 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ScyllaDB's fork of a modern, [feature-rich][features] and highly tunable C# client library for Scylla using Cassandra's binary protocol and Cassandra Query Language v3. -The driver targets .NET Framework 4.5.2 and .NET Standard 2.0. For more detailed information about platform compatibility, check [this section](#compatibility). +The driver targets .NET Standard 2.0. For more detailed information about platform compatibility, check [this section](#compatibility). ## Installation @@ -237,14 +237,14 @@ ICluster cluster = Cluster.Builder() - Apache Cassandra versions 2.0 and above. - ScyllaDB 5.x and above. - ScyllaDB Enterprise 2021.x and above. -- The driver targets .NET Framework 4.5.2 and .NET Standard 2.0 +- The driver targets .NET Standard 2.0 Here is a list of platforms and .NET targets that Datastax uses when testing this driver: -| Platform | net462 | net472 | net481 | net6 | net7 | net8 | -|-----------------------|--------|--------|--------|------|------|-------| -| Windows Server 2019³ | ✓ | ✓ | ✓ | ✓² | ✓¹ | ✓ | -| Ubuntu 18.04 | - | - | - | ✓ | ✓ | ✓ | +| Platform | net6 | net7 | net8 | +|-----------------------|------|------|-------| +| Windows Server 2019³ | ✓² | ✓¹ | ✓ | +| Ubuntu 18.04 | ✓ | ✓ | ✓ | ¹ No tests are run for the `net7` target on the Windows platform but `net7` is still considered fully supported. @@ -252,8 +252,6 @@ Here is a list of platforms and .NET targets that Datastax uses when testing thi ³ Appveyor's `Visual Studio 2022` image is used for these tests. -Mono `6.12.0` is also used to run `net462` tests on `Ubuntu 18.04` but Datastax can't guarantee that the driver fully supports Mono in a production environment. Datastax recommends the modern cross platform .NET platform instead. - Note: Big-endian systems are not supported. ## Building and running the tests diff --git a/appveyor.yml b/appveyor.yml index 79e164447..3bc38e211 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -13,37 +13,16 @@ environment: BuildAllTargets: "True" RunCodeAnalyzers: "True" matrix: - - TARGET: net462 - CI_TYPE: UNIT - PROJECT: Cassandra.Tests - - TARGET: net472 - CI_TYPE: UNIT - PROJECT: Cassandra.Tests - - TARGET: net481 - CI_TYPE: UNIT - PROJECT: Cassandra.Tests - TARGET: net6 CI_TYPE: UNIT PROJECT: Cassandra.Tests - TARGET: net8 CI_TYPE: UNIT PROJECT: Cassandra.Tests - - TARGET: net472 - CASSANDRA_VERSION: 3.11.6 - CI_TYPE: INTEGRATION - PROJECT: Cassandra.IntegrationTests - - TARGET: net462 - CASSANDRA_VERSION: 3.11.6 - CI_TYPE: INTEGRATION_FULL - PROJECT: Cassandra.IntegrationTests - TARGET: net8 CASSANDRA_VERSION: 3.11.6 CI_TYPE: INTEGRATION PROJECT: Cassandra.IntegrationTests - - TARGET: net481 - CASSANDRA_VERSION: 3.11.6 - CI_TYPE: INTEGRATION - PROJECT: Cassandra.IntegrationTests #init: # - ps: $blockRdp = $True; iex ((New-Object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) diff --git a/build.yaml b/build.yaml index 424829cbb..832f4daa1 100644 --- a/build.yaml +++ b/build.yaml @@ -8,17 +8,10 @@ schedules: exclude: # dont build on windows (windows provisioning takes too long, run only on nightly and weekly schedules) - os: 'win/cs' - # on linux dont build net452 and net461 - - os: 'ubuntu/bionic64/csharp-driver' - dotnet: ['net452', 'net461'] # on linux with netcoreapp2.1 target 2.2, 3.0 and 3.11 - os: 'ubuntu/bionic64/csharp-driver' dotnet: ['netcoreapp2.1'] cassandra: ['2.1', '4.0'] - # on linux with mono target 3.11 - - os: 'ubuntu/bionic64/csharp-driver' - dotnet: ['mono'] - cassandra: ['2.1', '2.2', '3.0', '4.0'] nightly-oss-ubuntu: # nightly job for primary branches to run almost all configs on ubuntu. schedule: adhoc @@ -30,14 +23,7 @@ schedules: matrix: exclude: - os: 'win/cs' - # on linux dont build net452 and net461 - - os: 'ubuntu/bionic64/csharp-driver' - dotnet: ['net452', 'net461'] # on linux with netcoreapp2.1 target all oss - # on linux with mono target 2.2 and 3.11 - - os: 'ubuntu/bionic64/csharp-driver' - dotnet: ['mono'] - cassandra: ['2.1', '3.0'] nightly-oss-windows: # nightly job for primary branches to run several configs on windows (windows builds are slow so it's less configs than the nightly ubuntu schedule). schedule: adhoc @@ -49,21 +35,10 @@ schedules: matrix: exclude: - os: 'ubuntu/bionic64/csharp-driver' - # on windows dont build mono - - os: 'win/cs' - dotnet: ['mono'] # on windows target 3.11 with netcoreapp2.1 - os: 'win/cs' dotnet: ['netcoreapp2.1'] cassandra: ['2.1', '2.2', '3.0'] - # on windows target 2.1, 2.2 and 3.11 - - os: 'win/cs' - dotnet: ['net452'] - cassandra: ['3.0'] - # on windows target 2.2 and 3.11 with net461 - - os: 'win/cs' - dotnet: ['net461'] - cassandra: ['2.1', '3.0'] adhoc: # adhoc job for non-primary braches that doesn't have the nightly and weekly schedules so this may be used to run same configs as the weekly schedule. schedule: adhoc @@ -71,30 +46,12 @@ schedules: slack: csharp-driver-dev-bots branches: exclude: ["/((\\d+(\\.[\\dx]+)+)|master)/"] - matrix: - exclude: - # on windows dont build mono - - os: 'win/cs' - dotnet: ['mono'] - # on linux dont build net452 and net461 - - os: 'ubuntu/bionic64/csharp-driver' - dotnet: ['net452', 'net461'] - # on linux target all weekly: schedule: adhoc notify: slack: csharp-driver-dev-bots branches: include: ["/((\\d+(\\.[\\dx]+)+)|master)/"] - matrix: - exclude: - # on windows dont build mono - - os: 'win/cs' - dotnet: ['mono'] - # on linux dont build net452 and net461 - - os: 'ubuntu/bionic64/csharp-driver' - dotnet: ['net452', 'net461'] - # on linux target all os: - ubuntu/bionic64/csharp-driver - win/cs @@ -105,10 +62,7 @@ cassandra: - '3.11' - '4.0' dotnet: - - 'mono' - 'netcoreapp2.1' - - 'net461' - - 'net452' build: - batch: script: | @@ -157,54 +111,27 @@ build: mkdir saxon curl -L -o saxon/saxon9he.jar https://repo1.maven.org/maven2/net/sf/saxon/Saxon-HE/9.8.0-12/Saxon-HE-9.8.0-12.jar - if [ $DOTNET_VERSION = 'mono' ]; then - echo "========== Starting Mono Build ==========" - mono --version - # Define alias for Nuget - nuget() { - mono /usr/local/bin/nuget.exe "$@" - } - export -f nuget - - # Install the required packages - nuget install NUnit.Runners -Version 3.6.1 -OutputDirectory testrunner + echo "========== Starting .NET Core Build ==========" + export DOTNET_CLI_TELEMETRY_OPTOUT=1 + dotnet --version - # Compile the driver and test code - msbuild /t:restore /v:m src/Cassandra.sln - msbuild /p:Configuration=Release /v:m /p:DynamicConstants=LINUX src/Cassandra.sln + # work around nuget issue + mkdir -p /tmp/NuGetScratch + chmod -R ugo+rwx /tmp/NuGetScratch - # Run the tests - mono ./testrunner/NUnit.ConsoleRunner.3.6.1/tools/nunit3-console.exe src/Cassandra.IntegrationTests/bin/Release/net452/Cassandra.IntegrationTests.dll --where "cat != long && cat != memory" --labels=All --result:"TestResult_nunit.xml" || error=true - java -jar saxon/saxon9he.jar -o:TestResult.xml TestResult_nunit.xml tools/nunit3-junit.xslt - - #Fail the build if there was an error - if [ $error ] - then - exit -1 - fi - else - echo "========== Starting .NET Core Build ==========" - export DOTNET_CLI_TELEMETRY_OPTOUT=1 - dotnet --version + # Install the required packages + dotnet restore src - # work around nuget issue - mkdir -p /tmp/NuGetScratch - chmod -R ugo+rwx /tmp/NuGetScratch - - # Install the required packages - dotnet restore src - - # Run the tests - dotnet test src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj -v n -f $DOTNET_VERSION -c Release --filter "(TestCategory!=long)&(TestCategory!=memory)" --logger "xunit;LogFilePath=../../TestResult_xunit.xml" || error=true - java -jar saxon/saxon9he.jar -o:TestResult.xml TestResult_xunit.xml tools/JUnitXml.xslt - - #Fail the build if there was an error - if [ $error ] - then - exit -1 - fi - fi + # Run the tests + dotnet test src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj -v n -f $DOTNET_VERSION -c Release --filter "(TestCategory!=long)&(TestCategory!=memory)" --logger "xunit;LogFilePath=../../TestResult_xunit.xml" || error=true + java -jar saxon/saxon9he.jar -o:TestResult.xml TestResult_xunit.xml tools/JUnitXml.xslt + #Fail the build if there was an error + if [ $error ] + then + exit -1 + fi + - xunit: - "**/TestResult.xml" diff --git a/build/memory_tests.ps1 b/build/memory_tests.ps1 deleted file mode 100644 index 68f35b0bd..000000000 --- a/build/memory_tests.ps1 +++ /dev/null @@ -1,14 +0,0 @@ -<# dotMemoryUnit requires the pull path of nunit3-console. -Appveyor does include the nunit3-console.exe at PATH system variable, but do not provide the Nunit3 path as a separated variable #> -$nunitrunner = "nunit3-console.exe"; -$paths = $env:PATH -split ";" -For ($i=0; $i -le $paths.Length; $i++) { - If (Test-Path "$($paths[$i])\nunit3-console.exe") { - $nunitrunner = "$($paths[$i])\nunit3-console.exe" - } -} -Write-Host "Nunit Runner path" + $nunitrunner -pushd src/Cassandra.IntegrationTests -Write-Host "Starting dotmemory unit tests..." -dotMemoryUnit -targetExecutable="$($nunitrunner)" --"bin\Release\net452\Cassandra.IntegrationTests.dll" --where "cat=memory" --trace=Verbose --labels:all --result="..\..\TestResult.xml" -popd diff --git a/docs/source/index.md b/docs/source/index.md index c229c0187..e9b6d72f2 100644 --- a/docs/source/index.md +++ b/docs/source/index.md @@ -2,7 +2,7 @@ ScyllaDB's fork of a modern, [feature-rich][features] and highly tunable C# client library for Scylla using Cassandra's binary protocol and Cassandra Query Language v3. -The driver targets .NET Framework 4.5.2 and .NET Standard 2.0. For more detailed information about platform compatibility, check [this section](#compatibility). +The driver targets .NET Standard 2.0. For more detailed information about platform compatibility, check [this section](#compatibility). ## Installation @@ -235,14 +235,14 @@ ICluster cluster = Cluster.Builder() - ScyllaDB 2025.1 and above. - ScyllaDB 5.x and above. - ScyllaDB Enterprise 2021.x and above. -- The driver targets .NET Framework 4.5.2 and .NET Standard 2.0 +- The driver targets .NET Standard 2.0 Here is a list of platforms and .NET targets that Datastax uses when testing this driver: -| Platform | net462 | net472 | net481 | net6 | net7 | net8 | -|-----------------------|--------|--------|--------|------|------|-------| -| Windows Server 2019³ | ✓ | ✓ | ✓ | ✓² | ✓¹ | ✓ | -| Ubuntu 18.04 | - | - | - | ✓ | ✓ | ✓ | +| Platform | net6 | net7 | net8 | +|-----------------------|------|------|-------| +| Windows Server 2019³ | ✓² | ✓¹ | ✓ | +| Ubuntu 18.04 | ✓ | ✓ | ✓ | ¹ No tests are run for the `net7` target on the Windows platform but `net7` is still considered fully supported. @@ -250,8 +250,6 @@ Here is a list of platforms and .NET targets that Datastax uses when testing thi ³ Appveyor's `Visual Studio 2022` image is used for these tests. -Mono `6.12.0` is also used to run `net462` tests on `Ubuntu 18.04` but Datastax can't guarantee that the driver fully supports Mono in a production environment. Datastax recommends the modern cross platform .NET platform instead. - Note: Big-endian systems are not supported. ## Building and running the tests diff --git a/src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj b/src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj index 31affcb49..dd36f747f 100644 --- a/src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj +++ b/src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj @@ -1,11 +1,10 @@  - net8;net7;net6;net481;net462;net472 - net481;net8 + net8;net7;net6 + net8 net6 net7 - net8 - net462 + net8 true NU1901;NU1902;NU1903;NU1904 false @@ -16,45 +15,9 @@ true 7.1 - - $(DefineConstants);NETFRAMEWORK - $(DefineConstants);NETCOREAPP - - - TargetFramework=net461 - - - TargetFramework=net462 - - - TargetFramework=net452 - - - - - TargetFramework=net461 - - - TargetFramework=net472 - - - TargetFramework=net452 - - - - - TargetFramework=net461 - - - TargetFramework=net481 - - - TargetFramework=net452 - - TargetFramework=netstandard2.0 @@ -108,18 +71,9 @@ - - - - - - - - - diff --git a/src/Cassandra.IntegrationTests/Core/ConnectionTests.cs b/src/Cassandra.IntegrationTests/Core/ConnectionTests.cs index 622b1c7c7..e1f547e47 100644 --- a/src/Cassandra.IntegrationTests/Core/ConnectionTests.cs +++ b/src/Cassandra.IntegrationTests/Core/ConnectionTests.cs @@ -466,7 +466,6 @@ public void Ssl_Connect_With_Ssl_Disabled_Host() StringAssert.IsMatch("SSL", ex.InnerException.Message); } else if (ex.InnerException is IOException || - ex.InnerException.GetType().Name.Contains("Mono") || ex.InnerException is System.Security.Authentication.AuthenticationException) { // Under Mono, it throws a IOException diff --git a/src/Cassandra.IntegrationTests/Core/ExceptionsTests.cs b/src/Cassandra.IntegrationTests/Core/ExceptionsTests.cs index 98225b404..f3d4f7139 100644 --- a/src/Cassandra.IntegrationTests/Core/ExceptionsTests.cs +++ b/src/Cassandra.IntegrationTests/Core/ExceptionsTests.cs @@ -233,10 +233,8 @@ public void PreserveStackTraceTest() { _simulacronCluster.PrimeFluent(b => b.WhenQuery("SELECT WILL FAIL").ThenSyntaxError("syntax_error")); var ex = Assert.Throws(() => _session.Execute("SELECT WILL FAIL")); -#if !NETFRAMEWORK StringAssert.Contains(nameof(PreserveStackTraceTest), ex.StackTrace); StringAssert.Contains(nameof(ExceptionsTests), ex.StackTrace); -#endif StringAssert.Contains("Cassandra.Session.Execute", ex.StackTrace); } diff --git a/src/Cassandra.IntegrationTests/Core/MemoryLeakTests.cs b/src/Cassandra.IntegrationTests/Core/MemoryLeakTests.cs deleted file mode 100644 index 244bfba73..000000000 --- a/src/Cassandra.IntegrationTests/Core/MemoryLeakTests.cs +++ /dev/null @@ -1,117 +0,0 @@ -// -// Copyright (C) DataStax 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. -// - -#if NETFRAMEWORK && !LINUX -using System; -using System.Net.Sockets; -using Cassandra.IntegrationTests.TestBase; -using Cassandra.Tests; -using JetBrains.dotMemoryUnit; -using NUnit.Framework; - -namespace Cassandra.IntegrationTests.Core -{ - [TestFixture, Category("memory"), Explicit("this test needs dotMemory")] - class MemoryLeakTests : TestGlobals - { - [Test] - public void Monitor_Should_Not_Leak_Connections_Test() - { - var presetQueryCassandraObjects = QueryBuilder.GetObjects(where => where.Namespace.Like("Cassandra*") - & where.Namespace.NotLike("Cassandra*Tests")); - var memoryBeforeAll = dotMemory.Check(memory => - { - TestContext.WriteLine("Before cluster creation"); - var cassandraPackage = memory.GetObjects(presetQueryCassandraObjects); - var socketObjects = memory.GetObjects(where => where.Type.Is()); - TestContext.WriteLine("=== Cassandra driver Object count: " + cassandraPackage.ObjectsCount); - TestContext.WriteLine("=== Number of Socket objects: " + socketObjects.ObjectsCount); - }); - - var socketOptions = new SocketOptions().SetReadTimeoutMillis(1).SetConnectTimeoutMillis(1); - var builder = ClusterBuilder() - .AddContactPoint(TestHelper.UnreachableHostAddress) - .WithSocketOptions(socketOptions); - - const int length = 1000; - using (var cluster = builder.Build()) - { - var firstExcepetion = Assert.Throws(() => cluster.Connect()); - Assert.AreEqual(1, firstExcepetion.Errors.Count); - TestContext.WriteLine("After first attempt"); - var memoryBeforeAttempts = dotMemory.Check(memory => - { - var cassandraPackage = memory.GetObjects(presetQueryCassandraObjects); - var socketObjects = memory.GetObjects(where => where.Type.Is()); - TestContext.WriteLine("=== Cassandra driver Object count: " + cassandraPackage.ObjectsCount); - TestContext.WriteLine("=== Number of Socket objects: " + socketObjects.ObjectsCount); - }); - - for (var i = 0; i < length; i++) - { - var ex = Assert.Throws(() => cluster.Connect()); - Assert.AreEqual(1, ex.Errors.Count); - } - GC.Collect(); - dotMemory.Check(memory => - { - TestContext.WriteLine("After " + length + " more attempts"); - var cassandraPackage = memory.GetObjects(presetQueryCassandraObjects); - var socketObjects = memory.GetObjects(where => where.Type.Is()); - TestContext.WriteLine("=== Cassandra driver Object count: " + cassandraPackage.ObjectsCount); - TestContext.WriteLine("=== Number of Socket objects: " + socketObjects.ObjectsCount); - var leaked = memory.GetDifference(memoryBeforeAttempts) - .GetSurvivedObjects(o => o.LeakedOnEventHandler()) - .GetObjects(presetQueryCassandraObjects).ObjectsCount; - TestContext.WriteLine("=== Difference: Leaked: " + leaked); - Assert.That(leaked, Is.EqualTo(0)); - - var newObjects = memory.GetDifference(memoryBeforeAttempts) - .GetNewObjects().GetObjects(presetQueryCassandraObjects).ObjectsCount; - TestContext.WriteLine("=== Difference: New Objects: " + newObjects); - Assert.That(newObjects, Is.LessThanOrEqualTo(1), "Increased the amount of new objects"); - - Assert.That(memory.GetDifference(memoryBeforeAll) - .GetNewObjects(o => o.Type.Is()).ObjectsCount, Is.LessThanOrEqualTo(1), - "Should have clean all socket objects"); - }); - } - GC.Collect(); - dotMemory.Check(memory => - { - TestContext.WriteLine("After cluster disposal"); - var cassandraPackage = memory.GetObjects(presetQueryCassandraObjects); - var socketObjects = memory.GetObjects(where => where.Type.Is()); - TestContext.WriteLine("=== Cassandra driver Object count: " + cassandraPackage.ObjectsCount); - TestContext.WriteLine("=== Number of Socket objects: " + socketObjects.ObjectsCount); - - var leaked = memory.GetDifference(memoryBeforeAll) - .GetNewObjects(o => o.LeakedOnEventHandler()) - .GetObjects(presetQueryCassandraObjects).ObjectsCount; - - TestContext.WriteLine("=== Difference: Leaked: " + leaked); - Assert.That(leaked, Is.EqualTo(0)); - var newObjects = memory.GetDifference(memoryBeforeAll) - .GetNewObjects().GetObjects(presetQueryCassandraObjects).ObjectsCount; - TestContext.WriteLine("=== Difference: New Objects: " + newObjects); - //Assert.That(newObjects, Is.EqualTo(0), "Should have clean all created objects"); - Assert.That(memory.GetDifference(memoryBeforeAll) - .GetSurvivedObjects(o => o.Type.Is()).ObjectsCount, Is.LessThanOrEqualTo(4), ""); - }); - } - } -} -#endif diff --git a/src/Cassandra.IntegrationTests/Core/SessionTests.cs b/src/Cassandra.IntegrationTests/Core/SessionTests.cs index 607676423..1d18581c6 100644 --- a/src/Cassandra.IntegrationTests/Core/SessionTests.cs +++ b/src/Cassandra.IntegrationTests/Core/SessionTests.cs @@ -235,10 +235,6 @@ public void Should_Create_The_Right_Amount_Of_Connections(bool useShardAwareness [Test, TestTimeout(5 * 60 * 1000), Repeat(10)] public async Task Session_With_Host_Changing_Distance() { - if (TestHelper.IsMono) - { - Assert.Ignore("The test should not run under the Mono runtime"); - } var lbp = new DistanceChangingLbp(); var builder = ClusterBuilder() .AddContactPoint(TestCluster.InitialContactPoint) @@ -366,24 +362,6 @@ public async Task Session_Disposed_On_Cluster() Assert.AreEqual(0, Volatile.Read(ref isDown)); } -#if NETFRAMEWORK - - [Test, Apartment(ApartmentState.STA)] - public void Session_Connect_And_ShutDown_SupportsSTA() - { - Assert.DoesNotThrow(() => - { - using (var localCluster = ClusterBuilder().AddContactPoint(TestCluster.InitialContactPoint).Build()) - { - var localSession = localCluster.Connect(); - var ps = localSession.Prepare("SELECT * FROM system.local WHERE key='local'"); - TestHelper.Invoke(() => localSession.Execute(ps.Bind()), 10); - } - }); - } - -#endif - [Test] public void Session_Execute_Logging_With_Verbose_Level_Test() { diff --git a/src/Cassandra.IntegrationTests/Metrics/MetricsTests.cs b/src/Cassandra.IntegrationTests/Metrics/MetricsTests.cs index 78eff1c60..116a86347 100644 --- a/src/Cassandra.IntegrationTests/Metrics/MetricsTests.cs +++ b/src/Cassandra.IntegrationTests/Metrics/MetricsTests.cs @@ -14,8 +14,6 @@ // limitations under the License. // -#if !NET452 - using System; using System.Linq; using System.Net; @@ -370,5 +368,3 @@ public void Should_AllMetricsHaveValidValues_When_NodeIsDown() } } } - -#endif \ No newline at end of file diff --git a/src/Cassandra.IntegrationTests/TestBase/TestHttpClient.cs b/src/Cassandra.IntegrationTests/TestBase/TestHttpClient.cs index 225769f33..7769f2f79 100644 --- a/src/Cassandra.IntegrationTests/TestBase/TestHttpClient.cs +++ b/src/Cassandra.IntegrationTests/TestBase/TestHttpClient.cs @@ -13,14 +13,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#if NETCOREAPP -using System.Net.Http; -#endif - using System; using System.Collections.Generic; using System.IO; using System.Net; +using System.Net.Http; using System.Text; using System.Threading.Tasks; @@ -46,16 +43,9 @@ public TestHttpClient(Uri baseAddress) public Task SendAsync(string method, string url) { -#if NETCOREAPP return SendAsync(method, url, null); -#endif - -#if NETFRAMEWORK - return SendAsync(method, url, null, null); -#endif } -#if NETCOREAPP public async Task SendWithJsonAsync(string method, string url, object body) { HttpContent content = null; @@ -114,62 +104,6 @@ public async Task SendAsync(string method, string url, HttpContent conte return dataStr; } } -#endif - -#if NETFRAMEWORK - - public async Task SendWithJsonAsync(string method, string url, object body) - { - byte[] content = null; - if (body != null) - { - var bodyStr = GetJsonFromObject(body); - content = Encoding.UTF8.GetBytes(bodyStr); - } - - var data = await SendAsync(method, url, "application/json", content).ConfigureAwait(false); - return string.IsNullOrEmpty(data) - ? default(T) - : JsonConvert.DeserializeObject(data); - } - - public async Task SendAsync(string method, string url, string contentType, byte[] content) - { - var request = (HttpWebRequest)WebRequest.Create(_baseAddress + "/" + url); - - request.KeepAlive = false; - request.Method = method; - - if (content != null) - { - request.ContentType = contentType; - request.ContentLength = content.Length; - using (var dataStream = request.GetRequestStream()) - { - dataStream.Write(content, 0, content.Length); - dataStream.Close(); - } - } - - using (var response = (HttpWebResponse)request.GetResponse()) - { - using (var dataStream = response.GetResponseStream()) - { - var reader = new StreamReader(dataStream); - var responseFromServer = await reader.ReadToEndAsync().ConfigureAwait(false); - var statusCode = (int)response.StatusCode; - if (statusCode < 200 || statusCode >= 300) - { - throw new Exception($"Invalid status code received {statusCode}.{Environment.NewLine}" + - $"{responseFromServer}"); - } - - return responseFromServer; - } - } - } - -#endif private static string GetJsonFromObject(object body) { diff --git a/src/Cassandra.Tests/AppMetricsExtension/HistogramTests.cs b/src/Cassandra.Tests/AppMetricsExtension/HistogramTests.cs index 1f929080b..657da065f 100644 --- a/src/Cassandra.Tests/AppMetricsExtension/HistogramTests.cs +++ b/src/Cassandra.Tests/AppMetricsExtension/HistogramTests.cs @@ -13,7 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#if !NET452 using System; using System.Linq; using System.Threading; @@ -176,4 +175,3 @@ private void AssertSecondSnapshot(IReservoirSnapshot snapshot) } } } -#endif \ No newline at end of file diff --git a/src/Cassandra.Tests/Cassandra.Tests.csproj b/src/Cassandra.Tests/Cassandra.Tests.csproj index a5bababc3..bf8ee2c23 100644 --- a/src/Cassandra.Tests/Cassandra.Tests.csproj +++ b/src/Cassandra.Tests/Cassandra.Tests.csproj @@ -1,11 +1,10 @@  - net8;net7;net6;net481;net462;net472 - net481;net8 + net8;net7;net6 + net8 net6 net7 - net8 - net462 + net8 true NU1901;NU1902;NU1903;NU1904 false @@ -16,22 +15,9 @@ true 7.1 - - $(DefineConstants);NETFRAMEWORK - $(DefineConstants);NETCOREAPP - - - TargetFramework=net452 - - - - - TargetFramework=net461 - - TargetFramework=netstandard2.0 @@ -52,12 +38,6 @@ - - - - - - diff --git a/src/Cassandra.Tests/TargetTests.cs b/src/Cassandra.Tests/TargetTests.cs index d002d6430..9c19da2e5 100644 --- a/src/Cassandra.Tests/TargetTests.cs +++ b/src/Cassandra.Tests/TargetTests.cs @@ -34,17 +34,6 @@ public void Should_TargetNetstandard15_When_TestsTargetNetcore20() Assert.AreEqual(".NETStandard,Version=v2.0", framework); } -#elif NETFRAMEWORK - [Test] - public void Should_TargetNet45_When_TestsTargetNetFramework() - { - var framework = Assembly - .GetAssembly(typeof(ISession))? - .GetCustomAttribute()? - .FrameworkName; - - Assert.AreEqual(".NETFramework,Version=v4.5.2", framework); - } #else [Test] public void Should_FailTest_When_TestsTargetDifferentTarget() diff --git a/src/Cassandra.Tests/TestAttributes/CloudSupportedAttribute.cs b/src/Cassandra.Tests/TestAttributes/CloudSupportedAttribute.cs index c2af359c6..a4017b62c 100644 --- a/src/Cassandra.Tests/TestAttributes/CloudSupportedAttribute.cs +++ b/src/Cassandra.Tests/TestAttributes/CloudSupportedAttribute.cs @@ -35,11 +35,7 @@ public void ApplyToTest(NUnit.Framework.Internal.Test test) private bool CloudSupported() { -#if NETFRAMEWORK - return true; -#else return PlatformHelper.RuntimeSupportsCloudTlsSettings(); -#endif } } } \ No newline at end of file diff --git a/src/Cassandra.Tests/TestHelper.cs b/src/Cassandra.Tests/TestHelper.cs index 566407b32..f3a92a226 100644 --- a/src/Cassandra.Tests/TestHelper.cs +++ b/src/Cassandra.Tests/TestHelper.cs @@ -452,17 +452,6 @@ public static bool IsWin } } - /// - /// Determines if we are running under mono. - /// - public static bool IsMono - { - get - { - return Type.GetType("Mono.Runtime") != null; - } - } - /// /// Executes the provided n times, awaiting for the task to be completed, limiting the /// concurrency. diff --git a/src/Cassandra.Tests/TestTimeoutAttribute.cs b/src/Cassandra.Tests/TestTimeoutAttribute.cs index de10c4aab..09fa28301 100644 --- a/src/Cassandra.Tests/TestTimeoutAttribute.cs +++ b/src/Cassandra.Tests/TestTimeoutAttribute.cs @@ -21,20 +21,13 @@ namespace Cassandra.Tests { [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method, Inherited = false)] public class TestTimeoutAttribute : -#if NETFRAMEWORK - TimeoutAttribute -#else Attribute -#endif { /// /// Construct a TimeoutAttribute given a time in milliseconds /// /// The timeout value in milliseconds public TestTimeoutAttribute(int timeout) -#if NETFRAMEWORK - : base(timeout) -#endif { //TODO: Implement an alternate Timeout mechanism for .NET Core } diff --git a/src/Cassandra/Cassandra.csproj b/src/Cassandra/Cassandra.csproj index 113cb9752..06b44bab1 100644 --- a/src/Cassandra/Cassandra.csproj +++ b/src/Cassandra/Cassandra.csproj @@ -7,8 +7,7 @@ 3.22.0.1 false DataStax and ScyllaDB - net452;netstandard2.0 - netstandard2.0 + netstandard2.0 $(NoWarn);1591 true NU1901;NU1902;NU1903;NU1904 @@ -27,9 +26,6 @@ 7.1 false - - $(DefineConstants);NETFRAMEWORK - $(DefineConstants);NETCOREAPP @@ -48,12 +44,4 @@ - - - - - - - - diff --git a/src/Cassandra/Data/CqlProviderFactory.cs b/src/Cassandra/Data/CqlProviderFactory.cs index 61d6d76cf..643b79afa 100644 --- a/src/Cassandra/Data/CqlProviderFactory.cs +++ b/src/Cassandra/Data/CqlProviderFactory.cs @@ -72,11 +72,5 @@ public override DbDataSourceEnumerator CreateDataSourceEnumerator() throw new NotSupportedException(); } -#if NETFRAMEWORK - public override System.Security.CodeAccessPermission CreatePermission(System.Security.Permissions.PermissionState state) - { - throw new NotSupportedException(); - } -#endif } } \ No newline at end of file diff --git a/src/Cassandra/Helpers/PlatformHelper.cs b/src/Cassandra/Helpers/PlatformHelper.cs index 56d80fb3c..01084c1da 100644 --- a/src/Cassandra/Helpers/PlatformHelper.cs +++ b/src/Cassandra/Helpers/PlatformHelper.cs @@ -28,18 +28,12 @@ internal static class PlatformHelper public static bool IsKerberosSupported() { -#if NETFRAMEWORK - return true; -#else return RuntimeInformation.IsOSPlatform(OSPlatform.Windows); -#endif } public static string GetTargetFramework() { -#if NET452 - return ".NET Framework 4.5.2"; -#elif NETSTANDARD2_0 +#if NETSTANDARD2_0 return ".NET Standard 2.0"; #else return null; @@ -118,7 +112,6 @@ public static CpuInfo GetLinuxProcCpuInfo() return new CpuInfo(null, Environment.ProcessorCount); } -#if !NETFRAMEWORK public static bool RuntimeSupportsCloudTlsSettings() { var netCoreVersion = PlatformHelper.GetNetCoreVersion(); @@ -158,6 +151,5 @@ public static string GetNetCoreVersion() } return null; } -#endif } } \ No newline at end of file diff --git a/src/Cassandra/Policies/AesColumnEncryptionPolicy.cs b/src/Cassandra/Policies/AesColumnEncryptionPolicy.cs index 0d0e883f1..628e697c4 100644 --- a/src/Cassandra/Policies/AesColumnEncryptionPolicy.cs +++ b/src/Cassandra/Policies/AesColumnEncryptionPolicy.cs @@ -41,15 +41,13 @@ public class AesColumnEncryptionPolicy : BaseColumnEncryptionPolicy public override byte[] EncryptWithKey(AesKeyAndIV key, byte[] objBytes) { if (objBytes == null) { - return EmptyArray; + return Array.Empty(); } using (var aes = Aes.Create()) { diff --git a/src/Extensions/Cassandra.AppMetrics/Cassandra.AppMetrics.csproj b/src/Extensions/Cassandra.AppMetrics/Cassandra.AppMetrics.csproj index e7f52c8a1..336792cff 100644 --- a/src/Extensions/Cassandra.AppMetrics/Cassandra.AppMetrics.csproj +++ b/src/Extensions/Cassandra.AppMetrics/Cassandra.AppMetrics.csproj @@ -6,8 +6,7 @@ 3.99.0.0 3.22.0.1 DataStax and ScyllaDB - netstandard2.0;net461 - netstandard2.0 + netstandard2.0 DataStax and ScyllaDB true true