Skip to content

Commit

Permalink
adding support to k6 cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
cmendesce committed Apr 27, 2024
1 parent 1649af8 commit 7c90b12
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import static io.resiliencebench.support.Annotations.CREATED_BY;
Expand All @@ -38,6 +39,7 @@ public ObjectMeta createMeta(Scenario scenario, Workload workload) {
return new ObjectMetaBuilder()
.withName(workload.getMetadata().getName() + "-" + UUID.fromString(scenario.getMetadata().getUid()))
.withNamespace(workload.getMetadata().getNamespace())
.withLabels(Map.of("app", "k6"))
.addToAnnotations(CREATED_BY, "resiliencebench-operator")
.addToAnnotations("resiliencebench.io/scenario", scenario.getMetadata().getName())
.addToAnnotations("resiliencebench.io/workload", workload.getMetadata().getName())
Expand Down Expand Up @@ -89,10 +91,11 @@ public Container createK6Container(Scenario scenario, ScenarioWorkload scenarioW
.withImage("grafana/k6") // TODO receive it from the workload
.withCommand(createCommand(scenario, scenarioWorkload, workload))
.withImagePullPolicy("IfNotPresent")
.withPorts(new ContainerPortBuilder().withContainerPort(6565).build())
.withVolumeMounts(
new VolumeMount("/scripts", "None", "script-volume", false, null, null),
new VolumeMount("/results", "HostToContainer", "test-results", false, null, null)
);
).withEnv(new EnvVar("K6_WEB_DASHBOARD", "true", null));
if (workload.getSpec().getCloud() != null) {
container.withEnv( // TODO send env vars from the workload, just like in containers
new EnvVar("K6_CLOUD_TOKEN", workload.getSpec().getCloud().token(), null),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class WorkloadSpec {
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<Integer> users = new ArrayList<>();
@Min(1)
@JsonPropertyDescription("Workload duration in milliseconds")
@JsonPropertyDescription("Workload duration in seconds")
private int duration;
@Pattern("^(http:\\/\\/www\\.|https:\\/\\/www\\.|http:\\/\\/|https:\\/\\/)?[a-z0-9]+([\\-\\.]{1}[a-z0-9]+)*\\.[a-z]{2,5}(:[0-9]{1,5})?(\\/.*)?$")
private String targetUrl;
Expand Down

0 comments on commit 7c90b12

Please sign in to comment.