Package com.indeed.proctor.common
Class Proctor
- java.lang.Object
-
- com.indeed.proctor.common.Proctor
-
public class Proctor extends java.lang.ObjectThe sole entry point for client applications determining the test buckets for a particular client. Basically a Factory to create ProctorResult for a given identifier and context, based on a TestMatrix and a specification. Supposedly immutable result of loading a test matrix, so each reload creates a new instance of this class.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidappendAllTests(java.io.Writer sb)voidappendTestMatrix(java.io.Writer writer)appends json representation of testmatrix.voidappendTestMatrixFiltered(java.io.Writer writer, java.util.Collection<java.lang.String> testNameFilter)appends json representation of testmatrix with only given testnames.voidappendTests(java.io.Writer sb, com.google.common.base.Predicate<com.indeed.proctor.common.TestChooser<?>> shouldIncludeTest)voidappendTests(java.io.Writer sb, TestType type)voidappendTestsNameFiltered(java.io.Writer sb, java.util.Collection<java.lang.String> testNameFilter)static Proctorconstruct(TestMatrixArtifact matrix, ProctorLoadResult loadResult, javax.el.FunctionMapper functionMapper)static Proctorconstruct(TestMatrixArtifact matrix, ProctorLoadResult loadResult, javax.el.FunctionMapper functionMapper, IdentifierValidator identifierValidator, ProctorResultReporter resultReporter)Factory method to do the setup and transformation of inputsProctorResultdetermineTestGroups(Identifiers identifiers, java.util.Map<java.lang.String,java.lang.Object> inputContext, ForceGroupsOptions forceGroupsOptions, java.util.Collection<java.lang.String> testNameFilter)See determineTestGroups() above.ProctorResultdetermineTestGroups(Identifiers identifiers, java.util.Map<java.lang.String,java.lang.Object> inputContext, java.util.Map<java.lang.String,java.lang.Integer> forceGroups)Deprecated.ProctorResultdetermineTestGroups(Identifiers identifiers, java.util.Map<java.lang.String,java.lang.Object> inputContext, java.util.Map<java.lang.String,java.lang.Integer> forceGroups, java.util.Collection<java.lang.String> testNameFilter)ProctorResultdetermineTestGroups(TestType testType, java.lang.String identifier, java.util.Map<java.lang.String,java.lang.Object> context, java.util.Map<java.lang.String,java.lang.Integer> forceGroups)Deprecated.ProctorLoadResultgetLoadResult()ConsumableTestDefinitiongetTestDefinition(java.lang.String name)java.util.Set<java.lang.String>getTestNames()
-
-
-
Field Detail
-
EMPTY
public static final Proctor EMPTY
-
-
Method Detail
-
construct
public static Proctor construct(@Nonnull TestMatrixArtifact matrix, @Nonnull ProctorLoadResult loadResult, @Nonnull javax.el.FunctionMapper functionMapper)
-
construct
@Nonnull public static Proctor construct(@Nonnull TestMatrixArtifact matrix, @Nonnull ProctorLoadResult loadResult, @Nonnull javax.el.FunctionMapper functionMapper, @Nonnull IdentifierValidator identifierValidator, @Nullable ProctorResultReporter resultReporter)
Factory method to do the setup and transformation of inputs- Parameters:
matrix- aTestMatrixArtifactloaded by ProctorLoaderloadResult- aProctorLoadResultwhich contains result of validation of test definitionfunctionMapper- a given elFunctionMapper- Returns:
- constructed Proctor object
-
determineTestGroups
@Nonnull @Deprecated public ProctorResult determineTestGroups(TestType testType, java.lang.String identifier, @Nonnull java.util.Map<java.lang.String,java.lang.Object> context, @Nonnull java.util.Map<java.lang.String,java.lang.Integer> forceGroups)
Deprecated.Determine which test buckets apply to a particular client.- Parameters:
testType- theTestTypeof the testidentifier- a unique-ishStringidentifying the client. This should be consistent across requests from the same client.context- aMapcontaining variables describing the context in which the request is executing. These will be supplied to any rules that execute to determine test eligibility.forceGroups- aMapfrom a String test name to an Integer bucket value. For the specified test allocate the specified bucket (if valid) regardless of the standard logic- Returns:
- a
ProctorResultcontaining the test buckets that apply to this client as well as the versions of the tests that were executed
-
determineTestGroups
@Nonnull @Deprecated public ProctorResult determineTestGroups(@Nonnull Identifiers identifiers, @Nonnull java.util.Map<java.lang.String,java.lang.Object> inputContext, @Nonnull java.util.Map<java.lang.String,java.lang.Integer> forceGroups)
Deprecated.Determine which test buckets apply to a particular client.- Parameters:
identifiers- aMapof unique-ishStrings describing the request in the context of differentTestTypes.For example,TestType.USERhas a CTK associated,TestType.EMAILis an email address,TestType.PAGEmight be a url-encoded String containing the normalized relevant page parametersinputContext- aMapcontaining variables describing the context in which the request is executing. These will be supplied to any rules that execute to determine test eligibility.forceGroups- aMapfrom a String test name to an Integer bucket value. For the specified test allocate the specified bucket (if valid) regardless of the standard logic- Returns:
- a
ProctorResultcontaining the test buckets that apply to this client as well as the versions of the tests that were executed
-
determineTestGroups
@Nonnull @Deprecated public ProctorResult determineTestGroups(@Nonnull Identifiers identifiers, @Nonnull java.util.Map<java.lang.String,java.lang.Object> inputContext, @Nonnull java.util.Map<java.lang.String,java.lang.Integer> forceGroups, @Nonnull java.util.Collection<java.lang.String> testNameFilter)
-
determineTestGroups
@Nonnull public ProctorResult determineTestGroups(@Nonnull Identifiers identifiers, @Nonnull java.util.Map<java.lang.String,java.lang.Object> inputContext, @Nonnull ForceGroupsOptions forceGroupsOptions, @Nonnull java.util.Collection<java.lang.String> testNameFilter)
See determineTestGroups() above. Adds a test name filter for returning a subset of tests. This is useful for the Proctor REST API. It lacks a specification and needs a way to evaluate only the tests mentioned in the HTTP parameters by each particular query. Otherwise, there will be logged errors due to missing context variables.- Parameters:
identifiers- aMapof unique-ishStrings describing the request in the context of differentTestTypes.For example,TestType.USERhas a CTK associated,TestType.EMAILis an email address,TestType.PAGEmight be a url-encoded String containing the normalized relevant page parametersinputContext- aMapcontaining variables describing the context in which the request is executing. These will be supplied to any rules that execute to determine test eligibility.forceGroupsOptions- aMapfrom a String test name to an Integer bucket value. For the specified test allocate the specified bucket (if valid) regardless of the standard logictestNameFilter- Only evaluates and returns the tests named in this collection. If empty, no filter is applied.- Returns:
- a
ProctorResultcontaining the test buckets that apply to this client as well as the versions of the tests that were executed
-
getTestNames
public java.util.Set<java.lang.String> getTestNames()
-
getTestDefinition
public ConsumableTestDefinition getTestDefinition(java.lang.String name)
-
getLoadResult
public ProctorLoadResult getLoadResult()
-
appendAllTests
public void appendAllTests(java.io.Writer sb)
-
appendTests
public void appendTests(java.io.Writer sb, TestType type)
-
appendTestsNameFiltered
public void appendTestsNameFiltered(java.io.Writer sb, java.util.Collection<java.lang.String> testNameFilter)
-
appendTests
public void appendTests(java.io.Writer sb, @Nonnull com.google.common.base.Predicate<com.indeed.proctor.common.TestChooser<?>> shouldIncludeTest)
-
appendTestMatrix
public void appendTestMatrix(java.io.Writer writer) throws java.io.IOExceptionappends json representation of testmatrix. Does not close the writer.- Throws:
java.io.IOException
-
appendTestMatrixFiltered
public void appendTestMatrixFiltered(java.io.Writer writer, java.util.Collection<java.lang.String> testNameFilter) throws java.io.IOExceptionappends json representation of testmatrix with only given testnames. Does not close the writer.- Throws:
java.io.IOException
-
-