public class ServiceTestRunner
extends java.lang.Object
SimulationTick
s against the result.Constructor and Description |
---|
ServiceTestRunner()
Creates a new instance against the default
svc.yml Service Specification YAML file. |
ServiceTestRunner(java.io.File specPath)
Creates a new instance against the provided Service Specification YAML path.
|
ServiceTestRunner(java.lang.String specDistFilename)
Creates a new instance against the provided Service Specification YAML filename within the service's
src/main/dist directory. |
Modifier and Type | Method and Description |
---|---|
static java.io.File |
getDistDir()
Returns a
File object for the service's src/main/dist directory. |
static java.io.File |
getDistFile(java.lang.String specFilePath)
Returns a
File object for a provided filename or relative path within the service's src/main/dist
directory. |
ServiceTestResult |
run()
Exercises the service's packaging and resulting Service Specification YAML file without running any simulation
afterwards.
|
ServiceTestResult |
run(java.util.Collection<SimulationTick> ticks)
Exercises the service's packaging and resulting Service Specification YAML file, then runs the provided
simulation ticks, if any are provided.
|
ServiceTestRunner |
setBuildTemplateParams(java.util.Map<java.lang.String,java.lang.String> paramMap)
Equivalent of
setBuildTemplateParams(String...) for a Map instead of string pairs. |
ServiceTestRunner |
setBuildTemplateParams(java.lang.String... paramKeyVals)
Configures the test with custom template parameters to be applied against the Universe packaging, as would be
provided via
TEMPLATE_X envvars when building the service. |
ServiceTestRunner |
setConfigTemplateDir(java.io.File configTemplateDir)
Configures the test with a custom configuration template location.
|
ServiceTestRunner |
setCustomValidators(ConfigValidator<ServiceSpec>... validators) |
ServiceTestRunner |
setOptions(java.util.Map<java.lang.String,java.lang.String> optionMap)
Equivalent of
setOptions(String...) for a Map instead of string pairs. |
ServiceTestRunner |
setOptions(java.lang.String... optionKeyVals)
Configures the test with custom options as would be provided via an
options.json file. |
ServiceTestRunner |
setPodEnv(java.lang.String podType,
java.util.Map<java.lang.String,java.lang.String> podEnvMap)
Equivalent of
setPodEnv(String, String...) for a Map instead of string pairs. |
ServiceTestRunner |
setPodEnv(java.lang.String podType,
java.lang.String... podEnvKeyVals)
Configures the test with additional environment variables in the specified Pod, beyond those which would be
included by the Scheduler or by Mesos.
|
ServiceTestRunner |
setRecoveryManagerFactory(RecoveryPlanOverriderFactory recoveryManagerFactory)
Allows the specification of custom recovery logic just as in
SchedulerBuilder.setRecoveryManagerFactory(RecoveryPlanOverriderFactory) . |
ServiceTestRunner |
setSchedulerEnv(java.util.Map<java.lang.String,java.lang.String> schedulerEnvMap)
Equivalent of
setSchedulerEnv(String...) for a Map instead of string pairs. |
ServiceTestRunner |
setSchedulerEnv(java.lang.String... schedulerEnvKeyVals)
Configures the test with additional environment variables in the Scheduler beyond those which would be included
by the service's
marathon.json.mustache . |
ServiceTestRunner |
setState(ServiceTestResult serviceTestResult)
Configures the test with the provided state from a prior run.
|
ServiceTestRunner |
setUseCustomExecutor()
Simulates DC/OS 1.9 behavior of using a custom executor instead of the default executor.
|
public ServiceTestRunner()
svc.yml
Service Specification YAML file.
WARNING: If you do not invoke the run()
method, your test will not run!
public ServiceTestRunner(java.lang.String specDistFilename)
src/main/dist
directory.
WARNING: If you do not invoke the run()
method, your test will not run!
specDistFilename
- path to the Service Specification YAML file, relative to the src/main/dist
directorypublic ServiceTestRunner(java.io.File specPath)
WARNING: If you do not invoke the run()
method, your test will not run!
specPath
- path to the Service Specification YAML file, relative to the dist
directorypublic static java.io.File getDistDir()
File
object for the service's src/main/dist
directory. Does not check if the directory
actually exists.public static java.io.File getDistFile(java.lang.String specFilePath)
File
object for a provided filename or relative path within the service's src/main/dist
directory. Does not check if the specified path actually exists.public ServiceTestRunner setOptions(java.util.Map<java.lang.String,java.lang.String> optionMap)
setOptions(String...)
for a Map
instead of string pairs.setOptions(String...)
public ServiceTestRunner setOptions(java.lang.String... optionKeyVals)
options.json
file. If this is not
invoked then the service defaults from config.json
are used for the test.optionKeyVals
- an even number of strings which will be unpacked as (key, value, key, value, ...), where the
keys should be in section1.section2.section3.name
form as an options.json
file would havethis
public ServiceTestRunner setBuildTemplateParams(java.util.Map<java.lang.String,java.lang.String> paramMap)
setBuildTemplateParams(String...)
for a Map
instead of string pairs.setBuildTemplateParams(String...)
public ServiceTestRunner setBuildTemplateParams(java.lang.String... paramKeyVals)
TEMPLATE_X
envvars when building the service. These are applied onto config.json
and resource.json
for the testparamKeyVals
- an even number of strings which will be unpacked as (key, value, key, value, ...)this
public ServiceTestRunner setConfigTemplateDir(java.io.File configTemplateDir)
this
public ServiceTestRunner setState(ServiceTestResult serviceTestResult)
serviceTestResult
- the result from a previous simulation, from which state will be retrievedthis
public ServiceTestRunner setSchedulerEnv(java.util.Map<java.lang.String,java.lang.String> schedulerEnvMap)
setSchedulerEnv(String...)
for a Map
instead of string pairs.setSchedulerEnv(String...)
public ServiceTestRunner setSchedulerEnv(java.lang.String... schedulerEnvKeyVals)
marathon.json.mustache
. This may be useful for tests against custom Service
Specification YAML files which reference envvars that aren't also present in the packaging's Marathon definition.
These values will override any produced by the service's packaging.schedulerEnvKeyVals
- an even number of strings which will be unpacked as (key, value, key, value, ...)this
public ServiceTestRunner setPodEnv(java.lang.String podType, java.util.Map<java.lang.String,java.lang.String> podEnvMap)
setPodEnv(String, String...)
for a Map
instead of string pairs.setPodEnv(String, String...)
public ServiceTestRunner setPodEnv(java.lang.String podType, java.lang.String... podEnvKeyVals)
bootstrap
.podType
- the pod to set the environment againstpodEnvKeyVals
- an even number of strings which will be unpacked as (key, value, key, value, ...)this
public ServiceTestRunner setRecoveryManagerFactory(RecoveryPlanOverriderFactory recoveryManagerFactory)
SchedulerBuilder.setRecoveryManagerFactory(RecoveryPlanOverriderFactory)
.public ServiceTestRunner setCustomValidators(ConfigValidator<ServiceSpec>... validators)
public ServiceTestRunner setUseCustomExecutor()
public ServiceTestResult run() throws java.lang.Exception
ServiceTestResult
containing the resulting scheduler environment and spec informationjava.lang.Exception
- if the test failedpublic ServiceTestResult run(java.util.Collection<SimulationTick> ticks) throws java.lang.Exception
ServiceTestResult
containing the resulting scheduler environment and spec informationjava.lang.Exception
- if the test failed