Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,26 @@ CCM_CASSANDRA_VERSION=${DSE_FIXED_VERSION} # maintain for backwards compatibilit
CCM_VERSION=${DSE_FIXED_VERSION}
CCM_SERVER_TYPE=dse
DSE_VERSION=${DSE_FIXED_VERSION}
CCM_IS_DSE=true
CCM_DISTRIBUTION=dse
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's another Jenkinsfile that needs this changes too probably. That jenkinsfile is responsible for daily/weekly builds.

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') {
sh label: 'Update environment for SNI proxy tests', script: '''#!/bin/bash -le
Expand Down Expand Up @@ -435,10 +448,13 @@ pipeline {
values '3.0', // latest 3.0.x Apache Cassandra�
'3.11', // latest 3.11.x Apache Cassandra�
'4.0', // latest 4.0.x Apache Cassandra�
'5.0-beta1', // Development Apache Cassandra�
'4.1',
'5.0', // Development Apache Cassandra�
'dse-5.1.35', // latest 5.1.x DataStax Enterprise
'dse-6.7.17', // latest 6.7.x DataStax Enterprise
'dse-6.8.30' // 6.8 current DataStax Enterprise
'dse-6.8.30', // 6.8 current DataStax Enterprise
'dse-6.9.3',
'hcd-1.0.0'
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need to prune this a bit, the matrix is too long for a "per-commit" build. We can run all the versions we want on the daily/weekly builds.

Maybe we can use 3.11, 4.1, 5.0, dse-5.1, dse-6.9.3 and hcd-1.0.0 for per-commit

}
axis {
name 'DOTNET_VERSION'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ protected override string[] SetupQueries
}
};

if (TestClusterManager.CheckCassandraVersion(false, new Version(4, 0), Comparison.LessThan))
// COMPACT STORAGE is not supported by DSE 6.0 / C* 4.0.
if (TestClusterManager.CheckCassandraVersion(true, new Version(4, 0), Comparison.LessThan) ||
(TestClusterManager.IsDse && TestClusterManager.CheckDseVersion(new Version(6, 0), Comparison.LessThan)))
{
setupQueries.Add($"CREATE TABLE {TableCompactStorage} (key blob PRIMARY KEY, bar int, baz uuid)" +
$" WITH COMPACT STORAGE");
Expand Down Expand Up @@ -547,9 +549,11 @@ public void SimpleStatement_With_Keyspace_Defined_On_Lower_Protocol_Versions()
[TestCassandraVersion(3, 11)]
public void SimpleStatement_With_No_Compact_Enabled_Should_Reveal_Non_Schema_Columns()
{
if (TestClusterManager.CheckCassandraVersion(false, new Version(4, 0), Comparison.GreaterThanOrEqualsTo))
if (TestClusterManager.CheckCassandraVersion(true, new Version(4, 0), Comparison.GreaterThanOrEqualsTo) ||
(TestClusterManager.IsDse && TestClusterManager.CheckDseVersion(new Version(6, 0), Comparison.GreaterThanOrEqualsTo)) ||
TestClusterManager.IsHcd)
{
Assert.Ignore("COMPACT STORAGE is only supported by C* versions prior to 4.0");
Assert.Ignore("COMPACT STORAGE is not supported by DSE 6.0 / C* 4.0");
return;
}

Expand All @@ -568,9 +572,11 @@ public void SimpleStatement_With_No_Compact_Enabled_Should_Reveal_Non_Schema_Col
[TestCassandraVersion(3, 11)]
public void SimpleStatement_With_No_Compact_Disabled_Should_Not_Reveal_Non_Schema_Columns()
{
if (TestClusterManager.CheckCassandraVersion(false, new Version(4, 0), Comparison.GreaterThanOrEqualsTo))
if (TestClusterManager.CheckCassandraVersion(true, new Version(4, 0), Comparison.GreaterThanOrEqualsTo) ||
(TestClusterManager.IsDse && TestClusterManager.CheckDseVersion(new Version(6, 0), Comparison.GreaterThanOrEqualsTo)) ||
TestClusterManager.IsHcd)
{
Assert.Ignore("COMPACT STORAGE is only supported by C* versions prior to 4.0");
Assert.Ignore("COMPACT STORAGE is not supported by DSE 6.0 / C* 4.0");
return;
}

Expand Down
13 changes: 6 additions & 7 deletions src/Cassandra.IntegrationTests/Core/SchemaMetadataTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,8 @@ public SchemaMetadataTests() :
base(() =>
{
string[] cassandraYaml = null;
if (TestClusterManager.CheckCassandraVersion(true, new Version(5, 0), Comparison.GreaterThanOrEqualsTo))
{
cassandraYaml = new[] { "materialized_views_enabled: true" };
}
else if (TestClusterManager.CheckCassandraVersion(true, new Version(4, 0), Comparison.GreaterThanOrEqualsTo))
if (TestClusterManager.CheckCassandraVersion(true, new Version(4, 0), Comparison.GreaterThanOrEqualsTo) ||
TestClusterManager.IsHcd)
{
cassandraYaml = new[] { "enable_materialized_views: true" };
}
Expand Down Expand Up @@ -664,11 +661,13 @@ public void RaiseErrorOnInvalidMultipleSecondaryIndexTest(bool metadataSync)
[Test, TestCase(true), TestCase(false), TestCassandraVersion(3, 0)]
public void ColumnClusteringOrderReversedTest(bool metadataSync)
{
if (TestClusterManager.CheckCassandraVersion(false, new Version(4, 0), Comparison.GreaterThanOrEqualsTo))
if (TestClusterManager.CheckCassandraVersion(true, new Version(4, 0), Comparison.GreaterThanOrEqualsTo) ||
(TestClusterManager.IsDse && TestClusterManager.CheckDseVersion(new Version(6, 0), Comparison.GreaterThanOrEqualsTo)))
{
Assert.Ignore("Compact table test designed for C* 3.0");
Assert.Ignore("COMPACT STORAGE is not supported by DSE 6.0 / C* 4.0");
return;
}

var keyspaceName = TestUtils.GetUniqueKeyspaceName();
var tableName = TestUtils.GetUniqueTableName().ToLower();
var cluster = GetNewTemporaryCluster(builder => builder.WithMetadataSyncOptions(new MetadataSyncOptions().SetMetadataSyncEnabled(metadataSync)));
Expand Down
9 changes: 2 additions & 7 deletions src/Cassandra.IntegrationTests/Core/UdfTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,7 @@ public void TestFixtureSetup()
return;
}
_testCluster = TestClusterManager.GetTestCluster(1, 0, false, DefaultMaxClusterCreateRetries, false, false);
var cassandraYaml = "enable_user_defined_functions: true";
if (TestClusterManager.CheckCassandraVersion(true, Version.Parse("5.0"), Comparison.GreaterThanOrEqualsTo))
{
cassandraYaml = "user_defined_functions_enabled: true";
}
_testCluster.UpdateConfig(cassandraYaml);
_testCluster.UpdateConfig("enable_user_defined_functions:true");
_testCluster.Start(1);
using (var cluster = ClusterBuilder().AddContactPoint(_testCluster.InitialContactPoint).Build())
{
Expand Down Expand Up @@ -159,7 +154,7 @@ public void GetFunction_Should_Retrieve_Metadata_Of_Cql_Function_Without_Paramet
Assert.AreEqual(false, func.CalledOnNullInput);
Assert.False(func.Monotonic);
Assert.False(func.Deterministic);
Assert.AreEqual(func.MonotonicOn, new string[0]);
Assert.AreEqual(new string[0], func.MonotonicOn);
}

[Test, TestCase(true), TestCase(false), TestCassandraVersion(2, 2)]
Expand Down
56 changes: 56 additions & 0 deletions src/Cassandra.IntegrationTests/TestClusterManagement/CcmBridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Sockets;
using System.Text.RegularExpressions;
using System.Threading;
using Cassandra.IntegrationTests.TestBase;
using Cassandra.Tests;
Expand Down Expand Up @@ -71,6 +73,11 @@ public void Create(bool useSsl)
ExecuteCcm(string.Format(
"create {0} --dse -v {1} {2}", Name, Version, sslParams));
}
else if(TestClusterManager.CurrentBackendType == TestClusterManager.BackendType.Hcd)
{
ExecuteCcm(string.Format(
"create {0} --hcd -v {1} {2}", Name, Version, sslParams));
}
else
{
ExecuteCcm(string.Format(
Expand Down Expand Up @@ -266,6 +273,9 @@ public ProcessOutput BootstrapNode(int n, string dc, bool start = true)
if (TestClusterManager.IsDse)
{
cmd += " --dse";
}else if (TestClusterManager.CurrentBackendType == TestClusterManager.BackendType.Hcd)
{
cmd += " --hcd";
}

var output = ExecuteCcm(string.Format(cmd, n, IpPrefix, n, 7000 + 100 * n, dc != null ? "-d " + dc : null));
Expand Down Expand Up @@ -294,6 +304,7 @@ public void UpdateConfig(params string[] configs)
{
return;
}
FixYaml(configs);
foreach (var c in configs)
{
ExecuteCcm(string.Format("updateconf \"{0}\"", c));
Expand All @@ -311,12 +322,57 @@ public void UpdateDseConfig(params string[] configs)
{
return;
}
FixYaml(configs);
foreach (var c in configs)
{
ExecuteCcm(string.Format("updatedseconf \"{0}\"", c));
}
}

public void UpdateConfig(int nodeId, params string[] yamlChanges)
{
if (yamlChanges == null) return;
FixYaml(yamlChanges);
var joinedChanges = string.Join(" ", yamlChanges.Select(s => $"\"{s}\""));
ExecuteCcm($"node{nodeId} updateconf {joinedChanges}");
}

private static void FixYaml(string[] yamlToFix)
{
// in-place fix
if (TestClusterManager.CheckCassandraVersion(false, System.Version.Parse("4.1"), Comparison.GreaterThanOrEqualsTo))
{
// Fix the yaml options that turned obsolete since 4.1.0
for (int i = 0; i < yamlToFix.Length; i++)
{
string line = yamlToFix[i];
var keyValueParts = line.Split(':');

var key = keyValueParts[0];
var value = keyValueParts[1];

var matchMs = Regex.Match(key, @"^(\w+)_in_ms$");
if (matchMs.Success)
{
yamlToFix[i] = $"{matchMs.Groups[1].Value}:{value}ms";
}

var matchKb = Regex.Match(key, @"^(\w+)_in_kb$");
if (matchKb.Success)
{
yamlToFix[i] = $"{matchKb.Groups[1].Value}:{value}KiB";
}

var matchEnable = Regex.Match(key, @"enable_(\w+)$");
if (matchEnable.Success)
{
yamlToFix[i] = $"{matchEnable.Groups[1].Value}_enabled:{value}";
}
}
}
}


public void SetNodeWorkloads(int nodeId, string[] workloads)
{
if (!TestClusterManager.IsDse)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,23 +214,17 @@ public void BootstrapNode(int nodeIdToStart, string dataCenterName, bool start =

public void UpdateDseConfig(params string[] yamlChanges)
{
if (yamlChanges == null) return;
var joinedChanges = string.Join(" ", yamlChanges.Select(s => $"\"{s}\""));
_ccm.ExecuteCcm($"updatedseconf {joinedChanges}");
_ccm.UpdateDseConfig(yamlChanges);
}

public void UpdateConfig(params string[] yamlChanges)
{
if (yamlChanges == null) return;
var joinedChanges = string.Join(" ", yamlChanges.Select(s => $"\"{s}\""));
_ccm.ExecuteCcm($"updateconf {joinedChanges}");
_ccm.UpdateConfig(yamlChanges);
}

public void UpdateConfig(int nodeId, params string[] yamlChanges)
{
if (yamlChanges == null) return;
var joinedChanges = string.Join(" ", yamlChanges.Select(s => $"\"{s}\""));
_ccm.ExecuteCcm($"node{nodeId} updateconf {joinedChanges}");
_ccm.UpdateConfig(nodeId, yamlChanges);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public static class TestClusterManager
public const string DefaultKeyspaceName = "test_cluster_keyspace";
private static ICcmProcessExecuter _executor;

private static readonly Version Version1Dot0 = new Version(1, 0);
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't need this one do we?

private static readonly Version Version2Dot0 = new Version(2, 0);
private static readonly Version Version2Dot1 = new Version(2, 1);
private static readonly Version Version2Dot2 = new Version(2, 2);
Expand All @@ -44,6 +45,8 @@ public static class TestClusterManager
private static readonly Version Version5Dot1 = new Version(5, 1);
private static readonly Version Version6Dot0 = new Version(6, 0);
private static readonly Version Version6Dot7 = new Version(6, 7);
private static readonly Version Version6Dot8 = new Version(6, 8);
private static readonly Version Version6Dot9 = new Version(6, 9);

/// <summary>
/// Gets the Cassandra version used for this test run
Expand All @@ -70,15 +73,18 @@ public static Version CassandraVersion
// C* 3.0
return Version3Dot0;
}
if (dseVersion < Version6Dot0)
if (dseVersion <= Version6Dot9)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm this is a tricky change. Technically DSE 6.x is in between 3.11 and 4.0 (it has some 4.0 features). This might result in some DSE 6.x tests not running because we declared the test as compatible with C* 4.0 and we relied on it working this way to run for DSE as well. Maybe try to check the total test count per server version before and after the changes to make sure we're not losing tests with these changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before the fix, dse-6.7.17 net6: total tests 1145, skipped 108.
After the fix, dse-6.7.17 net6: total tests 1145, skipped 107.

Before fix, dse-6.8 net6, skipped 28
After fix, dse-6.8 net6, skipped 27

So after my fix, it actually skips fewer tests. I think it may be because my change in CheckCassandraVersion. Previously it maps C* version to DSE version when comparing, using GetDseVersionFromCassandraVersion. I changed it so it maps DSE version to C* version instead. I think it makes more sense, and align with other drivers better, too.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Before fix, dse-6.8 net6, skipped 28
After fix, dse-6.8 net6, skipped 27

Do you have a total number for dse-6.8 net6 similar to dse-6.7.17 net6?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

dse-6.8.30

Copy link
Collaborator

Choose a reason for hiding this comment

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

I mean total number of tests, you wrote the total number of tests dse-6.7 but not dse-6.8

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh the same, the number of total tests is 1145. This is the number of tests before skipping any, so it will be the same for any versions, before and after fix.

Copy link
Contributor Author

@SiyaoIsHiding SiyaoIsHiding Nov 20, 2024

Choose a reason for hiding this comment

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

The one less skip count is about Should_FailFast_When_PreparedStatementIdChangesOnReprepare, because "This test relies on a bug that is fixed in this server version." I assume that test does not matter in this case.
Additionally, I just found out on the master branch, in [TestCassandraVersion(5, 0)],DSE 6.x has always map to C* 3.11. It's calling GetDseVersionFromCassandraVersion.
Mapping C* to DSE version is weird to me and brought a lot of confusion. For example, both with or without my fix, tests with [TestCassandraVersion(5, 0)] and the executing version of DSE-6.7.17 will run without being skipped.
Do we agree that

  1. We should map DSE 6.x to C* 3.11, and
  2. We change [TestCassandraVersion(x,x)] to map DSE version to C* version before it compares?
Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. looks right to me assuming that we don't cause additional tests to be skipped or cause test failures
  2. also looks right to me, it's weird that we're mapping C* to DSE version even when we're using OSS C* and the OSS C* test attribute. Probably a remnant from the time before the driver unification Idk
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should only try to map C*<->DSE versions if there's a mismatch between the attribute and the server type. If the attribute is DSE and the server is DSE no mapping is needed and the same thing is true if the attribute is OSS and the server is OSS.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Closing the loop here, without my fix dse-6.7.17 net6 skips 357 tests, with my fix it skips 355 tests. The only difference is:
Should_FailFast_When_PreparedStatementIdChangesOnReprepare which relies on a bug.
Should_CreateTable_WhenClusteringOrderAndCompactOptionsAreSet, the master branch skips this but it can actually pass.
I assume we are good mapping DSE 6.x to C* 3.11 now.

{
// C* 3.11
return Version3Dot11;
}
// C* 4.0
return Version4Dot0;
}

if (IsHcd)
{
return Version4Dot0;
}
return new Version(TestClusterManager.CassandraVersionString.Split('-')[0]);
}
}
Expand All @@ -99,14 +105,50 @@ public static string DsePath
get { return Environment.GetEnvironmentVariable("DSE_PATH"); }
}

public enum BackendType
{
Hcd,
Dse,
Cassandra
}

/// <summary>
/// "hcd", "dse", or "cassandra" (default)
/// </summary>
public static BackendType CurrentBackendType
{
get
{
string distribution = Environment.GetEnvironmentVariable("CCM_DISTRIBUTION") ?? "cassandra";
Copy link
Collaborator

@joao-r-reis joao-r-reis Nov 12, 2024

Choose a reason for hiding this comment

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

Currently the test project is relying on checking for DSE_VERSION to see if the tests are running against DSE or not so we should also check TestClusterManager.IsDse here before falling back to cassandra.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok I see you also changed the implementation of IsDse. I still think we should check the DSE_VERSION env variable here before falling back to cassandra

switch (distribution)
{
case "hcd":
return BackendType.Hcd;
case "dse":
return BackendType.Dse;
case "cassandra":
return BackendType.Cassandra;
default:
throw new TestInfrastructureException("Unknown CCM_DISTRIBUTION value: " + distribution);
}
}
}

public static string InitialContactPoint
{
get { return IpPrefix + "1"; }
}

public static string DseVersionString
{
get { return Environment.GetEnvironmentVariable("DSE_VERSION") ?? "6.7.7"; }
get
{
if (!IsDse)
{
throw new TestInfrastructureException("DSE_VERSION is only available when using DSE backend");
}
return Environment.GetEnvironmentVariable("CASSANDRA_VERSION") ?? "6.7.7";
}
}

public static string CassandraVersionString
Expand All @@ -116,7 +158,12 @@ public static string CassandraVersionString

public static bool IsDse
{
get { return Environment.GetEnvironmentVariable("DSE_VERSION") != null; }
get { return CurrentBackendType == BackendType.Dse; }
}

public static bool IsHcd
{
get { return CurrentBackendType == BackendType.Hcd; }
}

public static Version DseVersion
Expand Down Expand Up @@ -161,15 +208,14 @@ public static bool CheckDseVersion(Version version, Comparison comparison)

public static bool CheckCassandraVersion(bool requiresOss, Version version, Comparison comparison)
{
if (requiresOss && TestClusterManager.IsDse)
if (requiresOss && TestClusterManager.CurrentBackendType != BackendType.Cassandra)
{
return false;
}

var runningVersion = TestClusterManager.IsDse ? TestClusterManager.DseVersion : TestClusterManager.CassandraVersion;
var expectedVersion = TestClusterManager.IsDse ? TestClusterManager.GetDseVersionFromCassandraVersion(version) : version;

return TestDseVersion.VersionMatch(expectedVersion, runningVersion, comparison);
var runningVersion = TestClusterManager.CassandraVersion;
var expectedVersion = version;
return TestCassandraVersion.VersionMatch(expectedVersion, runningVersion, comparison);
}

/// <summary>
Expand Down
Loading