Skip to content

Commit

Permalink
HDDS-10503. Bump jgrapht to 1.4.0 (apache#6364)
Browse files Browse the repository at this point in the history
(cherry picked from commit d68ea97)
  • Loading branch information
ivanzlenko authored and Maksim Myskov committed Apr 3, 2024
1 parent 087f21b commit c78986c
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* 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.ozone.graph;

import com.google.common.graph.MutableGraph;
import org.apache.ozone.rocksdiff.CompactionNode;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.when;

/**
* This class is used for testing the PrintableGraph class.
* It contains methods to test the generation and printing of graphs with different types.
*/
@ExtendWith(MockitoExtension.class)
public class TestPrintableGraph {
@TempDir
private Path dir;

@Mock
private MutableGraph<CompactionNode> mutableGraph;

@ParameterizedTest
@EnumSource(PrintableGraph.GraphType.class)
void testPrintNoGraphMessage(PrintableGraph.GraphType graphType) {
PrintableGraph graph = new PrintableGraph(mutableGraph, graphType);
try {
graph.generateImage(dir.resolve(graphType.name()).toString());
} catch (IOException e) {
assertEquals("Graph is empty.", e.getMessage());
}
}

@ParameterizedTest
@EnumSource(PrintableGraph.GraphType.class)
void testPrintActualGraph(PrintableGraph.GraphType graphType) throws IOException {
Set<CompactionNode> nodes = Stream.of(
new CompactionNode("fileName1",
100, 100, "startKey1", "endKey1", "columnFamily1"),
new CompactionNode("fileName2",
200, 200, "startKey2", "endKey2", null),
new CompactionNode("fileName3",
300, 300, null, "endKey3", "columnFamily3"),
new CompactionNode("fileName4",
400, 400, "startKey4", null, "columnFamily4")
).collect(Collectors.toSet());
when(mutableGraph.nodes()).thenReturn(nodes);

PrintableGraph graph = new PrintableGraph(mutableGraph, graphType);
graph.generateImage(dir.resolve(graphType.name()).toString());

assertTrue(Files.exists(dir.resolve(graphType.name())), "Graph hasn't been generated");
}
}
3 changes: 1 addition & 2 deletions hadoop-ozone/dist/src/main/license/jar-report.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ share/ozone/lib/animal-sniffer-annotations.jar
share/ozone/lib/annotations.jar
share/ozone/lib/annotations.jar
share/ozone/lib/aopalliance.jar
share/ozone/lib/antlr4-runtime.jar
share/ozone/lib/aopalliance-repackaged.jar
share/ozone/lib/aspectjrt.jar
share/ozone/lib/aspectjweaver.jar
Expand Down Expand Up @@ -147,10 +146,10 @@ share/ozone/lib/jetty-util-ajax.jar
share/ozone/lib/jetty-util.jar
share/ozone/lib/jetty-webapp.jar
share/ozone/lib/jetty-xml.jar
share/ozone/lib/jgraph.jar
share/ozone/lib/jgrapht-core.jar
share/ozone/lib/jgrapht-ext.jar
share/ozone/lib/jgraphx.jar
share/ozone/lib/jheaps.jar
share/ozone/lib/jmespath-java.jar
share/ozone/lib/jna.jar
share/ozone/lib/jna-platform.jar
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
<lz4.version>1.9.3</lz4.version>
<snappy.version>1.1.8</snappy.version>
<zstd.version>1.4.9</zstd.version>
<jgrapht.version>1.0.1</jgrapht.version>
<jgrapht.version>1.4.0</jgrapht.version>

<vault.driver.version>5.1.0</vault.driver.version>
<native.lib.tmp.dir></native.lib.tmp.dir>
Expand Down

0 comments on commit c78986c

Please sign in to comment.