Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pd-store): intro Useless annotation & refactor and mark the failed tests in hg-pd-test #2480

Merged
merged 18 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from 17 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
25 changes: 13 additions & 12 deletions .github/workflows/pd-store.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,29 +45,30 @@ jobs:
run: |
mvn clean package -U -Dmaven.javadoc.skip=true -Dmaven.test.skip=true -ntp

- name: Prepare env and service
- name: Run common test
run: |
$TRAVIS_DIR/start-pd.sh
mvn test -pl hugegraph-pd/hg-pd-test -am -P pd-common-test

- name: Run client test
- name: Run core test
run: |
mvn test -pl hugegraph-pd/hg-pd-test -am -P pd-client-test -Dmaven.test.failure.ignore=true
mvn test -pl hugegraph-pd/hg-pd-test -am -P pd-core-test

- name: Run core test
# The above tests do not require starting a PD instance.
- name: Prepare env and service
run: |
mvn test -pl hugegraph-pd/hg-pd-test -am -P pd-core-test -Dmaven.test.failure.ignore=true
$TRAVIS_DIR/start-pd.sh

- name: Run cli-tools test
- name: Run client test
run: |
mvn test -pl hugegraph-pd/hg-pd-test -am -P pd-cli-tools-test -Dmaven.test.failure.ignore=true
mvn test -pl hugegraph-pd/hg-pd-test -am -P pd-client-test

- name: Run common test
- name: Run cli-tools test
run: |
mvn test -pl hugegraph-pd/hg-pd-test -am -P pd-common-test -Dmaven.test.failure.ignore=true
mvn test -pl hugegraph-pd/hg-pd-test -am -P pd-cli-tools-test

- name: Run service test
- name: Run rest test
run: |
mvn test -pl hugegraph-pd/hg-pd-test -am -P pd-service-test -Dmaven.test.failure.ignore=true
mvn test -pl hugegraph-pd/hg-pd-test -am -P pd-rest-test

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@

package org.apache.hugegraph.pd.client;

import org.apache.hugegraph.pd.common.Useless;
import org.apache.hugegraph.pd.grpc.discovery.NodeInfos;
import org.apache.hugegraph.pd.grpc.discovery.Query;

@Useless
public interface Discoverable {

NodeInfos getNodeInfos(Query query);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.function.Function;

import org.apache.hugegraph.pd.common.PDException;
import org.apache.hugegraph.pd.common.Useless;
import org.apache.hugegraph.pd.grpc.discovery.DiscoveryServiceGrpc;
import org.apache.hugegraph.pd.grpc.discovery.NodeInfo;
import org.apache.hugegraph.pd.grpc.discovery.NodeInfos;
Expand All @@ -38,6 +39,7 @@
import io.grpc.ManagedChannelBuilder;
import lombok.extern.slf4j.Slf4j;

@Useless
@Slf4j
public abstract class DiscoveryClient implements Closeable, Discoverable {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
import java.util.Map;
import java.util.function.Consumer;

import org.apache.hugegraph.pd.common.Useless;
import org.apache.hugegraph.pd.grpc.discovery.NodeInfo;
import org.apache.hugegraph.pd.grpc.discovery.RegisterType;

@Useless
public class DiscoveryClientImpl extends DiscoveryClient {

private final String id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.hugegraph.pd.client;

import org.apache.hugegraph.pd.common.KVPair;
import org.apache.hugegraph.pd.common.Useless;
import org.apache.hugegraph.pd.grpc.PDGrpc;
import org.apache.hugegraph.pd.grpc.Pdpb;

Expand All @@ -27,6 +28,7 @@
import io.grpc.stub.AbstractStub;
import lombok.extern.slf4j.Slf4j;

@Useless
@Slf4j
public class LicenseClient extends AbstractClient {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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.hugegraph.pd.common;
VGalaxies marked this conversation as resolved.
Show resolved Hide resolved

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* The "Useless" annotation indicates that the annotated object can be safely removed without
* affecting existing functionality, including objects that are only referenced in tests.
*/
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.TYPE})
@Retention(RetentionPolicy.SOURCE)
public @interface Useless {}
VGalaxies marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.hugegraph.pd;

import java.util.List;
import java.util.Objects;

import org.apache.hugegraph.pd.common.PDException;
import org.apache.hugegraph.pd.config.PDConfig;
Expand Down Expand Up @@ -128,7 +129,11 @@
* @throws PDException when io error
*/
public int getPartitionCount() throws PDException {
return getPDConfig().getPartitionCount();
Metapb.PDConfig config = getPDConfig();

Check warning on line 132 in hugegraph-pd/hg-pd-core/src/main/java/org/apache/hugegraph/pd/ConfigService.java

View check run for this annotation

Codecov / codecov/patch

hugegraph-pd/hg-pd-core/src/main/java/org/apache/hugegraph/pd/ConfigService.java#L132

Added line #L132 was not covered by tests
if (Objects.nonNull(config)) {
return config.getPartitionCount();

Check warning on line 134 in hugegraph-pd/hg-pd-core/src/main/java/org/apache/hugegraph/pd/ConfigService.java

View check run for this annotation

Codecov / codecov/patch

hugegraph-pd/hg-pd-core/src/main/java/org/apache/hugegraph/pd/ConfigService.java#L134

Added line #L134 was not covered by tests
}
return pdConfig.getInitialPartitionCount();

Check warning on line 136 in hugegraph-pd/hg-pd-core/src/main/java/org/apache/hugegraph/pd/ConfigService.java

View check run for this annotation

Codecov / codecov/patch

hugegraph-pd/hg-pd-core/src/main/java/org/apache/hugegraph/pd/ConfigService.java#L136

Added line #L136 was not covered by tests
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ public void shutDown() {
}

public boolean isLeader() {
if (Objects.isNull(this.raftNode)) {
return false;
}
return this.raftNode.isLeader(true);
}

Expand Down
4 changes: 2 additions & 2 deletions hugegraph-pd/hg-pd-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,14 @@
</configuration>
</execution>
<execution>
<id>pd-service-test</id>
<id>pd-rest-test</id>
<configuration>
<testSourceDirectory>${basedir}/src/main/java/
</testSourceDirectory>
<testClassesDirectory>${basedir}/target/classes/
</testClassesDirectory>
<includes>
<include>**/ServerSuiteTest.java</include>
<include>**/PDRestSuiteTest.java</include>
</includes>
</configuration>
</execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@

import org.apache.hugegraph.pd.common.KVPair;
import org.apache.hugegraph.pd.common.PartitionCache;
import org.apache.hugegraph.pd.common.Useless;
import org.apache.hugegraph.pd.grpc.Metapb;

import com.google.common.collect.Range;
import com.google.common.collect.RangeMap;
import com.google.common.collect.TreeRangeMap;

@Useless // can be merged to org.apache.hugegraph.pd.common.PartitionCacheTest
public class PartitionCacheTest {

// @Test
Expand Down

This file was deleted.

Loading
Loading