当前位置: 首页>>代码示例>>Java>>正文


Java ConsumableTestDefinition类代码示例

本文整理汇总了Java中com.indeed.proctor.common.model.ConsumableTestDefinition的典型用法代码示例。如果您正苦于以下问题:Java ConsumableTestDefinition类的具体用法?Java ConsumableTestDefinition怎么用?Java ConsumableTestDefinition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ConsumableTestDefinition类属于com.indeed.proctor.common.model包,在下文中一共展示了ConsumableTestDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: proctorMatrixDefinition

import com.indeed.proctor.common.model.ConsumableTestDefinition; //导入依赖的package包/类
/**
 * Returns the test definition for a specific test in JSON format.
 */
@RequestMapping(value="/proctor/matrix/definition/{testName}", method=RequestMethod.GET)
public JsonResponseView proctorMatrixDefinition(
        final Model model,
        @PathVariable String testName) {

    final Proctor proctor = tryLoadProctor();

    final ConsumableTestDefinition testDef = proctor.getTestDefinition(testName);
    if (testDef == null) {
        throw new NotFoundException(String.format("'%s' test definition not found in test matrix.", testName));
    }

    model.addAttribute(new JsonResponse<ConsumableTestDefinition>(testDef, new JsonMeta(HttpStatus.OK.value())));
    return new JsonResponseView();
}
 
开发者ID:indeedeng,项目名称:proctor-pipet,代码行数:19,代码来源:RestController.java

示例2: generateArtifact

import com.indeed.proctor.common.model.ConsumableTestDefinition; //导入依赖的package包/类
static void generateArtifact(final ProctorReader proctorPersister, final Writer outputSink,
                                       final String authorOverride, final String versionOverride
) throws IOException, IncompatibleTestMatrixException, StoreException {
    final TestMatrixVersion currentTestMatrix = proctorPersister.getCurrentTestMatrix();
    if(currentTestMatrix == null) {
        throw new RuntimeException("Failed to load current test matrix for " + proctorPersister);
    }

    // I'm not sure if it's better for the LocalDirectoryPersister to be aware of this svn info, or for all the overrides to happen here.
    if(!CharMatcher.WHITESPACE.matchesAllOf(Strings.nullToEmpty(authorOverride))) {
        currentTestMatrix.setAuthor(authorOverride);
    }
    if(!Strings.isNullOrEmpty(versionOverride)) {
        currentTestMatrix.setVersion(versionOverride);
    }

    final TestMatrixArtifact artifact = ProctorUtils.convertToConsumableArtifact(currentTestMatrix);

    // For each test, verify that it's internally consistent (buckets sum to 1.0, final null allocation)
    final String matrixSource = artifact.getAudit().getUpdatedBy() + "@" + artifact.getAudit().getVersion();
    for(final Map.Entry<String, ConsumableTestDefinition> td : artifact.getTests().entrySet()) {
        ProctorUtils.verifyInternallyConsistentDefinition(td.getKey(), matrixSource, td.getValue());
    }

    ProctorUtils.serializeArtifact(outputSink, artifact);
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:27,代码来源:ProctorBuilderUtils.java

示例3: convertToConsumableArtifact

import com.indeed.proctor.common.model.ConsumableTestDefinition; //导入依赖的package包/类
@Nonnull
public static TestMatrixArtifact convertToConsumableArtifact(@Nonnull final TestMatrixVersion testMatrix) {
    final Audit audit = new Audit();
    final Date published = Preconditions.checkNotNull(testMatrix.getPublished(), "Missing publication date");
    audit.setUpdated(published.getTime());
    audit.setVersion(testMatrix.getVersion());
    audit.setUpdatedBy(testMatrix.getAuthor());

    final TestMatrixArtifact artifact = new TestMatrixArtifact();
    artifact.setAudit(audit);

    final TestMatrixDefinition testMatrixDefinition = Preconditions.checkNotNull(testMatrix.getTestMatrixDefinition(), "Missing test matrix definition");

    final Map<String, TestDefinition> testDefinitions = testMatrixDefinition.getTests();

    final Map<String, ConsumableTestDefinition> consumableTestDefinitions = Maps.newLinkedHashMap();
    for (final Entry<String, TestDefinition> entry : testDefinitions.entrySet()) {
        final TestDefinition td = entry.getValue();
        final ConsumableTestDefinition ctd = convertToConsumableTestDefinition(td);
        consumableTestDefinitions.put(entry.getKey(), ctd);
    }

    artifact.setTests(consumableTestDefinitions);
    return artifact;
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:26,代码来源:ProctorUtils.java

示例4: verifyAndConsolidate

import com.indeed.proctor.common.model.ConsumableTestDefinition; //导入依赖的package包/类
public static ProctorLoadResult verifyAndConsolidate(@Nonnull final TestMatrixArtifact testMatrix, final String matrixSource, @Nonnull final Map<String, TestSpecification> requiredTests, @Nonnull final FunctionMapper functionMapper, final ProvidedContext providedContext) {
    final ProctorLoadResult result = verify(testMatrix, matrixSource, requiredTests, functionMapper, providedContext);

    final Map<String, ConsumableTestDefinition> definedTests = testMatrix.getTests();
    // Remove any invalid tests so that any required ones will be replaced with default values during the
    // consolidation below (just like missing tests). Any non-required tests can safely be ignored.
    for (final String invalidTest: result.getTestsWithErrors()) {
        // TODO - mjs - gross that this depends on the mutability of the returned map, but then so does the
        //  consolidate method below.
        definedTests.remove(invalidTest);
    }

    consolidate(testMatrix, requiredTests);

    return result;
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:17,代码来源:ProctorUtils.java

示例5: verifyWithoutSpecification

import com.indeed.proctor.common.model.ConsumableTestDefinition; //导入依赖的package包/类
/**
 * Verifies that the TestMatrix is correct and sane without using a specification.
 * The Proctor API doesn't use a test specification so that it can serve all tests in the matrix
 * without restriction.
 * Does a limited set of sanity checks that are applicable when there is no specification,
 * and thus no required tests or provided context.
 *
 * @param testMatrix   the {@link TestMatrixArtifact} to be verified.
 * @param matrixSource a {@link String} of the source of proctor artifact. For example a path of proctor artifact file.
 * @return a {@link ProctorLoadResult} to describe the result of verification. It contains errors of verification and a list of missing test.
 */
public static ProctorLoadResult verifyWithoutSpecification(@Nonnull final TestMatrixArtifact testMatrix,
                                                           final String matrixSource) {
    final ProctorLoadResult.Builder resultBuilder = ProctorLoadResult.newBuilder();

    for (final Entry<String, ConsumableTestDefinition> entry : testMatrix.getTests().entrySet()) {
        final String testName = entry.getKey();
        final ConsumableTestDefinition testDefinition = entry.getValue();

        try {
            verifyInternallyConsistentDefinition(testName, matrixSource, testDefinition);
        } catch (IncompatibleTestMatrixException e) {
            LOGGER.info(String.format("Unable to load test matrix for %s", testName), e);
            resultBuilder.recordError(testName, e);
        }
    }
    return resultBuilder.build();
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:29,代码来源:ProctorUtils.java

示例6: defaultFor

import com.indeed.proctor.common.model.ConsumableTestDefinition; //导入依赖的package包/类
@Nonnull
private static ConsumableTestDefinition defaultFor(final String testName, @Nonnull final TestSpecification testSpecification) {
    final String missingTestSoleBucketName = "inactive";
    final String missingTestSoleBucketDescription = "inactive";
    final Allocation allocation = new Allocation();
    allocation.setRanges(ImmutableList.of(new Range(testSpecification.getFallbackValue(), 1.0)));

    return new ConsumableTestDefinition(
            "default",
            null,
            TestType.RANDOM,
            testName,
            ImmutableList.of(new TestBucket(
                    missingTestSoleBucketName,
                    testSpecification.getFallbackValue(),
                    missingTestSoleBucketDescription)),
            // Force a nonnull allocation just in case something somewhere assumes 1.0 total allocation
            Collections.singletonList(allocation),
            Collections.<String, Object>emptyMap(),
            testName);
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:22,代码来源:ProctorUtils.java

示例7: construct

import com.indeed.proctor.common.model.ConsumableTestDefinition; //导入依赖的package包/类
/**
 * Factory method to do the setup and transformation of inputs
 *
 * @param matrix a {@link TestMatrixArtifact} loaded by ProctorLoader
 * @param loadResult a {@link ProctorLoadResult} which contains result of validation of test definition
 * @param functionMapper a given el {@link FunctionMapper}
 * @return constructed Proctor object
 */
@Nonnull
public static Proctor construct(@Nonnull final TestMatrixArtifact matrix, ProctorLoadResult loadResult, FunctionMapper functionMapper) {
    final ExpressionFactory expressionFactory = RuleEvaluator.EXPRESSION_FACTORY;

    final Map<String, TestChooser<?>> testChoosers = Maps.newLinkedHashMap();
    final Map<String, String> versions = Maps.newLinkedHashMap();

    for (final Entry<String, ConsumableTestDefinition> entry : matrix.getTests().entrySet()) {
        final String testName = entry.getKey();
        final ConsumableTestDefinition testDefinition = entry.getValue();
        final TestType testType = testDefinition.getTestType();
        final TestChooser<?> testChooser;
        if (TestType.RANDOM.equals(testType)) {
            testChooser = new RandomTestChooser(expressionFactory, functionMapper, testName, testDefinition);
        } else {
            testChooser = new StandardTestChooser(expressionFactory, functionMapper, testName, testDefinition);
        }
        testChoosers.put(testName, testChooser);
        versions.put(testName, testDefinition.getVersion());
    }

    return new Proctor(matrix, loadResult, testChoosers);
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:32,代码来源:Proctor.java

示例8: StandardTestChooser

import com.indeed.proctor.common.model.ConsumableTestDefinition; //导入依赖的package包/类
@VisibleForTesting
StandardTestChooser(@Nonnull final TestRangeSelector selector) {
    this.testRangeSelector = selector;
    this.hasher = newHasherFor(selector);

    final ConsumableTestDefinition testDefinition = selector.getTestDefinition();

    final Map<Integer, TestBucket> bucketValueToTest = Maps.newHashMap();
    for (final TestBucket testBucket : testDefinition.getBuckets()) {
        bucketValueToTest.put(testBucket.getValue(), testBucket);
    }

    final List<Allocation> allocations = testDefinition.getAllocations();
    this.cutoffs = new int[allocations.size()][];
    for (int i = 0; i < allocations.size(); i++) {
        final Allocation allocation = allocations.get(i);
        final List<Range> ranges = allocation.getRanges();
        cutoffs[i] = constructCutoffArray(allocation.getRule(), ranges);
    }
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:21,代码来源:StandardTestChooser.java

示例9: testELValidity_inProctorBuilderAllocationRules

import com.indeed.proctor.common.model.ConsumableTestDefinition; //导入依赖的package包/类
@Test
public void testELValidity_inProctorBuilderAllocationRules() throws IncompatibleTestMatrixException {

    //testing invalid allocation rule
    final List<TestBucket> buckets = fromCompactBucketFormat("inactive:-1,control:0,test:1");
    final ConsumableTestDefinition testDefInVal = constructDefinition(buckets,
            fromCompactAllocationFormat("${b4t#+=}|-1:0.5,0:0.5,1:0.0", "-1:0.25,0:0.5,1:0.25")); // invalid EL, nonsense rule
    try {
        ProctorUtils.verifyInternallyConsistentDefinition("testELevalInval", "test el recognition - inval", testDefInVal);
        fail("expected IncompatibleTestMatrixException");
    } catch (IncompatibleTestMatrixException e) {
        //expected
    }

    //testing valid functions pass with proctor included functions (will throw exception if can't find) and backwards compatibility
    final ConsumableTestDefinition testDefVal1 = constructDefinition(buckets,
            fromCompactAllocationFormat("${proctor:now()==indeed:now()}|-1:0.5,0:0.5,1:0.0", "-1:0.25,0:0.5,1:0.25"));
    ProctorUtils.verifyInternallyConsistentDefinition("testELevalProctor", "test el recognition", testDefVal1);

}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:21,代码来源:TestProctorUtils.java

示例10: testELValidity_inProctorBuilderTestRule

import com.indeed.proctor.common.model.ConsumableTestDefinition; //导入依赖的package包/类
@Test
public void testELValidity_inProctorBuilderTestRule() throws IncompatibleTestMatrixException {
    //Testing syntax validation with a test rule
    final List<TestBucket> buckets = fromCompactBucketFormat("inactive:-1,control:0,test:1");
    final ConsumableTestDefinition testDefInValTestRule = constructDefinition(buckets,
            fromCompactAllocationFormat("${proctor:now()>-1}|-1:0.5,0:0.5,1:0.0", "-1:0.25,0:0.5,1:0.25"));
    testDefInValTestRule.setRule("${b4t#+=}");
    try {
        ProctorUtils.verifyInternallyConsistentDefinition("testELevalInValTestRule", "test el recognition - inval test rule", testDefInValTestRule);
        fail("expected IncompatibleTestMatrixException");
    } catch (IncompatibleTestMatrixException e) {
        //expected
    }

    //testing the test rule el function recognition
    final ConsumableTestDefinition testDefValTestRule = constructDefinition(buckets,
            fromCompactAllocationFormat("${true}|-1:0.5,0:0.5,1:0.0", "-1:0.25,0:0.5,1:0.25"));
    testDefValTestRule.setRule("${proctor:now()==indeed:now()}");
    ProctorUtils.verifyInternallyConsistentDefinition("testELevalValTestRule", "test el recognition - val test rule and functions", testDefValTestRule);


}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:23,代码来源:TestProctorUtils.java

示例11: noBucketsSpecified

import com.indeed.proctor.common.model.ConsumableTestDefinition; //导入依赖的package包/类
@Test
public void noBucketsSpecified() throws IncompatibleTestMatrixException {
    // The test-matrix has 3 buckets
    List<TestBucket> buckets = fromCompactBucketFormat("zero:0,one:1,two:2");
    // The proctor-specification does not specify any buckets
    final TestSpecification testSpecification = transformTestBuckets(Collections.<TestBucket>emptyList());
    Map<String, TestSpecification> requiredTests = ImmutableMap.of(TEST_A, testSpecification);

    {
        final Map<String, ConsumableTestDefinition> tests = Maps.newHashMap();
        // Allocation of bucketValue=2 is > 0
        final ConsumableTestDefinition testDefinition = constructDefinition(buckets, fromCompactAllocationFormat("0:0,1:0,2:1.0"));
        tests.put(TEST_A, testDefinition);

        final TestMatrixArtifact matrix = constructArtifact(tests);

        assertValid("allocation for externally unknown bucket (two) > 0 when no buckets are specified", matrix, requiredTests);
    }
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:20,代码来源:TestProctorUtils.java

示例12: requiredTestBucketsMissing

import com.indeed.proctor.common.model.ConsumableTestDefinition; //导入依赖的package包/类
@Test
public void requiredTestBucketsMissing() throws IncompatibleTestMatrixException {
     // The test-matrix has fewer buckets than the required tests
    List<TestBucket> buckets_matrix = fromCompactBucketFormat("zero:0,one:1");
    List<TestBucket> buckets_required = fromCompactBucketFormat("zero:0,one:1,two:2,three:3");
    Map<String, TestSpecification> requiredTests = ImmutableMap.of(TEST_A, transformTestBuckets(buckets_required));

    {
        final Map<String, ConsumableTestDefinition> tests = Maps.newHashMap();
        tests.put(TEST_A, constructDefinition(buckets_matrix, fromCompactAllocationFormat("0:0,1:1.0")));

        final TestMatrixArtifact matrix = constructArtifact(tests);

        // internally inconsistent matrix
        assertValid("test-matrix has a subset of required buckets", matrix, requiredTests);
    }
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:18,代码来源:TestProctorUtils.java

示例13: setupMocks

import com.indeed.proctor.common.model.ConsumableTestDefinition; //导入依赖的package包/类
@Before
public void setupMocks() throws Exception {
    expressionFactory = new ExpressionFactoryImpl();
    functionMapper = RuleEvaluator.FUNCTION_MAPPER;
    testName = "testName";
    testDefinition = new ConsumableTestDefinition();
    testDefinition.setConstants(Collections.<String, Object>emptyMap());
    testDefinition.setTestType(TestType.AUTHENTICATED_USER);
    // most tests just set the salt to be the same as the test name
    testDefinition.setSalt(testName);
    testDefinition.setBuckets(INACTIVE_CONTROL_TEST_BUCKETS);

    updateAllocations(RANGES_50_50);

    final int effBuckets = INACTIVE_CONTROL_TEST_BUCKETS.size() - 1;
    counts = new int[effBuckets];
    hashes = new int[effBuckets];
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:19,代码来源:TestStandardTestChooser.java

示例14: createThreeFakeTests

import com.indeed.proctor.common.model.ConsumableTestDefinition; //导入依赖的package包/类
private TestMatrixArtifact createThreeFakeTests()
{
    final TestMatrixArtifact matrix = new TestMatrixArtifact();
    final Map<String, ConsumableTestDefinition> testMap = Maps.newHashMap();
    testMap.put("one", new ConsumableTestDefinition());
    testMap.put("two", new ConsumableTestDefinition());
    testMap.put("three", new ConsumableTestDefinition());

    // For appendTests to work, the testType property must not be null.
    testMap.get("one").setTestType(TestType.RANDOM);
    testMap.get("two").setTestType(TestType.RANDOM);
    testMap.get("three").setTestType(TestType.RANDOM);

    matrix.setTests(testMap);
    return matrix;
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:17,代码来源:TestProctor.java

示例15: initializeRandomTestChooser

import com.indeed.proctor.common.model.ConsumableTestDefinition; //导入依赖的package包/类
static RandomTestChooser initializeRandomTestChooser(final List<Range> ranges, final List<TestBucket> buckets) {
    final ExpressionFactory expressionFactory = new ExpressionFactoryImpl();

    final FunctionMapper functionMapper = RuleEvaluator.FUNCTION_MAPPER;

    final ConsumableTestDefinition testDefinition = new ConsumableTestDefinition();
    testDefinition.setConstants(Collections.<String, Object>emptyMap());

    testDefinition.setBuckets(buckets);

    final List<Allocation> allocations = Lists.newArrayList();
    allocations.add(new Allocation("${}", ranges));
    testDefinition.setAllocations(allocations);

    final RandomTestChooser rtc = new RandomTestChooser(expressionFactory, functionMapper, "testName", testDefinition);
    return rtc;
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:18,代码来源:TestRandomTestChooser.java


注:本文中的com.indeed.proctor.common.model.ConsumableTestDefinition类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。