Example #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRePlanAfterDataChangesFromAnEmptyDatabase() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldRePlanAfterDataChangesFromAnEmptyDatabase()
        {
            // GIVEN
            TestMonitor monitor = new TestMonitor();

            Db.resolveDependency(typeof(Monitors)).addMonitorListener(monitor);
            // - setup schema -
            CreateIndex();
            // - execute the query without the existence data -
            ExecuteDistantFriendsCountQuery(USERS);

            long replanTime = DateTimeHelper.CurrentUnixTimeMillis() + 1_800;

            // - create data -
            CreateData(0, USERS, CONNECTIONS);

            // - after the query TTL has expired -
            while (DateTimeHelper.CurrentUnixTimeMillis() < replanTime)
            {
                Thread.Sleep(100);
            }

            // WHEN
            monitor.Reset();
            // - execute the query again -
            ExecuteDistantFriendsCountQuery(USERS);

            // THEN
            assertEquals("Query should have been replanned.", 1, monitor.Discards.get());
            assertThat("Replan should have occurred after TTL", monitor.WaitTime.get(), greaterThanOrEqualTo(1L));
        }
Example #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRePlanAfterDataChangesFromAPopulatedDatabase() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldRePlanAfterDataChangesFromAPopulatedDatabase()
        {
            // GIVEN
            Config config = Db.DependencyResolver.resolveDependency(typeof(Config));
            double divergenceThreshold = config.Get(GraphDatabaseSettings.query_statistics_divergence_threshold);
            long   replanInterval      = config.Get(GraphDatabaseSettings.cypher_min_replan_interval).toMillis();

            TestMonitor monitor = new TestMonitor();

            Db.resolveDependency(typeof(Monitors)).addMonitorListener(monitor);
            // - setup schema -
            CreateIndex();
            //create some data
            CreateData(0, USERS, CONNECTIONS);
            ExecuteDistantFriendsCountQuery(USERS);

            long replanTime = DateTimeHelper.CurrentUnixTimeMillis() + replanInterval;

            assertTrue("Test does not work with edge setting for query_statistics_divergence_threshold: " + divergenceThreshold, divergenceThreshold > 0.0 && divergenceThreshold < 1.0);

            int usersToCreate = (( int )(Math.Ceiling((( double )USERS) / (1.0 - divergenceThreshold)))) - USERS + 1;

            //create more data
            CreateData(USERS, usersToCreate, CONNECTIONS);

            // - after the query TTL has expired -
            while (DateTimeHelper.CurrentUnixTimeMillis() <= replanTime)
            {
                Thread.Sleep(100);
            }

            // WHEN
            monitor.Reset();
            // - execute the query again -
            ExecuteDistantFriendsCountQuery(USERS);

            // THEN
            assertEquals("Query should have been replanned.", 1, monitor.Discards.get());
            assertThat("Replan should have occurred after TTL", monitor.WaitTime.get(), greaterThanOrEqualTo(replanInterval / 1000));
        }