Skip to content

Commit

Permalink
IGNITE-24286 Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
chesnokoff committed Feb 17, 2025
1 parent f1a7c0c commit 66093ea
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String, String> data) {
// No-op.
}
}

/** Client type to run load from. */
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Integer, Integer> cache = igniteEx.getOrCreateCache("myCache");
cache.put(0, 0);

startCollectStatistics();

Set<String> 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<String, String> 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());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -97,6 +98,7 @@
PerformanceStatisticsSelfTest.class,
PerformanceStatisticsThinClientTest.class,
PerformanceStatisticsRotateFileTest.class,
PerformanceStatisticsSystemViewTest.class,
TopologyChangesTest.class,
IgniteClusterIdTagTest.class,
StringCacheTest.class,
Expand Down

0 comments on commit 66093ea

Please sign in to comment.