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 20, 2025
1 parent 248783e commit b8f48e9
Show file tree
Hide file tree
Showing 3 changed files with 93 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,85 @@
/*
* 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 org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.testframework.ListeningTestLogger;
import org.apache.ignite.testframework.LogListener;
import org.junit.Test;

import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;

/**
* Tests performance start with system views.
*/
public class PerformanceStatisticsSystemViewTest extends AbstractPerformanceStatisticsTest {
/** */
private final ListeningTestLogger listeningLog = new ListeningTestLogger();

/** */
private static final List<String> IGNORED_VIEWS = List.of(
"baseline.node.attributes",
"metrics",
"caches",
"sql.queries",
"nodes");

/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

cfg.setCacheConfiguration(defaultCacheConfiguration());
cfg.setGridLogger(listeningLog);

return cfg;
}

/** @throws Exception If failed. */
@Test
public void testSystemViewCaches() throws Exception {
LogListener lsnr = LogListener.matches("Performance statistics writer started.").build();
listeningLog.registerListener(lsnr);

try (IgniteEx igniteEx = startGrid(0)) {
startCollectStatistics();

Set<String> viewsExpected = new HashSet<>();
igniteEx.context().systemView().forEach(view -> {
if (view.size() > 0 && !IGNORED_VIEWS.contains(view.name()))
viewsExpected.add(view.name());
});

assertTrue("Performance statistics writer did not start.", waitForCondition(lsnr::check, TIMEOUT));

Set<String> viewsActual = new HashSet<>();
stopCollectStatisticsAndRead(new TestHandler() {
@Override public void systemView(UUID id, String name, Map<String, String> data) {
viewsActual.add(name);
}
});

assertEquals(viewsExpected, viewsActual);
}
}
}
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 b8f48e9

Please sign in to comment.