Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 016B0200C60 for ; Mon, 24 Apr 2017 13:09:19 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id F4072160BA5; Mon, 24 Apr 2017 11:09:18 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 20E95160B99 for ; Mon, 24 Apr 2017 13:09:17 +0200 (CEST) Received: (qmail 42738 invoked by uid 500); 24 Apr 2017 11:09:17 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 42729 invoked by uid 99); 24 Apr 2017 11:09:17 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Apr 2017 11:09:17 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 3D708E0EE6; Mon, 24 Apr 2017 11:09:17 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: ptupitsyn@apache.org To: commits@ignite.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: ignite git commit: IGNITE-5066 .NET: Add continuous query test to verify that the problem from 1.9 no longer reproduces Date: Mon, 24 Apr 2017 11:09:17 +0000 (UTC) archived-at: Mon, 24 Apr 2017 11:09:19 -0000 Repository: ignite Updated Branches: refs/heads/ignite-2.0 1214d7e7e -> 5a433469a IGNITE-5066 .NET: Add continuous query test to verify that the problem from 1.9 no longer reproduces Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/5a433469 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/5a433469 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/5a433469 Branch: refs/heads/ignite-2.0 Commit: 5a433469afca394fc97b59cc16dbe83b2d24f8c5 Parents: 1214d7e Author: Pavel Tupitsyn Authored: Mon Apr 24 14:09:01 2017 +0300 Committer: Pavel Tupitsyn Committed: Mon Apr 24 14:09:01 2017 +0300 ---------------------------------------------------------------------- .../Apache.Ignite.Core.Tests.csproj | 1 + .../Query/Continuous/ContinuousQueryTest.cs | 115 +++++++++++++++++++ 2 files changed, 116 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/5a433469/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj index f4f5e59..c6b183b 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj @@ -101,6 +101,7 @@ + http://git-wip-us.apache.org/repos/asf/ignite/blob/5a433469/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryTest.cs new file mode 100644 index 0000000..5148dcc --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryTest.cs @@ -0,0 +1,115 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ + + +namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous +{ + using System; + using System.Collections.Concurrent; + using System.Collections.Generic; + using System.Threading; + using Apache.Ignite.Core.Cache; + using Apache.Ignite.Core.Cache.Event; + using Apache.Ignite.Core.Cache.Query.Continuous; + using NUnit.Framework; + + /// + /// Tests continuous queries. + /// + [Category(TestUtils.CategoryIntensive)] + public class ContinuousQueryTest + { + /// + /// Tests same query on multiple nodes. + /// This tests verifies that there are no exception on Java side during event delivery. + /// + [Test] + public void TestSameQueryMultipleNodes() + { + using (var ignite = StartIgnite()) + { + var cache = ignite.GetOrCreateCache("data"); + cache.QueryContinuous(new ContinuousQuery(new Listener())); + + using (var ignite2 = StartIgnite()) + { + var cache2 = ignite2.GetOrCreateCache("data"); + cache2.QueryContinuous(new ContinuousQuery(new Listener())); + + for (var i = 0; i < 100; i++) + { + PutEntry(cache2); + PutEntry(cache); + } + } + } + } + + /// + /// Puts the entry and verifies events. + /// + private static void PutEntry(ICache cache) + { + // Put new entry. + var entry = new Data {Id = Guid.NewGuid()}; + cache.Put(entry.Id, entry); + + // Wait for events. + Thread.Sleep(100); + + ICacheEntryEvent e; + + // Two listeners - two events. + Assert.IsTrue(Listener.Events.TryPop(out e)); + Assert.AreEqual(entry.Id, e.Key); + + Assert.IsTrue(Listener.Events.TryPop(out e)); + Assert.AreEqual(entry.Id, e.Key); + } + + /// + /// Starts the ignite. + /// + private static IIgnite StartIgnite() + { + return Ignition.Start(new IgniteConfiguration(TestUtils.GetTestConfiguration()) + { + BinaryConfiguration = new Core.Binary.BinaryConfiguration(typeof(Data)), + AutoGenerateIgniteInstanceName = true + }); + } + + private class Data + { + public Guid Id; + } + + private class Listener : ICacheEntryEventListener + { + public static readonly ConcurrentStack> Events + = new ConcurrentStack>(); + + public void OnEvent(IEnumerable> evts) + { + foreach (var e in evts) + { + Events.Push(e); + } + } + } + } +}