From 66093ea411647efc061d3ed86fed205e1bb6f67b Mon Sep 17 00:00:00 2001 From: chesnokoff Date: Tue, 11 Feb 2025 11:17:17 +0300 Subject: [PATCH] IGNITE-24286 Add test --- .../AbstractPerformanceStatisticsTest.java | 6 ++ .../PerformanceStatisticsSystemViewTest.java | 78 +++++++++++++++++++ .../IgniteBasicWithPersistenceTestSuite.java | 2 + 3 files changed, 86 insertions(+) create mode 100644 modules/core/src/test/java/org/apache/ignite/internal/processors/performancestatistics/PerformanceStatisticsSystemViewTest.java diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/performancestatistics/AbstractPerformanceStatisticsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/performancestatistics/AbstractPerformanceStatisticsTest.java index cc0d4ad41003c..dcf5b26b0eae4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/performancestatistics/AbstractPerformanceStatisticsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/performancestatistics/AbstractPerformanceStatisticsTest.java @@ -20,6 +20,7 @@ import java.io.File; import java.lang.management.ThreadInfo; import java.util.List; +import java.util.Map; import java.util.UUID; import org.apache.ignite.Ignite; import org.apache.ignite.internal.processors.cache.query.GridCacheQueryType; @@ -237,6 +238,11 @@ public static class TestHandler implements PerformanceStatisticsHandler { @Override public void pagesWriteThrottle(UUID nodeId, long endTime, long duration) { // No-op. } + + /** {@inheritDoc} */ + @Override public void systemView(UUID id, String name, Map data) { + // No-op. + } } /** Client type to run load from. */ diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/performancestatistics/PerformanceStatisticsSystemViewTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/performancestatistics/PerformanceStatisticsSystemViewTest.java new file mode 100644 index 0000000000000..a1341f4da11ad --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/performancestatistics/PerformanceStatisticsSystemViewTest.java @@ -0,0 +1,78 @@ +/* + * 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. + */ + +package org.apache.ignite.internal.processors.performancestatistics; + +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.atomic.AtomicBoolean; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; +import org.junit.Test; + +/** + * Tests performance start with system views. + */ +public class PerformanceStatisticsSystemViewTest extends AbstractPerformanceStatisticsTest { + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + cfg.setCacheConfiguration(defaultCacheConfiguration().setAtomicityMode(CacheAtomicityMode.ATOMIC)); + + return cfg; + } + + /** @throws Exception If failed. */ + @Test + public void testSystemViewCaches() throws Exception { + try (IgniteEx igniteEx = startGrid(0)) { + IgniteCache cache = igniteEx.getOrCreateCache("myCache"); + cache.put(0, 0); + + startCollectStatistics(); + + Set viewsExpected = new HashSet<>(List.of("baseline.node.attributes", + "caches", + "partitionStates", + "configuration", + "distributed.metastorage", + "local.cache.groups.io", + "dataRegionPageLists")); + + AtomicBoolean hasMyCache = new AtomicBoolean(false); + + stopCollectStatisticsAndRead(new TestHandler() { + @Override public void systemView(UUID id, String name, Map data) { + viewsExpected.remove(name); + + if ("caches".equals(name)) + hasMyCache.compareAndSet(false, "myCache".equals(data.get("cacheGroupName"))); + + } + }); + + assertTrue("System view record for myCache does not exist.", hasMyCache.get()); + assertTrue("System views " + viewsExpected + " were not found.", viewsExpected.isEmpty()); + } + } +} diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicWithPersistenceTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicWithPersistenceTestSuite.java index 721c5adb40da2..a2c2d922f2655 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicWithPersistenceTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicWithPersistenceTestSuite.java @@ -47,6 +47,7 @@ import org.apache.ignite.internal.processors.performancestatistics.PerformanceStatisticsPropertiesTest; import org.apache.ignite.internal.processors.performancestatistics.PerformanceStatisticsRotateFileTest; import org.apache.ignite.internal.processors.performancestatistics.PerformanceStatisticsSelfTest; +import org.apache.ignite.internal.processors.performancestatistics.PerformanceStatisticsSystemViewTest; import org.apache.ignite.internal.processors.performancestatistics.PerformanceStatisticsThinClientTest; import org.apache.ignite.internal.processors.performancestatistics.StringCacheTest; import org.apache.ignite.internal.processors.performancestatistics.TopologyChangesTest; @@ -97,6 +98,7 @@ PerformanceStatisticsSelfTest.class, PerformanceStatisticsThinClientTest.class, PerformanceStatisticsRotateFileTest.class, + PerformanceStatisticsSystemViewTest.class, TopologyChangesTest.class, IgniteClusterIdTagTest.class, StringCacheTest.class,