Skip to content

Commit

Permalink
CSHARP-1008 Remove EOL target frameworks and add new ones (.NET 6, .N…
Browse files Browse the repository at this point in the history
…ET 7, .NET 8) (#606)

- update several dependencies of the test projects
- add openssl.cnf TLS workaround to jenkinsfile
- fix build and test issues with new .NET versions
- update .NET targets of example projects
- update .NET targets in Jenkinsfile and Jenkinsfile.scheduled
- update .NET versions in appveyor and travis builds
- add readme section to describe which platforms are used in testing
  • Loading branch information
joao-r-reis committed Mar 8, 2024
1 parent d1ab72a commit 3c18335
Show file tree
Hide file tree
Showing 31 changed files with 350 additions and 201 deletions.
15 changes: 7 additions & 8 deletions .travis.yml
@@ -1,7 +1,7 @@
language: csharp
sudo: required
mono: none
dist: xenial
dist: focal

branches:
except:
Expand All @@ -12,13 +12,12 @@ branches:

matrix:
include:
- dotnet: 3.1.300
env: TARGETF="netcoreapp3.1" BUILD_EXAMPLES="1" BuildCoreOnly=True NETCORE_RUNTIME="3.1" RunCodeAnalyzers="True"
- dotnet: 2.1.202
env: TARGETF="netcoreapp2.0" BUILD_EXAMPLES="0" BuildCoreOnly=True NETCORE_RUNTIME="2.0" RunCodeAnalyzers="True"

before_install:
- sudo apt-get -y install dotnet-sdk-3.1
- dotnet: 8.0.200
env: TARGETF="net8" BUILD_EXAMPLES="1" BuildCoreOnly=True CASSANDRA_NETCORE_RUNTIME="8" RunCodeAnalyzers="True"
- dotnet: 6.0.419
env: TARGETF="net6" BUILD_EXAMPLES="0" BuildCoreOnly=True CASSANDRA_NETCORE_RUNTIME="6" RunCodeAnalyzers="True"
- dotnet: 7.0.406
env: TARGETF="net7" BUILD_EXAMPLES="0" BuildCoreOnly=True CASSANDRA_NETCORE_RUNTIME="7" RunCodeAnalyzers="True"

script:
- dotnet --info
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,17 @@
# ChangeLog - DataStax C# Driver

## 3.20.1

2024-03-08

### Bug fixes

* [[CSHARP-1007](https://datastax-oss.atlassian.net/browse/CSHARP-1007)] Build fails with .NET 7+ when using operators with CqlFunction and Guid (in LINQ statements)

### Other

* [[CSHARP-1008](https://datastax-oss.atlassian.net/browse/CSHARP-1008)] Exclude target frameworks which are EOL from test projects and add newer ones

## 3.20.0

2024-01-30
Expand Down
35 changes: 17 additions & 18 deletions CONTRIBUTING.md
Expand Up @@ -94,17 +94,17 @@ In both cases, the `CASSANDRA_VERSION` environment variable determines which ser

## Building the driver and running tests

DataStax C# drivers support .NET 4.5.2+ and .NET Core 2.1+. To run the code analyzers you need the .NET Core 3.1 SDK.
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.

### Prerequisites

- [.NET Core 3.1 SDK][dotnetcoresdk]
- [.NET 8 SDK][dotnetsdk]

### IDE Support

You can build and run tests on Visual Studio 2019+ and JetBrains Rider by opening the solution file `Cassandra.sln` with any of those applications.
You can build and run tests on Visual Studio 2022+ and JetBrains Rider by opening the solution file `Cassandra.sln` with any of those applications.

To run the code analyzers you need to update these IDEs to a version that supports `.editorconfig` because the code analysis settings are set on that file. In the case of Visual Studio, [you need Visual Studio 2019 16.3+][vs2019analyzers] because previous versions don't support nested `.editorconfig` files and we have a couple of these on the codebase.
To run the code analyzers you need to update these IDEs to a version that supports `.editorconfig` because the code analysis settings are set on that file. In the case of Visual Studio, old versions don't support nested `.editorconfig` files and we have a couple of these on the codebase.

You can also use Visual Studio Code although the repository doesn't contain the configuration for it.

Expand All @@ -115,38 +115,37 @@ 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 Core target framework in order to successfully build the project.
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.

You can build specific projects against specific target frameworks on any platform like this:

```bash
dotnet build src/Cassandra/Cassandra.csproj -f netstandard2.0
dotnet build src/Cassandra.Tests/Cassandra.Tests.csproj -f netcoreapp3.1
dotnet build src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj -f netcoreapp3.1
dotnet build src/Cassandra.Tests/Cassandra.Tests.csproj -f net8
dotnet build src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj -f net8
```

Alternatively you can set the `BuildCoreOnly` environment variable which will cause the projects to support .NET Core / .NET Standard targets only (you can see the conditions on the `.csproj` files).

### Running Unit Tests

```bash
dotnet test src/Cassandra.Tests/Cassandra.Tests.csproj -f netcoreapp3.1
dotnet test src/Cassandra.Tests/Cassandra.Tests.csproj -f net8
```

The target frameworks supported by the test projects are `netcoreapp3.1` and `net462` (by default). If you set the `BuildAllTargets` environment variable, the test projects will support these targets:
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:

- `net452`
- `net462`
- `net472`
- `net48`
- `netcoreapp2.0` (not LTS, might be removed at some point)
- `netcoreapp2.1`
- `netcoreapp3.1`
- `net481`
- `net6`
- `net7`(not LTS, might be removed at some point)
- `net8`

Running the unit tests for a single target should take no more than 5 minutes (usually less):

```bash
dotnet test src/Cassandra.Tests/Cassandra.Tests.csproj -c Release -f netcoreapp3.1 -l "console;verbosity=detailed"
dotnet test src/Cassandra.Tests/Cassandra.Tests.csproj -c Release -f net8 -l "console;verbosity=detailed"
```

### Running Integration Tests
Expand Down Expand Up @@ -187,7 +186,7 @@ Integration tests are tagged with one or more categories. You can see the list o
CCM tests usually take a bit longer to run so if you want a quick validation you might prefer to run the simulacron tests only. You can do this by running the tests that don't have the `realcluster` or `realclusterlong` categories:

```bash
dotnet test src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj -c Release -f netcoreapp3.1 --filter "(TestCategory!=realcluster)&(TestCategory!=realclusterlong)" -l "console;verbosity=detailed"
dotnet test src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj -c Release -f net8 --filter "(TestCategory!=realcluster)&(TestCategory!=realclusterlong)" -l "console;verbosity=detailed"
```

This currently takes less than 10 minutes.
Expand All @@ -197,15 +196,15 @@ If you get this error: `Simulacron start error: java.net.BindException: Address
To run the integration tests suite that the **per commit** schedule builds use on Appveyor and Jenkins, do this:

```bash
dotnet test src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj -c Release -f netcoreapp3.1 --filter "(TestCategory!=realclusterlong)" -l "console;verbosity=detailed"
dotnet test src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj -c Release -f net8 --filter "(TestCategory!=realclusterlong)" -l "console;verbosity=detailed"
```

This test suite contains all simulacron tests and most ccm tests. This currently takes less than 30 minutes for Apache Cassandra 3.11.x (which is the current default server version). You can change this by setting the `CASSANDRA_VERSION` environment variable or changing the default value of the `TestClusterManager.CassandraVersionString` property (don't commit this change).

To run all the integration tests (those that run on the **weekly** and **nightly** schedules), don't specify any filter:

```bash
dotnet test src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj -c Release -f netcoreapp3.1 -l "console;verbosity=detailed"
dotnet test src/Cassandra.IntegrationTests/Cassandra.IntegrationTests.csproj -c Release -f net8 -l "console;verbosity=detailed"
```

This currently takes less than 45 minutes for Apache Cassandra 3.11.x.
Expand Down
42 changes: 33 additions & 9 deletions Jenkinsfile
Expand Up @@ -86,16 +86,30 @@ def initializeEnvironment() {
gci env:* | sort-object name
'''
} else {
sh label: 'Copy SSL files', script: '''#!/bin/bash -le
cp -r ${HOME}/ccm/ssl $HOME/ssl
'''


sh label: 'Download Apache Cassandra® or DataStax Enterprise', script: '''#!/bin/bash -le
. ${CCM_ENVIRONMENT_SHELL} ${SERVER_VERSION}
echo "CASSANDRA_VERSION=${CCM_CASSANDRA_VERSION}" >> ${HOME}/environment.txt
'''

//https://learn.microsoft.com/en-us/dotnet/core/compatibility/cryptography/5.0/default-cipher-suites-for-tls-on-linux
sh label: 'Setup custom openssl.cnf due to .NET 5+ TLS changes on Linux', script: '''#!/bin/bash -le
cat >> /home/jenkins/openssl.cnf << OPENSSL_EOF
openssl_conf = default_conf
[default_conf]
ssl_conf = ssl_sect
[ssl_sect]
system_default = system_default_sect
[system_default_sect]
MinProtocol = TLSv1
CipherString = @SECLEVEL=2:kEECDH:kRSA:kEDH:kPSK:kDHEPSK:kECDHEPSK:-aDSS:-3DES:!DES:!RC4:!RC2:!IDEA:-SEED:!eNULL:!aNULL:!MD5:-SHA384:-CAMELLIA:-ARIA:-AESCCM8
Ciphersuites = TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256:TLS_AES_128_CCM_SHA256
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
Expand Down Expand Up @@ -200,7 +214,7 @@ def buildDriver() {
sh label: 'Build the driver for mono', script: '''#!/bin/bash -le
export BuildMonoOnly=True
export RunCodeAnalyzers=False
export MSBuildSDKsPath=/opt/dotnet/sdk/$(dotnet --version)/Sdks
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
Expand Down Expand Up @@ -262,7 +276,7 @@ def executeTests(perCommitSchedule) {
set -o allexport
. ${HOME}/environment.txt
set +o allexport
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"
'''
}
Expand Down Expand Up @@ -413,20 +427,30 @@ pipeline {
}
axis {
name 'DOTNET_VERSION'
values 'mono', 'netcoreapp3.1'
values 'mono', 'net8', 'net6'
}
}
excludes {
exclude {
axis {
name 'DOTNET_VERSION'
values 'mono'
values 'mono', 'net8'
}
axis {
name 'SERVER_VERSION'
values '2.2', '3.0', 'dse-5.1.35', 'dse-6.8.30'
}
}
exclude {
axis {
name 'DOTNET_VERSION'
values 'net8'
}
axis {
name 'SERVER_VERSION'
values 'dse-6.7.17', '3.11'
}
}
}

agent {
Expand Down

0 comments on commit 3c18335

Please sign in to comment.