Skip to content

Commit

Permalink
Support output verbosity option for nodes status getter
Browse files Browse the repository at this point in the history
  • Loading branch information
antas-marcin committed Dec 7, 2023
1 parent fb0a48c commit 2617112
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
public class NodesStatusGetter extends BaseClient<NodesStatusResponse> implements ClientResult<NodesStatusResponse> {

private String className;
private String output;

public NodesStatusGetter(HttpClient httpClient, Config config) {
super(httpClient, config);
Expand All @@ -23,6 +24,11 @@ public NodesStatusGetter withClassName(String className) {
return this;
}

public NodesStatusGetter withOutput(String output) {
this.output = output;
return this;
}

@Override
public Result<NodesStatusResponse> run() {
Response<NodesStatusResponse> resp = sendGetRequest(path(), NodesStatusResponse.class);
Expand All @@ -34,6 +40,9 @@ private String path() {
if (StringUtils.isNotBlank(className)) {
path = String.format("%s/%s", path, UrlEncoder.encodePathParam(className));
}
if (StringUtils.isNotBlank(output)) {
path = String.format("%s?%s", path, UrlEncoder.encodeQueryParam("output", output));
}
return path;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package io.weaviate.client.v1.cluster.model;

public interface NodeStatusOutput {
String VERBOSE = "verbose";
String MINIMAL = "minimal";
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
public class WeaviateVersion {

// to be set according to weaviate docker image
public static final String EXPECTED_WEAVIATE_VERSION = "1.22.6";
public static final String EXPECTED_WEAVIATE_VERSION = "1.23.0-rc.0";
// to be set according to weaviate docker image
public static final String EXPECTED_WEAVIATE_GIT_HASH = "ea13956";
public static final String EXPECTED_WEAVIATE_GIT_HASH = "977af56";

private WeaviateVersion() {}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.weaviate.integration.client.cluster;

import io.weaviate.client.base.util.TriConsumer;
import io.weaviate.client.v1.cluster.model.NodeStatusOutput;
import org.junit.After;
import org.junit.Before;
import org.junit.ClassRule;
Expand Down Expand Up @@ -77,7 +78,7 @@ public void testClusterNodesEndpointWithData() {
testGenerics.createTestSchemaAndData(client);

// when
Result<NodesStatusResponse> result = client.cluster().nodesStatusGetter().run();
Result<NodesStatusResponse> result = client.cluster().nodesStatusGetter().withOutput(NodeStatusOutput.VERBOSE).run();

// then
assertThat(result).isNotNull();
Expand Down Expand Up @@ -167,4 +168,63 @@ public void shouldGetNodeStatusPerClass() {
assertSingleNode.accept(resultSoup);
assertCounts.accept(resultSoup.getResult().getNodes()[0], 1L, (long) soupIds.size());
}

@Test
public void testClusterNodesEndpointWithDataWithOutputMinimal() {
// given
testGenerics.createTestSchemaAndData(client);

// when
Result<NodesStatusResponse> result = client.cluster().nodesStatusGetter().withOutput(NodeStatusOutput.MINIMAL).run();

// then
assertThat(result).isNotNull();
assertThat(result.hasErrors()).isFalse();

NodesStatusResponse nodes = result.getResult();
assertThat(nodes).isNotNull();
assertThat(nodes.getNodes()).hasSize(1);

NodesStatusResponse.NodeStatus nodeStatus = nodes.getNodes()[0];
assertThat(nodeStatus.getName()).isNotBlank();
assertThat(nodeStatus)
.returns(EXPECTED_WEAVIATE_VERSION, NodesStatusResponse.NodeStatus::getVersion)
.returns(EXPECTED_WEAVIATE_GIT_HASH, NodesStatusResponse.NodeStatus::getGitHash)
.returns(NodesStatusResponse.Status.HEALTHY, NodesStatusResponse.NodeStatus::getStatus)
.extracting(NodesStatusResponse.NodeStatus::getStats)
.returns(2L, NodesStatusResponse.Stats::getShardCount)
.returns(6L, NodesStatusResponse.Stats::getObjectCount);

assertThat(nodeStatus.getShards()).isNull();
}

@Test
public void testClusterNodesEndpointWithDataWithClassWithOutputMinimal() {
// given
testGenerics.createTestSchemaAndData(client);

// when
Result<NodesStatusResponse> result = client.cluster().nodesStatusGetter()
.withClassName("Soup").withOutput(NodeStatusOutput.MINIMAL).run();

// then
assertThat(result).isNotNull();
assertThat(result.hasErrors()).isFalse();

NodesStatusResponse nodes = result.getResult();
assertThat(nodes).isNotNull();
assertThat(nodes.getNodes()).hasSize(1);

NodesStatusResponse.NodeStatus nodeStatus = nodes.getNodes()[0];
assertThat(nodeStatus.getName()).isNotBlank();
assertThat(nodeStatus)
.returns(EXPECTED_WEAVIATE_VERSION, NodesStatusResponse.NodeStatus::getVersion)
.returns(EXPECTED_WEAVIATE_GIT_HASH, NodesStatusResponse.NodeStatus::getGitHash)
.returns(NodesStatusResponse.Status.HEALTHY, NodesStatusResponse.NodeStatus::getStatus)
.extracting(NodesStatusResponse.NodeStatus::getStats)
.returns(1L, NodesStatusResponse.Stats::getShardCount)
.returns(2L, NodesStatusResponse.Stats::getObjectCount);

assertThat(nodeStatus.getShards()).isNull();
}
}
2 changes: 1 addition & 1 deletion src/test/resources/docker-compose-azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
- --scheme
- http
- --write-timeout=600s
image: semitechnologies/weaviate:preview-hnsw-bq-ea13956
image: semitechnologies/weaviate:1.23.0-rc.0
restart: on-failure:0
environment:
PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
Expand Down
4 changes: 2 additions & 2 deletions src/test/resources/docker-compose-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
- --scheme
- http
- --write-timeout=600s
image: semitechnologies/weaviate:preview-hnsw-bq-ea13956
image: semitechnologies/weaviate:1.23.0-rc.0
restart: on-failure:0
environment:
LOG_LEVEL: 'debug'
Expand Down Expand Up @@ -41,7 +41,7 @@ services:
- '8088'
- --scheme
- http
image: semitechnologies/weaviate:preview-hnsw-bq-ea13956
image: semitechnologies/weaviate:1.23.0-rc.0
restart: on-failure:0
environment:
LOG_LEVEL: 'debug'
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/docker-compose-okta-cc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
- --scheme
- http
- --write-timeout=600s
image: semitechnologies/weaviate:preview-hnsw-bq-ea13956
image: semitechnologies/weaviate:1.23.0-rc.0
restart: on-failure:0
environment:
PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/docker-compose-okta-users.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
- --scheme
- http
- --write-timeout=600s
image: semitechnologies/weaviate:preview-hnsw-bq-ea13956
image: semitechnologies/weaviate:1.23.0-rc.0
restart: on-failure:0
environment:
PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/docker-compose-proxy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:
- '8080'
- --scheme
- http
image: semitechnologies/weaviate:preview-hnsw-bq-ea13956
image: semitechnologies/weaviate:1.23.0-rc.0
restart: on-failure:0
environment:
LOG_LEVEL: "debug"
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/docker-compose-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:
- '8080'
- --scheme
- http
image: semitechnologies/weaviate:preview-hnsw-bq-ea13956
image: semitechnologies/weaviate:1.23.0-rc.0
links:
- "contextionary:contextionary"
restart: on-failure:0
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/docker-compose-wcs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
- --scheme
- http
- --write-timeout=600s
image: semitechnologies/weaviate:preview-hnsw-bq-ea13956
image: semitechnologies/weaviate:1.23.0-rc.0
restart: on-failure:0
environment:
PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
Expand Down

0 comments on commit 2617112

Please sign in to comment.