diff --git a/CMakeLists.txt b/CMakeLists.txt index 606048ed..3029499e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -496,6 +496,7 @@ if(WIN32) # Needed for prebuild on windows # #add_test(NAME csharp_tests_compatibility COMMAND nunit.bat bin/${PLATFORM}/$/ CompatibilityModeTestSuite TestResult-compatibility.xml) add_test(NAME csharp_tests_query COMMAND nunit.bat bin/${PLATFORM}/$/ RemoteQueryTestSuite TestResult-query.xml) add_test(NAME csharp_tests_counter COMMAND nunit.bat bin/${PLATFORM}/$/ CounterTestSuite TestResult-counter.xml) + add_test(NAME csharp_tests_counter_with_listener COMMAND nunit.bat bin/${PLATFORM}/$/ CounterWithListenerTestSuite TestResult-counter.xml) add_test(NAME csharp_tests_cluster COMMAND nunit.bat bin/${PLATFORM}/$/ ClusterTestSuite TestResult-cluster.xml) add_test(NAME csharp_tests_adminop COMMAND nunit.bat bin/${PLATFORM}/$/ AdminOpTestSuite TestResult-adminop.xml) @@ -533,7 +534,7 @@ if(WIN32 AND NOT DEFINED ENV{HOTROD_PREBUILT_LIB_DIR}) file(TO_CMAKE_PATH ${PROTOBUF_PROTOC_EXECUTABLE_CS} CM_PROTOBUF_PROTOC_EXECUTABLE_CS) install(FILES "${NLOG_DLL_LOCAL}" DESTINATION lib/) install(FILES "${NLOG_LICENSE_LOCAL}" DESTINATION lib/ OPTIONAL) - install(FILES "${CM_GOOGLE_PROTOBUF_NUPKG}/Google.Protobuf.3.4.0/lib/netstandard1.0/Google.Protobuf.dll" DESTINATION lib/) + install(FILES "${CM_GOOGLE_PROTOBUF_NUPKG}/Google.Protobuf.3.8.0/lib/net45/Google.Protobuf.dll" DESTINATION lib/) install(FILES "${CM_PROTOBUF_PROTOC_EXECUTABLE_CS}" DESTINATION bin/) endif(WIN32 AND NOT DEFINED ENV{HOTROD_PREBUILT_LIB_DIR}) diff --git a/build.bat b/build.bat index 4fd1e10f..c13b5fd0 100644 --- a/build.bat +++ b/build.bat @@ -1,13 +1,4 @@ if [%generator%] == [""] set generator="Visual Studio 17 2022" -echo Using generator -G %generator% - -set home_drive=%CD:~0,2% - -rmdir /s /q build_windows -mkdir build_windows -cd build_windows - -set "buildTest=%~1" if [%CLIENT_VERSION%] neq [] set V1=%CLIENT_VERSION:*/=% @@ -31,18 +22,29 @@ if 1%v_3micro% neq +1%v_3micro% set v_3micro=0 set package_name=%v_1major%.%v_2minor%.%v_3micro%.%v_4qualifier% set nuget_package_name=%v_1major%.%v_2minor%.%v_3micro%-%v_4qualifier% -if [%HOTRODCPP_HOME%] == [] set HOTRODCPP_HOME=%checkoutDir%/cpp-client/build_win/_CPack_Packages/WIN-x86_64/ZIP/infinispan-hotrod-cpp-%package_name%-WIN-x86_64 echo Using HOTRODCPP_HOME=%HOTRODCPP_HOME% if "%HOTROD_PREBUILT_LIB_DIR%" == "" ( set HOTRODCSDLL=hotrodcs.dll - set PROTOBUFDLL=%GOOGLE_PROTOBUF_NUPKG%\Google.Protobuf.3.4.0\lib\net451\Google.Protobuf.dll + set PROTOBUFDLL=%GOOGLE_PROTOBUF_NUPKG%\Google.Protobuf.3.8.0\lib\net45\Google.Protobuf.dll ) else ( set HOTRODCSDLL=%HOTROD_PREBUILT_LIB_DIR%\hotrodcs.dll set PROTOBUFDLL=%HOTROD_PREBUILT_LIB_DIR%\Google.Protobuf.dll ) +if NOT DEFINED HOTRODCPP_HOME set HOTRODCPP_HOME=%checkoutDir%/cpp-client/build_win/_CPack_Packages/WIN-x86_64/ZIP/infinispan-hotrod-cpp-%package_name%-WIN-x86_64 +echo Using generator -G %generator% + +set home_drive=%CD:~0,2% + call :unquote u_generator %generator% + +if not "%buildBuild%"=="skip" ( +rmdir /s /q build_windows +mkdir build_windows +cd build_windows +set "myest=%~1" + cmake -G "%u_generator%" -DHOTRODCPP_HOME=%HOTRODCPP_HOME% -DHOTROD_VERSION_MAJOR=%v_1major% -DHOTROD_VERSION_MINOR=%v_2minor% -DHOTROD_VERSION_PATCH=%v_3micro% -DHOTROD_VERSION_LABEL=%v_4qualifier% -DSWIG_DIR=%SWIG_DIR% -DSWIG_EXECUTABLE=%SWIG_EXECUTABLE% -DPROTOBUF_PROTOC_EXECUTABLE_CS="%PROTOBUF_PROTOC_EXECUTABLE_CS%" -DGOOGLE_PROTOBUF_NUPKG="%GOOGLE_PROTOBUF_NUPKG%" -DPROTOBUF_INCLUDE_DIR=%PROTOBUF_INCLUDE_DIR% -DJBOSS_HOME=%JBOSS_HOME% -DIKVM_CUSTOM_BIN_PATH=%IKVM_CUSTOM_BIN_PATH% -DOPENSSL_ROOT_DIR=%OPENSSL_ROOT_DIR% -DCONFIGURATION=RelWithDebInfo -DENABLE_DOXYGEN=1 -DENABLE_JAVA_TESTING=FALSE -DProtobuf_LIBRARIES=%PROTOBUFDLL% %~4 .. if %errorlevel% neq 0 goto fail if "%HOTROD_PREBUILT_LIB_DIR%" == "" ( @@ -50,29 +52,37 @@ if "%HOTROD_PREBUILT_LIB_DIR%" == "" ( ) else ( cmake --build . --config RelWithDebInfo --target hotrodcs-test-bin ) +cd .. +) if %errorlevel% neq 0 goto fail if not "%buildTest%"=="skip" ( +cd build_windows ctest -V -C RelWithDebInfo +cd .. ) if %errorlevel% neq 0 goto fail -if "%HOTROD_PREBUILT_LIB_DIR%" == "" ( - cpack -G ZIP --config CPackSourceConfig.cmake - if %errorlevel% neq 0 goto fail - - cpack -G ZIP --config CPackConfig.cmake - if %errorlevel% neq 0 goto fail +if not "%buildPack%"=="skip" ( +cd build_windows + if "%HOTROD_PREBUILT_LIB_DIR%" == "" ( + cpack -G ZIP --config CPackSourceConfig.cmake + if %errorlevel% neq 0 goto fail - cpack -G WIX -C RelWithDebInfo - if %errorlevel% neq 0 goto fail + cpack -G ZIP --config CPackConfig.cmake + if %errorlevel% neq 0 goto fail - cmake %* -P ../wix-bundle.cmake - if "%packNuget%"=="true" ( - cpack -G NuGet -R %nuget_package_name% -C RelWithDebInfo + cpack -G WIX -C RelWithDebInfo if %errorlevel% neq 0 goto fail + + cmake %* -P ../wix-bundle.cmake + if "%packNuget%"=="true" ( + cpack -G NuGet -R %nuget_package_name% -C RelWithDebInfo + if %errorlevel% neq 0 goto fail + ) ) +cd .. ) if %errorlevel% neq 0 goto fail endlocal diff --git a/buildtools/build.fsx b/buildtools/build.fsx index a3375f63..b6ea1e71 100644 --- a/buildtools/build.fsx +++ b/buildtools/build.fsx @@ -7,12 +7,16 @@ open Fake open Fake.NuGet.Install open Fake.DotNetCli -let cppClientVersion = "8.1.0.SNAPSHOT" -let cppClientPackageVersion = "8.2.0-Alpha2" // nuget does not support string values after. +let cppClientVersion = environVar "buildTag" +let cppClientUrlTemplate = "https://github.com/infinispan/cpp-client/releases/download/%s/infinispan-hotrod-cpp-%s-WIN-x86_64.zip" +//#Can't use cppClientUrlTemplate below. TODO fix this +let cppClientUrl = sprintf "https://github.com/infinispan/cpp-client/releases/download/%s/infinispan-hotrod-cpp-%s-WIN-x86_64.zip" cppClientVersion cppClientVersion +//let cppClientUrl = "file://C:\Users\rigazilla\git\cpp-client\build_win\_CPack_Packages\WIN-x86_64\ZIP\infinispan-hotrod-cpp-8.1.1.SNAPSHOT-WIN-x86_64.zip" +let cppClientPackageVersion = environVar "buildTag" // nuget does not support string values after. let swigVersion = "3.0.12" -let protobufVersion = "3.4.0" // if changing this, be sure to also update Google.Protobuf in src/Infinispan.HotRod/Infinispan.HotRod.csproj +let protobufVersion = "3.8.0" // if changing this, be sure to also update Google.Protobuf in src/Infinispan.HotRod/Infinispan.HotRod.csproj let nunitToolsVersion = "2.6.1" -let infinispanServerVersion = "9.1.1.Final" +let infinispanServerVersion = "14.0.6.Final" let generateDir = "../../../src/Infinispan.HotRod/generated" let generateSwigDir = "../src/Infinispan.HotRod/generated" @@ -45,7 +49,7 @@ Target "GenerateSwig" (fun _ -> let cppClientLocation = if (environVar "HOTROD_PREBUILT_DIR" <> null) then environVar "HOTROD_PREBUILT_DIR" - else (downloadCppClientIfNonexist cppClientVersion) + else (downloadCppClientIfNonexist cppClientUrl cppClientVersion) trace ("Target GenerateSwig: cpp client location is: " <+ cppClientLocation) let swigToolPath = downloadSwigToolsIfNonexist swigVersion copyIncludeForSwig cppClientLocation "../swig/native_client/include" @@ -63,9 +67,10 @@ Target "BuildSwigWrapper" (fun _ -> let cppClientLocation = if (environVar "HOTROD_PREBUILT_DIR" <> null) then environVar "HOTROD_PREBUILT_DIR" - else (downloadCppClientIfNonexist cppClientVersion) + else (downloadCppClientIfNonexist cppClientUrl cppClientVersion) copyIncludeForSwig cppClientLocation "../swig/native_client/include" copyLibForSwig cppClientLocation "../swig/native_client/lib" + EnvironmentHelper.setBuildParam "VisualStudioVersion" "15.0" buildSwig () ) @@ -127,7 +132,7 @@ Target "CppPackage" (fun _ -> let cppClientLocation = if (environVar "HOTROD_PREBUILT_DIR" <> null) then environVar "HOTROD_PREBUILT_DIR" - else (downloadCppClientIfNonexist cppClientVersion) + else (downloadCppClientIfNonexist cppClientUrl cppClientVersion) directoryCopy "../swig/build/RelWithDebInfo" binsPath false Copy binsPath (Directory.EnumerateFiles (sprintf "%s/lib" cppClientLocation)) Copy packageRoot ["Infinispan.HotRod.Cpp-client.win7-x64.nuspec"] diff --git a/global.json b/global.json index e1459cc4..3345c38a 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,6 @@ { "sdk": { - "version": "2.1.4" + "version": "2.1.4", + "rollForward": "latestMajor" } } diff --git a/src/Infinispan.HotRod/Infinispan.HotRod.csproj b/src/Infinispan.HotRod/Infinispan.HotRod.csproj index 98a0f803..434120cb 100644 --- a/src/Infinispan.HotRod/Infinispan.HotRod.csproj +++ b/src/Infinispan.HotRod/Infinispan.HotRod.csproj @@ -2,7 +2,7 @@ netstandard2.0 - 8.2.0-Alpha2 + $(CLIENT_VERSION) infinispan.org .NET core binding of C# HotRod client for connecting to infinispan false @@ -13,7 +13,7 @@ - + diff --git a/swig/hotrod_wrap.vcxproj b/swig/hotrod_wrap.vcxproj index 58b7605d..99b7c1bd 100644 --- a/swig/hotrod_wrap.vcxproj +++ b/swig/hotrod_wrap.vcxproj @@ -29,25 +29,29 @@ DynamicLibrary false MultiByte - v140 + v141 + 10.0.22000.0 DynamicLibrary false MultiByte - v140 + v141 + 10.0.22000.0 DynamicLibrary false MultiByte - v140 + v141 + 10.0.22000.0 DynamicLibrary false MultiByte - v140 + v141 + 10.0.22000.0 diff --git a/templates/hotrodcs.proj.in b/templates/hotrodcs.proj.in index 44a3881f..30eef41d 100644 --- a/templates/hotrodcs.proj.in +++ b/templates/hotrodcs.proj.in @@ -33,7 +33,7 @@ - ${GOOGLE_PROTOBUF_NUPKG}\Google.Protobuf.3.4.0\lib\net451\Google.Protobuf.dll + ${GOOGLE_PROTOBUF_NUPKG}\Google.Protobuf.3.8.0\lib\net45\Google.Protobuf.dll diff --git a/test/Infinispan.HotRod.Tests/AuthorizationTester.cs b/test/Infinispan.HotRod.Tests/AuthorizationTester.cs index 2906d9c6..25454dfd 100644 --- a/test/Infinispan.HotRod.Tests/AuthorizationTester.cs +++ b/test/Infinispan.HotRod.Tests/AuthorizationTester.cs @@ -287,7 +287,10 @@ protected void TestPutRemoveAsyncContains(IRemoteCache cache) cache.Put(K1, V1); Assert.IsTrue(cache.ContainsKey(K1)); Task result = cache.RemoveAsync(K1); - result.Wait(5000); + if (!result.Wait(5000)) { + // Give more time + result.Wait(5000); + } Assert.IsFalse(cache.ContainsKey(K1)); } diff --git a/test/Infinispan.HotRod.Tests/CounterTest.cs b/test/Infinispan.HotRod.Tests/CounterTest.cs index 1a1fbc36..b93cb4b5 100644 --- a/test/Infinispan.HotRod.Tests/CounterTest.cs +++ b/test/Infinispan.HotRod.Tests/CounterTest.cs @@ -246,168 +246,5 @@ public void RemoveWeakTest() Assert.AreEqual(5, counter.GetValue()); rcm.Remove(counterName); } - - [Test] - public void AddRemoveListenerWeakTest() - { - Semaphore s = new Semaphore(0, 1); - bool secondEvent = false; - Action a = (Event.CounterEvent e) => - { - if (!secondEvent) - { - Assert.AreEqual(5, e.OldValue); - Assert.AreEqual(15, e.NewValue); - Assert.AreEqual(Event.CounterState.VALID, e.NewState); - Assert.AreEqual(Event.CounterState.VALID, e.OldState); - secondEvent = true; - } - s.Release(); - }; - - Action a2 = (Event.CounterEvent e) => - { - Assert.AreEqual(6, e.OldValue); - Assert.AreEqual(16, e.NewValue); - Assert.AreEqual(Event.CounterState.VALID, e.NewState); - Assert.AreEqual(Event.CounterState.VALID, e.OldState); - s.Release(); - }; - - string counterName = "weakTestAddRemoveListener"; - Event.CounterListener cl = new Event.CounterListener(counterName, a); - Event.CounterListener cl1 = new Event.CounterListener(counterName, a2); - var rcm = remoteManager.GetCounterManager(); - var cc = new CounterConfiguration(5, 0, 20, 8, CounterType.WEAK, Storage.VOLATILE); - rcm.DefineCounter(counterName, cc); - var counter = rcm.GetWeakCounter(counterName); - object o = counter.AddListener(cl); - counter.Add(10); - Assert.True(s.WaitOne(5000)); - counter.RemoveListener(o); - counter.Add(-9); - Assert.False(s.WaitOne(5000)); - - object o1 = counter.AddListener(cl1); - counter.Add(10); - Assert.True(s.WaitOne(5000)); - counter.RemoveListener(o1); - - } - - [Test] - [Ignore("ISPN-9296")] - public void AddRemoveCounterWithListenerWeakTest() - { - Semaphore s = new Semaphore(0, 1); - Action a = (Event.CounterEvent e) => - { - s.Release(); - }; - - string counterName = "weak1TestAddRemoveListener"; - Event.CounterListener cl = new Event.CounterListener(counterName, a); - var rcm = remoteManager.GetCounterManager(); - var cc = new CounterConfiguration(5, 0, 20, 8, CounterType.WEAK, Storage.VOLATILE); - rcm.DefineCounter(counterName, cc); - var counter = rcm.GetWeakCounter(counterName); - object o = counter.AddListener(cl); - counter.Add(10); - Assert.True(s.WaitOne(5000)); - counter.Remove(); - - // After the remove no events should arrive - changeCounterFromAnotherCacheManager(); - Assert.False(s.WaitOne(5000)); - - // if the counter is recreated, events should come again - var counter1 = rcm.GetWeakCounter(counterName); - counter1.Add(10); - Assert.AreEqual(15, counter1.GetValue()); - Assert.True(s.WaitOne(5000)); - counter.RemoveListener(o); - } - - void changeCounterFromAnotherCacheManager() - { - ConfigurationBuilder conf = new ConfigurationBuilder(); - conf.AddServer().Host("127.0.0.1").Port(11222); - conf.ConnectionTimeout(90000).SocketTimeout(6000); - conf.ProtocolVersion("2.7"); - RemoteCacheManager remoteManager = new RemoteCacheManager(conf.Build(), true); - - var rcm = remoteManager.GetCounterManager(); - string counterName = "weak1TestAddRemoveListener"; - var counter = rcm.GetWeakCounter(counterName); - counter.Increment(); - remoteManager.Stop(); - } - - [Test] - public void BasicListenerStrongTest() - { - int step = 0; - Semaphore s = new Semaphore(0, 1); - Action a2 = (Event.CounterEvent e) => - { - switch (step) - { - case 0: - Assert.AreEqual(5, e.OldValue); - Assert.AreEqual(15, e.NewValue); - Assert.AreEqual(Event.CounterState.VALID, e.NewState); - Assert.AreEqual(Event.CounterState.VALID, e.OldState); - s.Release(); - break; - case 1: - Assert.AreEqual(15, e.OldValue); - Assert.AreEqual(0, e.NewValue); - Assert.AreEqual(Event.CounterState.LOWER_BOUND_REACHED, e.NewState); - Assert.AreEqual(Event.CounterState.VALID, e.OldState); - s.Release(); - break; - case 2: - Assert.AreEqual(0, e.OldValue); - Assert.AreEqual(20, e.NewValue); - Assert.AreEqual(Event.CounterState.UPPER_BOUND_REACHED, e.NewState); - Assert.AreEqual(Event.CounterState.LOWER_BOUND_REACHED, e.OldState); - s.Release(); - break; - default: - Assert.Fail(); - break; - } - }; - - - string counterName = "strongTestBasicListener"; - Event.CounterListener cl = new Event.CounterListener(counterName, a2); - var rcm = remoteManager.GetCounterManager(); - var cc = new CounterConfiguration(5, 0, 20, 8, CounterType.BOUNDED_STRONG, Storage.VOLATILE); - rcm.DefineCounter(counterName, cc); - var counter = rcm.GetStrongCounter(counterName); - object o = counter.AddListener(cl); - counter.AddAndGet(10); - Assert.True(s.WaitOne(15000)); - step = 1; - try - { - counter.AddAndGet(-20); - } - catch (CounterLowerBoundException) - { - } - Assert.True(s.WaitOne(15000)); - step = 2; - try - { - counter.AddAndGet(30); - } - catch (CounterUpperBoundException) - { - } - Assert.True(s.WaitOne(15000)); - counter.RemoveListener(o); - } } } diff --git a/test/Infinispan.HotRod.Tests/TranscodingTest.cs b/test/Infinispan.HotRod.Tests/TranscodingTest.cs index 8f5255a3..a7250f29 100644 --- a/test/Infinispan.HotRod.Tests/TranscodingTest.cs +++ b/test/Infinispan.HotRod.Tests/TranscodingTest.cs @@ -78,11 +78,11 @@ public void RawCachePutJbossGetJsonMediaTypeTest() var df = new DataFormat(); df.Marshaller = new TransparentMarshaller(); df.KeyMediaType = "application/json"; - df.ValueMediaType = "application/json"; + df.ValueMediaType = "application/unknown"; var jsonCache = cache.WithDataFormat(df); cache.Put("k1", "value1"); var retVal = jsonCache.Get("\x0003>\x0002k1"); - Assert.AreEqual("\"\\u0003>\\u0006value1\"", retVal); + Assert.AreEqual("\u0003>\u0006value1", retVal); } [Test] @@ -93,8 +93,8 @@ public void RawCachePutJsonGetJsonMediaTypeTest() df.KeyMediaType = "application/json"; df.ValueMediaType = "application/json"; var jsonCache = cache.WithDataFormat(df); - jsonCache.Put("\"k1\"", "value1"); - var retVal = jsonCache.Get("\"k1\""); + jsonCache.Put("k1", "\"value1\""); + var retVal = jsonCache.Get("k1"); Assert.AreEqual("\"value1\"", retVal); } @@ -116,9 +116,9 @@ public void JBossCachePutJbossGetJsonMediaTypeTest() df.KeyMediaType = "application/json"; df.ValueMediaType = "application/json"; var jsonCache = transcodingCache.WithDataFormat(df); - transcodingCache.Put("k1", "value1"); - var retVal = jsonCache.Get("\"k1\""); - Assert.AreEqual("\"value1\"", retVal); + transcodingCache.Put("kx", "\"valuex\""); + var retVal = jsonCache.Get("\"kx\""); + Assert.AreEqual("\"valuex\"", retVal); } [Test]