/** * Prepares the target exporter's output using the specified source. * @param modelClass class of data model * @param description target importer * @param source test data * @throws IOException if failed to prepare the importer * @throws IllegalArgumentException if some parameters were {@code null} */ public void prepare( Class<?> modelClass, ExporterDescription description, DataModelSourceFactory source) throws IOException { if (modelClass == null) { throw new IllegalArgumentException("modelClass must not be null"); //$NON-NLS-1$ } if (description == null) { throw new IllegalArgumentException("description must not be null"); //$NON-NLS-1$ } if (source == null) { throw new IllegalArgumentException("source must not be null"); //$NON-NLS-1$ } DataModelDefinition<?> definition = repository.toDataModelDefinition(modelClass); prepare(definition, description, source); }
/** * Prepares jobflow input. * @param description the importer description * @param source the data model source * @throws IOException if failed to prepare the input */ public void prepare(ImporterDescription description, DataModelSourceFactory source) throws IOException { TestModerator moderator = new TestModerator(getTestTools(), this); moderator.prepare(description.getModelType(), description, source); }
private <T> void prepare( DataModelDefinition<T> definition, ImporterDescription description, DataModelSourceFactory source) throws IOException { assert definition != null; assert description != null; assert source != null; ModelOutput< T> output = getDriver(description).createOutput(definition, description, context); prepare(definition, output, source); }
/** * Collects jobflow output. * @param description the exporter description * @param sink the output sink * @throws IOException if failed to collect the output * @since 0.9.1 */ public void collect(ExporterDescription description, DataModelSinkFactory sink) throws IOException { TestModerator moderator = new TestModerator(getTestTools(), this); moderator.save(description.getModelType(), description, sink); }
/** * Truncates jobflow output. * @param description the target exporter description * @throws IOException if failed to truncate the output */ public void truncate(ExporterDescription description) throws IOException { LOG.info(MessageFormat.format( Messages.getString("BatchTestTool.infoCleaningOutput"), //$NON-NLS-1$ description.getClass().getName())); TestModerator moderator = new TestModerator(getTestTools(), this); moderator.truncate(description); }
private void validateTestCondition() throws IOException { TestModerator moderator = new TestModerator(driverContext.getRepository(), driverContext); for (Map.Entry<? extends ImporterDescription, ? extends DataModelSourceFactory> entry : getExternalResources().entrySet()) { ImporterDescription description = entry.getKey(); String label = String.format("Resource(%s)", description); //$NON-NLS-1$ DataModelSourceFactory source = entry.getValue(); moderator.validate(entry.getKey().getModelType(), label, source); } for (Map.Entry<String, JobFlowTester> entry : jobflowMap.entrySet()) { validateTestCondition(entry.getValue(), entry.getKey()); } }
/** * Verifies jobflow output. * @param description the exporter description * @param verifier the verifier * @return verify differences * @throws IOException if failed to verify the output */ public List<Difference> verify(ExporterDescription description, VerifierFactory verifier) throws IOException { TestModerator moderator = new TestModerator(getTestTools(), this); return moderator.inspect( description.getModelType(), description, new VerifyContext(this), verifier); }
moderator.save(port.getDataType(), port.getDescription(), output.getResultSink()); List<Difference> diffList = moderator.inspect( port.getDataType(), port.getDescription(), LOG.debug("saving output differences: {} ({})", //$NON-NLS-1$ name, output.getDifferenceSink()); moderator.save(port.getDataType(), diffList, output.getDifferenceSink());
/** * Inspects the target exporter's output using specified expected data and rule. * @param modelClass class of data model * @param description target exporter * @param verifyContext current verification context * @param verifier verifier factory * @return detected invalid differences * @throws IOException if failed to inspect the result * @throws IllegalArgumentException if some parameters were {@code null} */ public List<Difference> inspect( Class<?> modelClass, ExporterDescription description, VerifyContext verifyContext, VerifierFactory verifier) throws IOException { if (modelClass == null) { throw new IllegalArgumentException("modelClass must not be null"); //$NON-NLS-1$ } if (description == null) { throw new IllegalArgumentException("description must not be null"); //$NON-NLS-1$ } if (verifyContext == null) { throw new IllegalArgumentException("verifyContext must not be null"); //$NON-NLS-1$ } if (verifier == null) { throw new IllegalArgumentException("verifier must not be null"); //$NON-NLS-1$ } DataModelDefinition<?> definition = repository.toDataModelDefinition(modelClass); return inspect(definition, description, verifyContext, verifier); }
/** * Truncates the target importer's input. * @param description target importer * @throws IOException if failed to prepare the importer * @throws IllegalArgumentException if some parameters were {@code null} */ public void truncate(ImporterDescription description) throws IOException { if (description == null) { throw new IllegalArgumentException("description must not be null"); //$NON-NLS-1$ } getDriver(description).truncate(description, context); }
/** * Cleans up extra resources. * @param resources the external resource map * @throws IOException if failed to create job processes * @throws IllegalArgumentException if some parameters were {@code null} * @since 0.7.3 */ public void cleanExtraResources( Map<? extends ImporterDescription, ? extends DataModelSourceFactory> resources) throws IOException { if (resources == null) { throw new IllegalArgumentException("resources must not be null"); //$NON-NLS-1$ } if (driverContext.isSkipCleanInput() == false) { for (ImporterDescription description : resources.keySet()) { LOG.debug("cleaning external resource: {}", description); //$NON-NLS-1$ moderator.truncate(description); } } else { LOG.info(Messages.getString("JobflowExecutor.infoSkipInitializeExtraResources")); //$NON-NLS-1$ } }
/** * Creates a new instance. * @param context submission context * @throws IllegalArgumentException if some parameters were {@code null} */ JobflowExecutor(TestDriverContext context) { if (context == null) { throw new IllegalArgumentException("context must not be null"); //$NON-NLS-1$ } this.driverContext = context; this.moderator = new TestModerator(context.getRepository(), context); this.taskExecutors = new ArrayList<>(); taskExecutors.addAll(TaskExecutors.loadDefaults(context.getClassLoader())); taskExecutors.add(new DefaultHadoopTaskExecutor()); taskExecutors.add(new DefaultCommandTaskExecutor()); taskExecutors.add(new DefaultDeleteTaskExecutor()); this.configurations = ConfigurationFactory.getDefault(); }
private void validateTestCondition() throws IOException { TestModerator moderator = new TestModerator(driverContext.getRepository(), driverContext); for (Map.Entry<? extends ImporterDescription, ? extends DataModelSourceFactory> entry : getExternalResources().entrySet()) { String label = String.format("Resource(%s)", description); //$NON-NLS-1$ DataModelSourceFactory source = entry.getValue(); moderator.validate(entry.getKey().getModelType(), label, source); DataModelSourceFactory source = port.getSource(); if (source != null) { moderator.validate(type, label, source); DataModelSourceFactory source = port.getSource(); if (source != null) { moderator.validate(type, label, source); moderator.validate(type, label, verifier);
/** * Truncates jobflow input. * @param description the target importer description * @throws IOException if failed to truncate the input */ public void truncate(ImporterDescription description) throws IOException { LOG.info(MessageFormat.format( Messages.getString("BatchTestTool.infoCleaningInput"), //$NON-NLS-1$ description.getClass().getName())); TestModerator moderator = new TestModerator(getTestTools(), this); moderator.truncate(description); }
/** * Truncates the target exporter's output. * @param description target importer * @throws IOException if failed to prepare the importer * @throws IllegalArgumentException if some parameters were {@code null} */ public void truncate(ExporterDescription description) throws IOException { if (description == null) { throw new IllegalArgumentException("description must not be null"); //$NON-NLS-1$ } getDriver(description).truncate(description, context); }
/** * Cleans up target jobflow's input/output. * @param flow target jobflow * @throws IOException if failed to clean up * @throws IllegalArgumentException if some parameters were {@code null} * @since 0.8.0 */ public void cleanInputOutput(JobflowMirror flow) throws IOException { if (flow == null) { throw new IllegalArgumentException("info must not be null"); //$NON-NLS-1$ } if (driverContext.isSkipCleanInput() == false) { for (PortMirror<? extends ImporterDescription> port : flow.getInputs()) { LOG.debug("cleaning input: {}", port.getName()); //$NON-NLS-1$ moderator.truncate(port.getDescription()); } } else { LOG.info(Messages.getString("JobflowExecutor.infoSkipInitializeInput")); //$NON-NLS-1$ } if (driverContext.isSkipCleanOutput() == false) { for (PortMirror<? extends ExporterDescription> port : flow.getOutputs()) { LOG.debug("cleaning output: {}", port.getName()); //$NON-NLS-1$ moderator.truncate(port.getDescription()); } } else { LOG.info(Messages.getString("JobflowExecutor.infoSkipInitializeOutput")); //$NON-NLS-1$ } }
/** * Prepares the target importer's input using the specified source. * @param modelClass class of data model * @param description target importer * @param source test data * @throws IOException if failed to prepare the importer * @throws IllegalArgumentException if some parameters were {@code null} */ public void prepare( Class<?> modelClass, ImporterDescription description, DataModelSourceFactory source) throws IOException { if (modelClass == null) { throw new IllegalArgumentException("modelClass must not be null"); //$NON-NLS-1$ } if (description == null) { throw new IllegalArgumentException("description must not be null"); //$NON-NLS-1$ } if (source == null) { throw new IllegalArgumentException("source must not be null"); //$NON-NLS-1$ } DataModelDefinition<?> definition = repository.toDataModelDefinition(modelClass); prepare(definition, description, source); }
private <T> void prepare( DataModelDefinition<T> definition, ExporterDescription desctipion, DataModelSourceFactory source) throws IOException { assert definition != null; assert desctipion != null; assert source != null; ModelOutput<T> output = getDriver(desctipion).createOutput(definition, desctipion, context); prepare(definition, output, source); }
private void validateTestCondition(JobFlowTester flow, String id) throws IOException { TestModerator moderator = new TestModerator(driverContext.getRepository(), driverContext); for (DriverInputBase<?> port : flow.inputs) { String label = String.format("Input(flow=%s, name=%s)", id, port.getName()); //$NON-NLS-1$ Class<?> type = port.getModelType(); DataModelSourceFactory source = port.getSource(); if (source != null) { moderator.validate(type, label, source); } } for (DriverOutputBase<?> port : flow.outputs) { String label = String.format("Output(flow=%s, name=%s)", id, port.getName()); //$NON-NLS-1$ Class<?> type = port.getModelType(); DataModelSourceFactory source = port.getSource(); if (source != null) { moderator.validate(type, label, source); } VerifierFactory verifier = port.getVerifier(); if (verifier != null) { moderator.validate(type, label, verifier); } } } }
private <T> List<Difference> inspect( DataModelDefinition<T> definition, ExporterDescription description, VerifyContext verifyContext, VerifierFactory verifier) throws IOException { assert definition != null; assert description != null; assert verifier != null; List<Difference> results; try (DataModelSource target = getDriver(description).createSource(definition, description, context); Verifier engine = verifier.createVerifier(definition, verifyContext)) { results = engine.verify(target); } Collections.sort(results, new DifferenceComparator(definition)); return results; }