Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

PROC-1528: Add payload experiment config fields #166

Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ springJdbc = 'org.springframework:spring-jdbc:5.3.19'
springTest = 'org.springframework:spring-test:5.3.19'
springWeb = 'org.springframework:spring-web:5.3.19'
springWebmvc = 'org.springframework:spring-webmvc:5.3.19'
lombok = 'org.projectlombok:lombok:1.18.32'
ant = 'org.apache.ant:ant:1.10.9'
svnkit = 'org.tmatesoft.svnkit:svnkit:1.8.5'
tomcatElApi = 'org.apache.tomcat:tomcat-el-api:7.0.109'
Expand Down
5 changes: 5 additions & 0 deletions proctor-common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ dependencies {
testImplementation libs.annotationApi
testImplementation libs.mockito
testImplementation libs.jsr305
compileOnly libs.lombok
annotationProcessor libs.lombok

testCompileOnly libs.lombok
testAnnotationProcessor libs.lombok
}

// Need to remove all dependenceis that get added or will cause issues upstream when projects include
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public class ConsumableTestDefinition {
private boolean containsUnitlessAllocation = false;
private boolean forceLogging = false;

@Nullable PayloadExperimentConfig payloadExperimentConfig;

public ConsumableTestDefinition() {
/* intentionally empty */
}
Expand Down Expand Up @@ -141,7 +143,8 @@ private ConsumableTestDefinition(
final boolean evaluateForIncognitoUsers,
final boolean enableUnitlessAllocations,
final boolean containsUnitlessAllocation,
final boolean forceLogging) {
final boolean forceLogging,
final PayloadExperimentConfig payloadExperimentConfig) {
this.constants = constants;
this.version = version;
this.salt = salt;
Expand All @@ -157,6 +160,7 @@ private ConsumableTestDefinition(
this.enableUnitlessAllocations = enableUnitlessAllocations;
this.containsUnitlessAllocation = containsUnitlessAllocation;
this.forceLogging = forceLogging;
this.payloadExperimentConfig = payloadExperimentConfig;
}

@Nonnull
Expand Down Expand Up @@ -298,6 +302,15 @@ public void setForceLogging(final boolean forceLogging) {
this.forceLogging = forceLogging;
}

@Nullable
public PayloadExperimentConfig getPayloadExperimentConfig() {
return payloadExperimentConfig;
}

public void setPayloadExperimentConfig(final PayloadExperimentConfig payloadExperimentConfig) {
this.payloadExperimentConfig = payloadExperimentConfig;
}

@Nonnull
public static ConsumableTestDefinition fromTestDefinition(@Nonnull final TestDefinition td) {
final Map<String, Object> specialConstants = td.getSpecialConstants();
Expand Down Expand Up @@ -354,6 +367,7 @@ public static ConsumableTestDefinition fromTestDefinition(@Nonnull final TestDef
td.getEvaluateForIncognitoUsers(),
td.getEnableUnitlessAllocations(),
containsUnitlessAllocation,
td.getForceLogging());
td.getForceLogging(),
td.getPayloadExperimentConfig());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.indeed.proctor.common.model;

import lombok.Data;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;

@Data
public class PayloadExperimentConfig {
@Nullable private String priority;
@Nonnull private List<String> namespaces = Collections.emptyList();

@Override
public String toString() {
return "PayloadExperimentConfig{"
+ "priority='"
+ priority
+ '\''
+ ", namespaces="
+ namespaces
+ '}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public class TestDefinition {

private boolean forceLogging;

@Nullable PayloadExperimentConfig payloadExperimentConfig;

public TestDefinition() {
/* intentionally empty */
}
Expand Down Expand Up @@ -141,6 +143,7 @@ public TestDefinition(
this.metaTags = metaTags;
this.evaluateForIncognitoUsers = false;
this.forceLogging = false;
payloadExperimentConfig = null;
}

public TestDefinition(@Nonnull final TestDefinition other) {
Expand All @@ -163,6 +166,7 @@ private TestDefinition(@Nonnull final Builder builder) {
evaluateForIncognitoUsers = builder.evaluateForIncognitoUsers;
enableUnitlessAllocations = builder.enableUnitlessAllocations;
forceLogging = builder.forceLogging;
payloadExperimentConfig = builder.payloadExperimentConfig;
}

public static Builder builder() {
Expand Down Expand Up @@ -332,6 +336,11 @@ public boolean getForceLogging() {
return forceLogging;
}

@Nullable
public PayloadExperimentConfig getPayloadExperimentConfig() {
return payloadExperimentConfig;
}

@Override
public String toString() {
return "TestDefinition{"
Expand Down Expand Up @@ -369,6 +378,8 @@ public String toString() {
+ enableUnitlessAllocations
+ ", forceLogging="
+ forceLogging
+ ", payloadExperimentConfig="
+ payloadExperimentConfig
+ '}';
}

Expand Down Expand Up @@ -403,7 +414,8 @@ public int hashCode() {
dependsOn,
evaluateForIncognitoUsers,
enableUnitlessAllocations,
forceLogging);
forceLogging,
payloadExperimentConfig);
}

/**
Expand Down Expand Up @@ -436,7 +448,8 @@ && bucketListEqual(buckets, that.buckets)
&& Objects.equals(dependsOn, that.dependsOn)
&& Objects.equals(evaluateForIncognitoUsers, that.evaluateForIncognitoUsers)
&& Objects.equals(enableUnitlessAllocations, that.enableUnitlessAllocations)
&& Objects.equals(forceLogging, that.forceLogging);
&& Objects.equals(forceLogging, that.forceLogging)
&& Objects.equals(payloadExperimentConfig, that.payloadExperimentConfig);
}

@VisibleForTesting
Expand Down Expand Up @@ -478,6 +491,7 @@ public static class Builder {
private boolean evaluateForIncognitoUsers;
private boolean enableUnitlessAllocations;
private boolean forceLogging;
private PayloadExperimentConfig payloadExperimentConfig;

public Builder from(@Nonnull final TestDefinition other) {
setVersion(other.version);
Expand All @@ -495,6 +509,7 @@ public Builder from(@Nonnull final TestDefinition other) {
setEvaluateForIncognitoUsers(other.evaluateForIncognitoUsers);
setEnableUnitlessAllocations(other.enableUnitlessAllocations);
setForceLogging(other.forceLogging);
setPayloadExperimentConfig(other.payloadExperimentConfig);
return this;
}

Expand Down Expand Up @@ -608,6 +623,12 @@ public Builder setForceLogging(final boolean forceLogging) {
return this;
}

public Builder setPayloadExperimentConfig(
final PayloadExperimentConfig payloadExperimentConfig) {
this.payloadExperimentConfig = payloadExperimentConfig;
return this;
}

public TestDefinition build() {
return new TestDefinition(this);
}
Expand Down
Loading