Fix parallel test running develop
authorBlake Bender <bblake@vmware.com>
Thu, 10 Jun 2021 01:44:10 +0000 (18:44 -0700)
committerBlake Bender <bblake@vmware.com>
Thu, 10 Jun 2021 01:44:10 +0000 (18:44 -0700)
- Geode 'Client' is a singleton, so needs to be a global resource in
  tests
- XUnit uses a 'Collection' for this, so added NetCoreCollectionFixture
  and NetCoreCollection classes.  Now Client is created before any tests
  run, and torn down when the last test completes.

NetCore.Test/CacheFactoryUnitTest.cs
NetCore.Test/CacheUnitTest.cs
NetCore.Test/NetCoreCollectionFixture.cs [new file with mode: 0644]
NetCore.Test/ObjectLeakUnitTest.cs
NetCore.Test/PoolFactoryUnitTest.cs
NetCore.Test/PoolManagerUnitTest.cs
NetCore.Test/RegionFactoryUnitTest.cs
NetCore.Test/xunit.runner.json

index cdcd581db25bf10c4106a7516d687d93d173a5bd..d451778acfbf7b05ebcdf630ee35fa44116793e2 100644 (file)
@@ -4,83 +4,66 @@ using Xunit;
 
 namespace GemfireDotNetTest
 {
-    public class CacheFactoryUnitTests 
+    [Collection("Geode .net Core Collection")]
+    public class CacheFactoryUnitTests
     {
         [Fact]
         public void TestCreateFactory()
         {
-            using (var client = new Client())
+            using (var cacheFactory = CacheFactory.Create())
             {
-                using (var cacheFactory = CacheFactory.Create())
-                {
-                    Assert.NotNull(cacheFactory);
-                }
+                Assert.NotNull(cacheFactory);
             }
         }
         
         [Fact]
         public void TestCacheFactoryGetVersion()
         {
-            using (var client = new Client())
+            using (var cacheFactory = CacheFactory.Create())
             {
-                using (var cacheFactory = CacheFactory.Create())
-                {
-                    var version = cacheFactory.Version;
-                    Assert.NotEqual(version, String.Empty);
-                }
+                var version = cacheFactory.Version;
+                Assert.NotEqual(version, String.Empty);
             }
         }
         
         [Fact]
         public void TestCacheFactoryGetProductDescription()
         {
-            using (var client = new Client())
+            using (var cacheFactory = CacheFactory.Create())
             {
-                using (var cacheFactory = CacheFactory.Create())
-                {
-                    var description = cacheFactory.ProductDescription;
-                    Assert.NotEqual(description, String.Empty);
-                }
+                var description = cacheFactory.ProductDescription;
+                Assert.NotEqual(description, String.Empty);
             }
         }
         
         [Fact]
         public void TestCacheFactorySetPdxIgnoreUnreadFields()
         {
-            using (var client = new Client())
+            using (var cacheFactory = CacheFactory.Create())
             {
-                using (var cacheFactory = CacheFactory.Create())
-                {
-                    cacheFactory.PdxIgnoreUnreadFields = true;
-                    cacheFactory.PdxIgnoreUnreadFields = false;
-                }
+                cacheFactory.PdxIgnoreUnreadFields = true;
+                cacheFactory.PdxIgnoreUnreadFields = false;
             }
         }
         
         [Fact]
         public void TestCacheFactorySetPdxReadSerialized()
         {
-            using (var client = new Client())
+            using (var cacheFactory = CacheFactory.Create())
             {
-                using (var cacheFactory = CacheFactory.Create())
-                {
-                    cacheFactory.PdxReadSerialized = true;
-                    cacheFactory.PdxReadSerialized = false;
-                }
+                cacheFactory.PdxReadSerialized = true;
+                cacheFactory.PdxReadSerialized = false;
             }
         }
         
         [Fact]
         public void TestCacheFactoryCreateCache()
         {
-            using (var client = new Client())
+            using (var cacheFactory = CacheFactory.Create())
             {
-                using (var cacheFactory = CacheFactory.Create())
+                using (var cache = cacheFactory.CreateCache())
                 {
-                    using (var cache = cacheFactory.CreateCache())
-                    {
-                        ;
-                    }
+                    ;
                 }
             }
         }
@@ -88,13 +71,10 @@ namespace GemfireDotNetTest
         [Fact]
         public void TestCacheFactorySetProperty()
         {
-            using (var client = new Client())
+            using (var cacheFactory = CacheFactory.Create())
             {
-                using (var cacheFactory = CacheFactory.Create())
-                {
-                    cacheFactory.SetProperty("log-level", "none")
-                        .SetProperty("log-file", "geode_native.log");
-                }
+                cacheFactory.SetProperty("log-level", "none")
+                    .SetProperty("log-file", "geode_native.log");
             }
         }
     }
index e19ccb3a00938f501548dae6719e1052a897c5f6..9c01608a94db6149a7c5025902d4174c4e3a05f6 100644 (file)
@@ -5,166 +5,115 @@ using Xunit;
 
 namespace GemfireDotNetTest
 {
+    [Collection("Geode .net Core Collection")]
     public class CacheUnitTests
     {
         [Fact]
         public void TestClientCacheGetPdxReadSerialized()
         {
-            using (var client = new Client())
+            using var cacheFactory = CacheFactory.Create()
+                .SetProperty("log-level", "debug")
+                .SetProperty("log-file", "TestClientCacheGetPdxReadSerialized.log");
+            try
             {
-                using (var cacheFactory = CacheFactory.Create()
-                    .SetProperty("log-level", "debug")
-                    .SetProperty("log-file", "TestClientCacheGetPdxReadSerialized.log"))
-                {
-                    try
-                    {
-                        cacheFactory.PdxReadSerialized = true;
-                        using (var cache = cacheFactory.CreateCache())
-                        {
-                            Assert.True(cache.GetPdxReadSerialized());
-                        }
+                cacheFactory.PdxReadSerialized = true;
+                using var cache = cacheFactory.CreateCache();
 
-                        cacheFactory.PdxReadSerialized = false;
-                        using (var otherCache = cacheFactory.CreateCache())
-                        {
-                            Assert.False(otherCache.GetPdxReadSerialized());
-                        }
-                    }
-                    catch (Exception e)
-                    {
-                        Console.WriteLine(e);
-                        throw;
-                    }
-                }
+                Assert.True(cache.GetPdxReadSerialized());
+
+                cacheFactory.PdxReadSerialized = false;
+                using var otherCache = cacheFactory.CreateCache();
+
+                Assert.False(otherCache.GetPdxReadSerialized());
+            }
+            catch (Exception e)
+            {
+                Console.WriteLine(e);
+                throw;
             }
         }
         
         [Fact]
         public void TestClientCacheGetPdxIgnoreUnreadFields()
         {
-            using (var client = new Client())
-            {
-                using (var cacheFactory = CacheFactory.Create()
-                    .SetProperty("log-level", "none")
-                    .SetProperty("log-file", "geode_native.log"))
-                {
-                    cacheFactory.PdxIgnoreUnreadFields = true;
-                    using (var cache = cacheFactory.CreateCache())
-                    {
-                        Assert.True(cache.GetPdxIgnoreUnreadFields());
-                    }
+            using var cacheFactory = CacheFactory.Create()
+                .SetProperty("log-level", "none")
+                .SetProperty("log-file", "geode_native.log");
+            cacheFactory.PdxIgnoreUnreadFields = true;
+            using var cache = cacheFactory.CreateCache();
 
-                    cacheFactory.PdxIgnoreUnreadFields = false;
-                    using (var otherCache = cacheFactory.CreateCache())
-                    {
-                        Assert.False(otherCache.GetPdxIgnoreUnreadFields());
-                    }
-                }
-            }
+            Assert.True(cache.GetPdxIgnoreUnreadFields());
+
+            cacheFactory.PdxIgnoreUnreadFields = false;
+            using var otherCache = cacheFactory.CreateCache();
+            Assert.False(otherCache.GetPdxIgnoreUnreadFields());
         }
 
         [Fact]
         public void TestClientCacheGetPoolManager()
         {
-            using (var client = new Client())
-            {
-                using (var cacheFactory = CacheFactory.Create()
-                    .SetProperty("log-level", "none")
-                    .SetProperty("log-file", "geode_native.log"))
-                {
-                    cacheFactory.PdxIgnoreUnreadFields = true;
-                    using (var cache = cacheFactory.CreateCache())
-                    {
-                        var poolManager = cache.PoolManager;
-                        poolManager.Dispose();
-                    }
-                }
-            }
+            using var cacheFactory = CacheFactory.Create()
+                .SetProperty("log-level", "none")
+                .SetProperty("log-file", "geode_native.log");
+
+            cacheFactory.PdxIgnoreUnreadFields = true;
+            using var cache = cacheFactory.CreateCache();
+            using var poolManager = cache.PoolManager;
         }
         
         [Fact]
         public void TestClientCacheCreateRegionFactory()
         {
-            using (var client = new Client())
-            {
-                using (var cacheFactory = CacheFactory.Create()
-                    .SetProperty("log-level", "none")
-                    .SetProperty("log-file", "geode_native.log"))
-                {
-                    cacheFactory.PdxIgnoreUnreadFields = true;
-                    using (var cache = cacheFactory.CreateCache())
-                    {
-                        using (var regionFactory = cache.CreateRegionFactory(RegionShortcut.Proxy))
-                        {
-                            ;
-                        }
-                    }
-                }
-            }
+            using var cacheFactory = CacheFactory.Create()
+                .SetProperty("log-level", "none")
+                .SetProperty("log-file", "geode_native.log");
+            cacheFactory.PdxIgnoreUnreadFields = true;
+            using var cache = cacheFactory.CreateCache();
+            using var regionFactory = cache.CreateRegionFactory(RegionShortcut.Proxy);
         }
 
         [Fact]
         public void TestClientCacheGetName()
         {
-            using (var client = new Client())
-            {
-                using (var cacheFactory = CacheFactory.Create()
-                    .SetProperty("log-level", "none"))
-                {
-                    cacheFactory.PdxIgnoreUnreadFields = true;
-                    using (var cache = cacheFactory.CreateCache())
-                    {
-                        var cacheName = cache.Name;
-                        Assert.NotEqual(cacheName, String.Empty);
-                    }
-                }
-            }
+            using var cacheFactory = CacheFactory.Create()
+                .SetProperty("log-level", "none");
+            cacheFactory.PdxIgnoreUnreadFields = true;
+            using var cache = cacheFactory.CreateCache();
+
+            var cacheName = cache.Name;
+            Assert.NotEqual(cacheName, String.Empty);
         }
         
         [Fact]
         public void TestClientCacheClose()
         {
-            using (var client = new Client())
-            {
-                using (var cacheFactory = CacheFactory.Create()
-                    .SetProperty("log-level", "none"))
-                {
-                    cacheFactory.PdxIgnoreUnreadFields = true;
-                    using (var cache = cacheFactory.CreateCache())
-                    {
-                        Assert.False(cache.Closed);
-                        cache.Close();
-                        Assert.True(cache.Closed);
-                    }
-                }
-            }
+            using var cacheFactory = CacheFactory.Create()
+                .SetProperty("log-level", "none");
+            cacheFactory.PdxIgnoreUnreadFields = true;
+            using var cache = cacheFactory.CreateCache();
+
+            Assert.False(cache.Closed);
+            cache.Close();
+            Assert.True(cache.Closed);
         }
         
         [Fact]
         public void TestClientCacheCloseWithKeepalive()
         {
-            using (var client = new Client())
-            {
-                using (var cacheFactory = CacheFactory.Create()
-                    .SetProperty("log-level", "none"))
-                {
-                    cacheFactory.PdxIgnoreUnreadFields = true;
-                    using (var cache = cacheFactory.CreateCache())
-                    {
-                        Assert.False(cache.Closed);
-                        cache.Close(true);
-                        Assert.True(cache.Closed);
+            using var cacheFactory = CacheFactory.Create()
+                .SetProperty("log-level", "none");
+            cacheFactory.PdxIgnoreUnreadFields = true;
+            using var cache = cacheFactory.CreateCache();
+            
+            Assert.False(cache.Closed);
+            cache.Close(true);
+            Assert.True(cache.Closed);
 
-                    }
+            using var otherCache = cacheFactory.CreateCache();
 
-                    using (var otherCache = cacheFactory.CreateCache())
-                    {
-                        Assert.False(otherCache.Closed);
-                        otherCache.Close(false);
-                        Assert.True(otherCache.Closed);
-                    }
-                }
-            }
+            Assert.False(otherCache.Closed);
+            otherCache.Close(false);
+            Assert.True(otherCache.Closed);
         }
     }
 }
diff --git a/NetCore.Test/NetCoreCollectionFixture.cs b/NetCore.Test/NetCoreCollectionFixture.cs
new file mode 100644 (file)
index 0000000..49a14ce
--- /dev/null
@@ -0,0 +1,22 @@
+´╗┐using System;
+using Apache.Geode.NetCore;
+using Xunit;
+
+public class NetCoreCollectionFixture : IDisposable
+{
+    public NetCoreCollectionFixture()
+    {
+        client_ = new Client();
+    }
+    public void Dispose()
+    {
+        client_.Dispose();
+    }
+
+    Client client_;
+}
+
+[CollectionDefinition("Geode .net Core Collection")]
+public class NetCoreCollection : ICollectionFixture<NetCoreCollectionFixture>
+{
+}
index acfa131110eb63e428faa0ff8356b030da3f9ced..56d41d4ec2e62eb756f9b3b0ab5465752d8364f0 100644 (file)
@@ -4,7 +4,8 @@ using Xunit;
 
 namespace GemfireDotNetTest
 {
-    public class ObjectLeakUnitTests 
+    [Collection("Geode .net Core Collection")]
+    public class ObjectLeakUnitTests
     {
         [Fact]
         public void TestLeakCacheFactory()
index 766fb40f530c8c5e1659cc9ed13316e32a30d0ad..8ec8dde25b50fea2e989366850598527b41757d4 100644 (file)
@@ -4,78 +4,46 @@ using Xunit;
 
 namespace GemfireDotNetTest
 {
+    [Collection("Geode .net Core Collection")]
     public class PoolFactoryUnitTests
     {
         [Fact]
         public void TestPoolFactoryAddLocator()
         {
-            using (var client = new Client())
-            {
-                using (var cacheFactory = CacheFactory.Create()
-                        .SetProperty("log-level", "none")
-                        .SetProperty("log-file", "geode_native.log"))
-                {
-                    using (var cache = cacheFactory.CreateCache())
-                    {
-                        using (var poolManager = cache.PoolManager)
-                        {
-                            using (var poolFactory = poolManager.CreatePoolFactory())
-                            {
-                              poolFactory.AddLocator("localhost", 10334);
-                            }
-                        }
-                    }
-                }
-            }
+            using var cacheFactory = CacheFactory.Create()
+                    .SetProperty("log-level", "none")
+                    .SetProperty("log-file", "geode_native.log");
+            using var cache = cacheFactory.CreateCache();
+            using var poolManager = cache.PoolManager;
+            using var poolFactory = poolManager.CreatePoolFactory();
+
+            poolFactory.AddLocator("localhost", 10334);
         }
         
         [Fact]
         public void TestPoolFactoryCreatePool()
         {
-            using (var client = new Client())
-            {
-                using (var cacheFactory = CacheFactory.Create()
-                        .SetProperty("log-level", "none")
-                        .SetProperty("log-file", "geode_native.log"))
-                {
-                    using (var cache = cacheFactory.CreateCache())
-                    {
-                        using (var poolManager = cache.PoolManager)
-                        {
-                            using (var poolFactory = poolManager.CreatePoolFactory())
-                            {
-                                poolFactory.AddLocator("localhost", 10334);
-                                using (var pool = poolFactory.CreatePool("myPool"))
-                                {
-                                    ;
-                                }
-                            }
-                        }
-                    }
-                }
-            }
+            using var cacheFactory = CacheFactory.Create()
+                    .SetProperty("log-level", "none")
+                    .SetProperty("log-file", "geode_native.log");
+            using var cache = cacheFactory.CreateCache();
+            using var poolManager = cache.PoolManager;
+            using var poolFactory = poolManager.CreatePoolFactory();
+
+            poolFactory.AddLocator("localhost", 10334);
+            using var pool = poolFactory.CreatePool("myPool");
         }
 
         [Fact]
         public void TestCreatePoolWithoutPoolManager()
         {
-            using (var client = new Client())
-            {
-                using (var cacheFactory = CacheFactory.Create())
-                {
-                    using (var cache = cacheFactory.CreateCache())
-                    {
-                        using (var poolFactory = cache.PoolFactory)
-                        {
-                            poolFactory.AddLocator("localhost", 10334);
-                            using (var pool = poolFactory.CreatePool("myPool"))
-                            {
-                            }
-                        }
-                    }
-                }
-            }
+            using var cacheFactory = CacheFactory.Create();
+            using var cache = cacheFactory.CreateCache();
+            using var poolFactory = cache.PoolFactory;
+            
+            poolFactory.AddLocator("localhost", 10334);
+            using var pool = poolFactory.CreatePool("myPool");
         }
-  }
+    }
 }
 
index 5dfec19fd7b3403660da4dfd8cec9045ed5bf588..14767a5d2d5f04c5b88c824367fab0e7e65941b9 100644 (file)
@@ -4,26 +4,16 @@ using Xunit;
 
 namespace GemfireDotNetTest
 {
+    [Collection("Geode .net Core Collection")]
     public class PoolManagerUnitTests
     {
         [Fact]
         public void TestPoolManagerCreatePoolFactory()
         {
-            using (var client = new Client())
-            {
-                using (var cacheFactory = CacheFactory.Create())
-                {
-                    using (var cache = cacheFactory.CreateCache())
-                    {
-                        using (var poolManager = cache.PoolManager)
-                        {
-                            using (var poolFactory = poolManager.CreatePoolFactory())
-                            {
-                            }
-                        }
-                    }
-                }
-            }
+            using var cacheFactory = CacheFactory.Create();
+            using var cache = cacheFactory.CreateCache();
+            using var poolManager = cache.PoolManager;
+            using var poolFactory = poolManager.CreatePoolFactory();
         }
     }
 }
index e9989319bacb259e6ed8a5e107883836a6d1a452..aee341fb886239f08db07573b6f002b7fd2c9f91 100644 (file)
@@ -23,6 +23,8 @@ namespace GemfireDotNetTest
         }
     }
     
+
+    [Collection("Geode .net Core Collection")]
     public class RegionFactoryUnitTests
     {
         private const string Username1 = "rtimmons";
@@ -30,17 +32,10 @@ namespace GemfireDotNetTest
 
         private void createPool(IGeodeCache cache, int port)
         {
-            using (var poolManager = cache.PoolManager)
-            {
-                using (var poolFactory = poolManager.CreatePoolFactory()
-                    .AddLocator("localhost", port))
-                {
-                    using (var pool = poolFactory.CreatePool("myPool"))
-                    {
-                        ;
-                    }
-                }
-            }
+            using var poolManager = cache.PoolManager;
+            using var poolFactory = poolManager.CreatePoolFactory()
+                .AddLocator("localhost", port);
+            using var pool = poolFactory.CreatePool("myPool");
         }
 
         private void doPutsAndGets(Region region)
@@ -72,51 +67,36 @@ namespace GemfireDotNetTest
         
         private void CreateRegionAndDoWork(IGeodeCache cache, string regionName, RegionShortcut regionType)
         {
-            using (var regionFactory = cache.CreateRegionFactory(regionType))
-            {
-                using (var region = regionFactory.CreateRegion(regionName))
-                {
-                    doPutsAndGets(region);
-                    DoRemoves(region);
-                }
-            }
+            using var regionFactory = cache.CreateRegionFactory(regionType);
+            using var region = regionFactory.CreateRegion(regionName);
+
+            doPutsAndGets(region);
+            DoRemoves(region);
         }
         
         [Fact]
         public void TestRegionFactoryCreateProxyRegion()
         {
-            using (var client = new Client())
-            {
-                using (var cacheFactory = CacheFactory.Create()
-                    .SetProperty("log-level", "none")
-                    .SetProperty("log-file", "geode_native.log"))
-                {
-                    using (var cache = cacheFactory.CreateCache())
-                    {
-                        createPool(cache, 10334);
-                        CreateRegionAndDoWork(cache, "exampleRegion", RegionShortcut.Proxy);
-                    }
-                }
-            }
+            using var cacheFactory = CacheFactory.Create()
+                .SetProperty("log-level", "none")
+                .SetProperty("log-file", "geode_native.log");
+            using var cache = cacheFactory.CreateCache();
+
+            createPool(cache, 10334);
+            CreateRegionAndDoWork(cache, "exampleRegion", RegionShortcut.Proxy);
         }
        
         [Fact]
         public void TestRegionFactoryCreateRegionWithAuthentication()
         {
-            using (var client = new Client())
-            {
-                using (var cacheFactory = CacheFactory.Create()
-                    .SetProperty("log-level", "debug")
-                    .SetProperty("log-file", "geode_native_with_auth.log"))
-                {
-                    cacheFactory.AuthInitialize = new SimpleAuthInitialize();
-                    using (var cache = cacheFactory.CreateCache())
-                    {
-                        createPool(cache, 10335);
-                        CreateRegionAndDoWork(cache, "authExampleRegion", RegionShortcut.CachingProxy);
-                    }
-                }
-            }
+            using var cacheFactory = CacheFactory.Create()
+                .SetProperty("log-level", "debug")
+                .SetProperty("log-file", "geode_native_with_auth.log");
+            cacheFactory.AuthInitialize = new SimpleAuthInitialize();
+            using var cache = cacheFactory.CreateCache();
+
+            createPool(cache, 10335);
+            CreateRegionAndDoWork(cache, "authExampleRegion", RegionShortcut.CachingProxy);
         }
     }
 }
index c977ea03d42890f8adbba1be66b55be58f864ce5..0243b2c28313e57086e481579d58f18d21380e0c 100644 (file)
@@ -1,5 +1,5 @@
 {
   "methodDisplay": "classAndMethod",
   "parallelizeAssembly": true,
-  "parallelizeTestCollections": false
-}
+  "parallelizeTestCollections": true
+}
\ No newline at end of file