Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[engine] Align story execution timeout properties naming #3531

Merged
merged 1 commit into from
Jan 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions docs/modules/ROOT/pages/tests-configuration.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ NOTE: The properties marked with *bold* are mandatory.
|`<empty>`
|If set the value overrides global setting `scenario.fail-fast`.

|`batch-<batch-number>.story-execution-timeout`
|`batch-<batch-number>.story.execution-timeout`
|`PT3H`
|The max duration of the single story in the batch.
|The max duration of the single story in the batch in {iso-date-format-link} format. Overrides value specified via `story.execution-timeout`.

|`batch.fail-fast`
|`false`
Expand All @@ -88,6 +88,10 @@ NOTE: The properties marked with *bold* are mandatory.
|`false`
|If set to `true` the scenario execution will be stopped after first failed assertion

|`story.execution-timeout`
|`PT3H`
|The max duration of the single story in {iso-date-format-link} format. Could be overriden via corresponging batch setting.

|`bdd.configuration.dry-run`
|`false`
|Enables dry-run execution mode (no actual steps will be executed, dynamic variables and xref:ROOT:glossary.adoc#_expression[expressions] won't be resolved). For example dry-run could be useful to debug what stroies will be executed with provided config.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 the original author or authors.
* Copyright 2019-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -33,10 +33,9 @@ public class BatchConfiguration
private String name;
private Integer threads;
private List<String> metaFilters;
private Duration storyExecutionTimeout;
private Boolean failFast;
private ScenarioExecutionConfiguration scenario;
private StoryExecutionConfiguration story;
private ScenarioExecutionConfiguration scenario = new ScenarioExecutionConfiguration();
private StoryExecutionConfiguration story = new StoryExecutionConfiguration();
private Map<String, String> variables = Map.of();

public String getResourceLocation()
Expand Down Expand Up @@ -106,12 +105,12 @@ public void setMetaFilters(String metaFilters)

public Duration getStoryExecutionTimeout()
{
return storyExecutionTimeout;
return story.executionTimeout;
}

public void setStoryExecutionTimeout(Duration storyExecutionTimeout)
public void overrideStoryExecutionTimeout(Duration storyExecutionTimeout)
{
this.storyExecutionTimeout = storyExecutionTimeout;
story.executionTimeout = storyExecutionTimeout;
}

public Boolean isFailFast()
Expand All @@ -126,7 +125,7 @@ public void setFailFast(Boolean failFast)

public Boolean isFailScenarioFast()
{
return scenario == null ? null : scenario.failFast;
return scenario.failFast;
}

public void setScenario(ScenarioExecutionConfiguration scenario)
Expand All @@ -136,7 +135,7 @@ public void setScenario(ScenarioExecutionConfiguration scenario)

public Boolean isFailStoryFast()
{
return story == null ? null : story.failFast;
return story.failFast;
}

public void setStory(StoryExecutionConfiguration story)
Expand Down Expand Up @@ -167,19 +166,25 @@ private List<String> convertToList(String list)

private static final class StoryExecutionConfiguration
{
private boolean failFast;
private Boolean failFast;
private Duration executionTimeout;

private void setFailFast(boolean failFast)
private void setFailFast(Boolean failFast)
ikalinin1 marked this conversation as resolved.
Show resolved Hide resolved
{
this.failFast = failFast;
}

private void setExecutionTimeout(Duration executionTimeout)
{
this.executionTimeout = executionTimeout;
}
}

private static final class ScenarioExecutionConfiguration
{
private boolean failFast;
private Boolean failFast;

private void setFailFast(boolean failFast)
private void setFailFast(Boolean failFast)
{
this.failFast = failFast;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 the original author or authors.
* Copyright 2019-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,26 +21,48 @@
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Optional;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.vividus.util.property.IPropertyMapper;

public class BatchStorage
{
private static final Logger LOGGER = LoggerFactory.getLogger(BatchStorage.class);

private static final String BATCH = "batch-";
private static final String DEPRECATION_MESSAGE =
"Property `bdd.story-execution-timeout` is deprecated and will be removed in"
+ " VIVIDUS 0.7.0. Please use `story.execution-timeout` instead.";
private static final Duration DEFAULT_STORY_TIMEOUT = Duration.ofHours(3);

private final Map<String, BatchConfiguration> batchConfigurations;

private final Duration defaultStoryExecutionTimeout;
private final List<String> defaultMetaFilters;
private final boolean failFast;

public BatchStorage(IPropertyMapper propertyMapper, String defaultStoryExecutionTimeout,
List<String> defaultMetaFilters, boolean failFast) throws IOException
public BatchStorage(IPropertyMapper propertyMapper, Duration defaultStoryExecutionTimeout,
String deprecatedDefaultStoryExecutionTimeout, List<String> defaultMetaFilters,
boolean failFast) throws IOException
{
this.defaultMetaFilters = defaultMetaFilters;
this.defaultStoryExecutionTimeout = Duration.ofSeconds(Long.parseLong(defaultStoryExecutionTimeout));
if (null != deprecatedDefaultStoryExecutionTimeout)
{
Validate.isTrue(defaultStoryExecutionTimeout == null,
"Conflicting properties are found: `bdd.story-execution-timeout` and `story.execution-timeout`. "
+ DEPRECATION_MESSAGE);
this.defaultStoryExecutionTimeout =
ikalinin1 marked this conversation as resolved.
Show resolved Hide resolved
Duration.ofSeconds(Long.parseLong(deprecatedDefaultStoryExecutionTimeout));
LOGGER.warn(DEPRECATION_MESSAGE);
}
else
{
this.defaultStoryExecutionTimeout = Optional.ofNullable(defaultStoryExecutionTimeout)
.orElse(DEFAULT_STORY_TIMEOUT);
}
this.failFast = failFast;

batchConfigurations = readFromProperties(propertyMapper, BATCH, BatchConfiguration.class);
Expand All @@ -58,7 +80,7 @@ public BatchStorage(IPropertyMapper propertyMapper, String defaultStoryExecution
}
if (batchConfiguration.getStoryExecutionTimeout() == null)
{
batchConfiguration.setStoryExecutionTimeout(this.defaultStoryExecutionTimeout);
batchConfiguration.overrideStoryExecutionTimeout(this.defaultStoryExecutionTimeout);
}
if (batchConfiguration.isFailFast() == null)
{
Expand Down Expand Up @@ -88,7 +110,7 @@ public BatchConfiguration getBatchConfiguration(String batchKey)
return batchConfigurations.computeIfAbsent(batchKey, b -> {
BatchConfiguration config = new BatchConfiguration();
config.setName(batchKey);
config.setStoryExecutionTimeout(defaultStoryExecutionTimeout);
config.overrideStoryExecutionTimeout(defaultStoryExecutionTimeout);
config.setMetaFilters(defaultMetaFilters);
config.setFailFast(failFast);
return config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

<bean id="batchStorage" class="org.vividus.batch.BatchStorage">
<constructor-arg ref="propertyMapper" />
<constructor-arg value="${bdd.story-execution-timeout}" />
<constructor-arg type="java.time.Duration" value="${story.execution-timeout:#{null}}" />
<constructor-arg type="java.lang.String" value="${bdd.story.execution-timeout:#{null}}" />
<constructor-arg value="${bdd.all-meta-filters}" />
<constructor-arg value="${batch.fail-fast}" />
</bean>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 the original author or authors.
* Copyright 2019-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -270,7 +270,7 @@ private void mockBatchConfiguration(boolean failFast)
private void mockBatchConfiguration(boolean failFast, Boolean failStoryFast)
{
var batchConfiguration = spy(new BatchConfiguration());
batchConfiguration.setStoryExecutionTimeout(Duration.ofHours(1));
batchConfiguration.overrideStoryExecutionTimeout(Duration.ofHours(1));
batchConfiguration.setMetaFilters(META_FILTERS);
batchConfiguration.setThreads(2);
batchConfiguration.setFailFast(failFast);
Expand Down
Loading