Examples of TestMatrixArtifact


Examples of com.indeed.proctor.common.model.TestMatrixArtifact

        return true;
    }

    @Nullable
    public Proctor doLoad() throws IOException, MissingTestMatrixException {
        final TestMatrixArtifact testMatrix = loadTestMatrix();
        if (testMatrix == null) {
            throw new MissingTestMatrixException("Failed to load Test Matrix from " + getSource());
        }

        final ProctorLoadResult loadResult;
        if (requiredTests == null) {
            // Probably an absent specification.
            loadResult = ProctorUtils.verifyWithoutSpecification(testMatrix, getSource(), functionMapper, providedContext);
        } else {
            loadResult = ProctorUtils.verifyAndConsolidate(testMatrix, getSource(), requiredTests, functionMapper, providedContext);
        }

        final Audit newAudit = testMatrix.getAudit();
        if (lastAudit != null) {
            final Audit audit = Preconditions.checkNotNull(newAudit, "Missing audit");
            if(lastAudit.getVersion().equals(audit.getVersion())) {
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("Not reloading " + getSource() + " test matrix definition because audit is unchanged: " + lastAudit.getVersion() + " @ " + lastAudit.getUpdated() + " by " + lastAudit.getUpdatedBy());
View Full Code Here

Examples of com.indeed.proctor.common.model.TestMatrixArtifact

        final Audit audit = new Audit();
        audit.setUpdated(0);
        audit.setUpdatedBy("nobody");
        audit.setVersion(Audit.EMPTY_VERSION);

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

        final ProctorLoadResult loadResult = ProctorLoadResult.emptyResult();

        final Map<String, TestChooser<?>> choosers = Collections.emptyMap();
View Full Code Here

Examples of com.indeed.proctor.common.model.TestMatrixArtifact

    }

    public void appendTestMatrixFiltered(final Writer writer, final Collection<String> testNameFilter) throws IOException {
        // Create new matrix object copied from the old one,
        // but keep only the tests with names in testNameFilter.
        final TestMatrixArtifact filtered = new TestMatrixArtifact();
        filtered.setAudit(this.matrix.getAudit());
        filtered.setTests(Maps.filterKeys(this.matrix.getTests(), Predicates.in(testNameFilter)));
        ProctorUtils.serializeArtifact(writer, filtered);
    }
View Full Code Here

Examples of com.indeed.proctor.common.model.TestMatrixArtifact

            }
        }
        reader.close();
        final String newContents = sb.toString();
        try {
            final TestMatrixArtifact testMatrix = objectMapper.readValue(newContents, TestMatrixArtifact.class);
            if (testMatrix != null) {
                //  record the file contents AFTER successfully loading the matrix
                fileContents = newContents;
            }
            return testMatrix;
View Full Code Here

Examples of com.indeed.proctor.common.model.TestMatrixArtifact

        }
        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);
    }
View Full Code Here

Examples of com.indeed.proctor.common.model.TestMatrixArtifact

    }

    @SuppressWarnings("UnusedDeclaration") // TODO Remove?
    public static String convertToArtifact(@Nonnull final TestMatrixVersion testMatrix) throws IOException {
        final StringWriter sw = new StringWriter();
        final TestMatrixArtifact artifact = convertToConsumableArtifact(testMatrix);
        serializeArtifact(sw, artifact);
        return sw.toString();
    }
View Full Code Here

Examples of com.indeed.proctor.common.model.TestMatrixArtifact

        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;
    }
View Full Code Here

Examples of com.indeed.proctor.common.model.TestMatrixArtifact

        assertEquals("abc0,def0",   calcGroups(proctor, "aksdh8947jh4807", "IO", "pt", 4));
        assertEquals("abc0,def0",   calcGroups(proctor, "aksdh8947jh4807", "UY", "pt", 4));
    }

    private Proctor constructProctor() {
        final TestMatrixArtifact matrix = new TestMatrixArtifact();

        final Audit audit = new Audit();
        audit.setUpdated(0);
        audit.setUpdatedBy("nobody");
        audit.setVersion(Audit.EMPTY_VERSION);

        matrix.setAudit(audit);

        final TestBucket abcBucket0 = new TestBucket("always", 0, "always description", null);
        final List<TestBucket> abcBuckets = Lists.newArrayList(abcBucket0);
        final Map<String, Object> abcTestConstants = Maps.newHashMap();
        abcTestConstants.put("ANOTHER_NUM", Integer.valueOf(5));
        abcTestConstants.put("SOME_NUM", Integer.valueOf(1));

        final List<Allocation> abcAllocations = Collections.singletonList(new Allocation(null, Arrays.asList(new Range[] { new Range(abcBucket0.getValue(), 1) })));

        /**
final int id, final int version, final String rule, final TestType testType, final String salt, final List<TestBucket> buckets, final List<RuleRatio> ratios,
final Map<String, Object> constants, final String description) {

         */
        final ConsumableTestDefinition abcTD = new ConsumableTestDefinition("1", "${num > SOME_NUM && num < ANOTHER_NUM}", TestType.ANONYMOUS_USER, "abcsalt", abcBuckets, abcAllocations, abcTestConstants, "zingle boppity zip zop");

        final TestBucket defBucket0 = new TestBucket("control", 0, "control description", null);
        final TestBucket defBucket1 = new TestBucket("test1", 1, "test1 description", null);
        final TestBucket defBucket2 = new TestBucket("test2", 2, "test2 description", null);
        final List<TestBucket> defBuckets = Lists.newArrayList(defBucket0, defBucket1, defBucket2);
        final Map<String, Object> defTestConstants = Maps.newHashMap();
        defTestConstants.put("T", Boolean.TRUE);
        defTestConstants.put("COUNTRIES", Sets.newHashSet("AE", "IO", "UY"));
        final List<Allocation> defAllocations = Collections.singletonList(new Allocation(null, Arrays.asList(new Range[] {
                new Range(defBucket0.getValue(), 1/3f),
                new Range(defBucket1.getValue(), 1/3f),
                new Range(defBucket2.getValue(), 1/3f),
        })));
        final ConsumableTestDefinition defTD = new ConsumableTestDefinition("2", "${proctor:contains(COUNTRIES, country) && T}", TestType.ANONYMOUS_USER, "defsalt", defBuckets, defAllocations, defTestConstants, "finkle fangle foop");

        final TestBucket ghiBucket0 = new TestBucket("inactive", -1, "inactive description", null);
        final TestBucket ghiBucket1 = new TestBucket("control", 0, "control desc", null);
        final TestBucket ghiBucket2 = new TestBucket("optionA", 1, "option A desc", null);
        final TestBucket ghiBucket3 = new TestBucket("optionB", 2, "option B desc", null);
        final TestBucket ghiBucket4 = new TestBucket("optionC", 3, "option C desc", null);
        final List<TestBucket> ghiBuckets = Lists.newArrayList(ghiBucket0, ghiBucket1, ghiBucket2, ghiBucket3, ghiBucket4);
        final Map<String, Object> ghiTestConstants = Maps.newHashMap();
        ghiTestConstants.put("LANGUAGES", Sets.newHashSet("es", "fr", "pt", "nl"));
        ghiTestConstants.put("COUNTRIES", Sets.newHashSet("AE", "IO", "UY"));
        final List<Allocation> ghiAllocations = Collections.singletonList(new Allocation(null,
                Arrays.asList(new Range[] {
                        new Range(ghiBucket0.getValue(), 0.2),
                        new Range(ghiBucket1.getValue(), 0.2),
                        new Range(ghiBucket2.getValue(), 0.2),
                        new Range(ghiBucket3.getValue(), 0.2),
                        new Range(ghiBucket4.getValue(), 0.2),
                })));
        final ConsumableTestDefinition ghiTD = new ConsumableTestDefinition("3", "${proctor:contains(LANGUAGES, language)}", TestType.ANONYMOUS_USER, "ghisalt", ghiBuckets, ghiAllocations, ghiTestConstants, "jangle bing zimple plop");
        final Map<String, ConsumableTestDefinition> tests = Maps.newLinkedHashMap();
        tests.put("abc", abcTD);
        tests.put("def", defTD);
        tests.put("ghi", ghiTD);

        matrix.setTests(tests);

        return Proctor.construct(matrix, ProctorLoadResult.emptyResult(), RuleEvaluator.defaultFunctionMapperBuilder().build());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.