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 13 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
4 changes: 2 additions & 2 deletions .github/workflows/pd-store.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ jobs:
run: |
mvn test -pl hugegraph-pd/hg-pd-test -am -P pd-common-test -Dmaven.test.failure.ignore=true

- 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 -Dmaven.test.failure.ignore=true

- 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
Expand Up @@ -15,28 +15,17 @@
* limitations under the License.
*/

package org.apache.hugegraph.pd.service;
package org.apache.hugegraph.pd.common;
VGalaxies marked this conversation as resolved.
Show resolved Hide resolved

import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import lombok.extern.slf4j.Slf4j;


@RunWith(Suite.class)
@Suite.SuiteClasses({
RestApiTest.class,
ConfigServiceTest.class,
IdServiceTest.class,
KvServiceTest.class,
LogServiceTest.class,
StoreServiceTest.class,
StoreNodeServiceNewTest.class,
StoreMonitorDataServiceTest.class,
TaskScheduleServiceTest.class,
PartitionServiceTest.class
})

@Slf4j
public class ServerSuiteTest {
}
/**
* 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 @@ public synchronized PDConfig setPartitionCount(int count) {
* @throws PDException when io error
*/
public int getPartitionCount() throws PDException {
return getPDConfig().getPartitionCount();
Metapb.PDConfig config = getPDConfig();
if (Objects.nonNull(config)) {
return config.getPartitionCount();
}
return pdConfig.getInitialPartitionCount();
}

@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