Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Contributor

@adoroszlai adoroszlai Mar 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

License header is needed in all files. Example:

/*
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
*/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we need more informative output in rat.sh and mark build failed :)
~/projects/opensource/ozone hadoop-hdds/rocksdb-checkpoint-differ/target/rat.txt: !????? /home/izlenko/projects/opensource/ozone/hadoop-hdds/rocksdb-checkpoint-differ/src/test/java/org/apache/ozone/graph/TestPrintableGraph.java izlenko:~/projects/open
I've totally missed that.

Copy link
Contributor

@adoroszlai adoroszlai Mar 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we need more informative output in rat.sh

Agreed.

and mark build failed

I don't see any problem there, the check failed: https://github.com/ivanzlenko/ozone/actions/runs/8233075581/job/22511818434

Copy link
Contributor Author

@ivanzlenko ivanzlenko Mar 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  17.799 s
[INFO] Finished at: 2024-03-11T17:44:03+05:00
[INFO] ------------------------------------------------------------------------
[INFO] 26 goals, 26 executed
~/projects/opensource/ozone
hadoop-hdds/rocksdb-checkpoint-differ/target/rat.txt: !????? /home/izlenko/projects/opensource/ozone/hadoop-hdds/rocksdb-checkpoint-differ/src/test/java/org/apache/ozone/graph/TestPrintableGraph.java

Whole output from console.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rat.sh exits with error code.

$ echo $?
1

BUILD SUCCESS is printed only because hadoop-hdds and hadoop-ozone are checked separately, the latter is successful. This will be improved in #6358, which changes the build to run a single Maven command for the whole project.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!


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 @@ -2,7 +2,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 @@ -142,10 +141,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 @@ -295,7 +295,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
<aspectj.version>1.9.7</aspectj.version>
<aspectj-plugin.version>1.14.0</aspectj-plugin.version>
<restrict-imports.enforcer.version>2.5.0</restrict-imports.enforcer.version>
<jgrapht.version>1.0.1</jgrapht.version>
<jgrapht.version>1.4.0</jgrapht.version>

<spring.version>5.3.27</spring.version>
<jooq.version>3.11.10</jooq.version>
Expand Down