Skip to content

Commit

Permalink
fix(graphql): use array format as label input
Browse files Browse the repository at this point in the history
Signed-off-by: Thuan Vo <thvo@redhat.com>
  • Loading branch information
Thuan Vo committed Mar 14, 2023
1 parent 806c2d7 commit 4e0acd3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
package io.cryostat.net.web.http.api.v2.graph;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
Expand All @@ -57,6 +59,7 @@
import io.cryostat.net.TargetConnectionManager;
import io.cryostat.net.security.ResourceAction;
import io.cryostat.net.web.WebServer;
import io.cryostat.net.web.http.api.v2.graph.PutActiveRecordingMetadataMutator.InputRecordingLabel;
import io.cryostat.platform.ServiceRef;
import io.cryostat.platform.discovery.TargetNode;
import io.cryostat.recordings.RecordingMetadataManager;
Expand Down Expand Up @@ -161,11 +164,21 @@ public HyperlinkedSerializableRecordingDescriptor getAuthenticated(
}
Metadata m = new Metadata();
if (settings.containsKey("metadata")) {
m =
(Metadata)
gson.fromJson(
settings.get("metadata").toString(),
new TypeToken<Metadata>() {}.getType());
Map<String, Object> _metadata =
gson.fromJson(
settings.get("metadata").toString(),
new TypeToken<Map<String, Object>>() {}.getType());

Map<String, String> labels = new HashMap<>();
List<InputRecordingLabel> inputLabels =
gson.fromJson(
_metadata.get("labels").toString(),
new TypeToken<List<InputRecordingLabel>>() {}.getType());

for (InputRecordingLabel l : inputLabels) {
labels.put(l.getKey(), l.getValue());
}
m = new Metadata(labels);
}
IRecordingDescriptor desc =
recordingTargetHelper.startRecording(
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/itest/GraphQLIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,10 @@ void testStartRecordingMutationOnSpecificTarget() throws Exception {
query.put(
"query",
"query { targetNodes(filter: { annotations: \"PORT == 9093\" }) {"
+ " doStartRecording(recording: { name: \"graphql-itest\", duration: 30,"
+ " template: \"Profiling\", templateType: \"TARGET\", archiveOnStop: true,"
+ " metadata: { labels: { newLabel: someValue } } }) { name state duration"
+ " archiveOnStop }} }");
+ " doStartRecording(recording: { name: \"graphql-itest\", duration: 30,"
+ " template: \"Profiling\", templateType: \"TARGET\", archiveOnStop: true,"
+ " metadata: { labels: [ { key: \"newLabel\", value: \"someValue\"} ] } }) {"
+ " name state duration archiveOnStop }} }");
Map<String, String> expectedLabels =
Map.of(
"template.name",
Expand Down

0 comments on commit 4e0acd3

Please sign in to comment.