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): fix hstore backend core tests failure #2431

Merged
merged 17 commits into from
Feb 27, 2024
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,8 @@
"Invalid cache implement: %s", cache.getClass());
return cache;
}

public void clearCache() {
this.caches.clear();
}

Check warning on line 157 in hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/cache/CacheManager.java

View check run for this annotation

Codecov / codecov/patch

hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/cache/CacheManager.java#L156-L157

Added lines #L156 - L157 were not covered by tests
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@
}

private Cache<Id, Object> cache(String prefix, long capacity) {
// TODO: uncomment later - graph space
Pengzna marked this conversation as resolved.
Show resolved Hide resolved
//final String name = prefix + "-" + this.graph().spaceGraphName();
final String name = prefix + "-" + "";
final String name = prefix + "-" + this.graphName();

Check warning on line 88 in hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/cache/CachedSchemaTransactionV2.java

View check run for this annotation

Codecov / codecov/patch

hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/cache/CachedSchemaTransactionV2.java#L88

Added line #L88 was not covered by tests
// NOTE: must disable schema cache-expire due to getAllSchema()
return CacheManager.instance().cache(name, capacity);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import org.apache.hugegraph.HugeGraph;
import org.apache.hugegraph.HugeGraphParams;
import org.apache.hugegraph.backend.cache.CacheManager;
import org.apache.hugegraph.backend.store.BackendFeatures;
import org.apache.hugegraph.dist.RegisterUtil;
import org.apache.hugegraph.masterelection.GlobalMasterInfo;
Expand Down Expand Up @@ -90,6 +91,7 @@ public static void clear() {
public void setup() {
this.clearData();
this.clearSchema();
this.clearCache();
}

@After
Expand Down Expand Up @@ -146,6 +148,11 @@ private void clearSchema() {
});
}

private void clearCache() {
CacheManager cacheManager = CacheManager.instance();
cacheManager.clearCache();
}

protected void mayCommitTx() {
// Commit tx probabilistically for test
if (new Random().nextBoolean()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ public void testCopySchemaWithMultiGraphs() {

SchemaManager schema = g1.schema();

schema.propertyKey("id").asInt().create();
schema.propertyKey("name").asText().create();
schema.propertyKey("age").asInt().valueSingle().create();
schema.propertyKey("city").asText().create();
schema.propertyKey("weight").asDouble().valueList().create();
schema.propertyKey("id").asInt().checkExist(false).create();
schema.propertyKey("name").asText().checkExist(false).create();
schema.propertyKey("age").asInt().valueSingle().checkExist(false).create();
schema.propertyKey("city").asText().checkExist(false).create();
schema.propertyKey("weight").asDouble().valueList().checkExist(false).create();
schema.propertyKey("born").asDate().ifNotExist().create();
schema.propertyKey("time").asDate().ifNotExist().create();

Expand Down Expand Up @@ -211,8 +211,8 @@ public void testCopySchemaWithMultiGraphsWithConflict() {
g1.serverStarted(GlobalMasterInfo.master("server-g1c"));
g2.serverStarted(GlobalMasterInfo.master("server-g2c"));

g1.schema().propertyKey("id").asInt().create();
g2.schema().propertyKey("id").asText().create();
g1.schema().propertyKey("id").asInt().checkExist(false).create();
g2.schema().propertyKey("id").asText().checkExist(false).create();

Assert.assertThrows(ExistedException.class, () -> {
g2.schema().copyFrom(g1.schema());
Expand Down
Loading