Skip to content
Draft
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
10 changes: 9 additions & 1 deletion docs/modules/configuration/pages/tests-configuration.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ NOTE: The properties marked with *bold* are mandatory.
|`<empty>`
|If set the value overrides global setting `scenario.fail-fast`.

|`batch-<batch-number>.execution-timeout`
|`PT10H`
|The max duration of execution tests of batch in {durations-format-link} format. Overrides value specified via `batch.execution-timeout`.

|`batch-<batch-number>.story.execution-timeout`
|`PT2H`
|The max duration of the single story in the batch in {durations-format-link} format. Overrides value specified via `story.execution-timeout`.
Expand All @@ -88,9 +92,13 @@ NOTE: The properties marked with *bold* are mandatory.
|`false`
|If set to `true` the scenario execution will be stopped after the first failed assertion

|`batch.execution-timeout`
|`PT10H`
|The max duration of the single batch in {durations-format-link} format. Could be overridden via corresponding batch setting.

|`story.execution-timeout`
|`PT2H`
|The max duration of the single story in {durations-format-link} format. Could be overriden via corresponging batch setting.
|The max duration of the single story in {durations-format-link} format. Could be overridden via corresponding batch setting.

|`story.example-index-format`
|`\u0020[0]`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ private EmbedderControls createEmbedderControls(BatchConfiguration batchConfigur
EmbedderControls embedderControls = new EmbedderControls();
embedderControls.useStoryTimeouts(
Long.toString(batchConfiguration.getStoryExecutionTimeout().toSeconds()));
embedderControls.useRunTimeout(Long.toString(batchConfiguration.getExecutionTimeout().toSeconds()));
Optional.ofNullable(batchConfiguration.getThreads())
.ifPresent(embedderControls::useThreads);
embedderControls.doIgnoreFailureInStories(true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2023 the original author or authors.
* Copyright 2019-2025 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,6 +33,7 @@ public class BatchConfiguration
private Integer threads;
private List<String> metaFilters;
private Boolean failFast;
private Duration executionTimeout;
private ScenarioExecutionConfiguration scenario = new ScenarioExecutionConfiguration();
private StoryExecutionConfiguration story = new StoryExecutionConfiguration();
private Map<String, String> variables = Map.of();
Expand Down Expand Up @@ -122,6 +123,16 @@ public void setFailFast(Boolean failFast)
this.failFast = failFast;
}

public Duration getExecutionTimeout()
{
return executionTimeout;
}

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

public Boolean isFailScenarioFast()
{
return scenario.failFast;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,17 @@ public final class BatchStorage
"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(2);
private static final Duration DEFAULT_BATCH_TIMEOUT = Duration.ofHours(10);

private final Map<String, BatchConfiguration> batchConfigurations;
private final Duration defaultStoryExecutionTimeout;
private final Duration defaultBatchExecutionTimeout;
private final List<String> defaultMetaFilters;
private final boolean failFast;

public BatchStorage(IPropertyMapper propertyMapper, Duration defaultStoryExecutionTimeout,
String deprecatedDefaultStoryExecutionTimeout, List<String> defaultMetaFilters,
Duration defaultBatchExecutionTimeout, String deprecatedDefaultStoryExecutionTimeout,
List<String> defaultMetaFilters,
boolean failFast) throws IOException
{
this.defaultMetaFilters = defaultMetaFilters;
Expand All @@ -63,6 +66,8 @@ public BatchStorage(IPropertyMapper propertyMapper, Duration defaultStoryExecuti
this.defaultStoryExecutionTimeout = Optional.ofNullable(defaultStoryExecutionTimeout)
.orElse(DEFAULT_STORY_TIMEOUT);
}
this.defaultBatchExecutionTimeout = Optional.ofNullable(defaultBatchExecutionTimeout)
.orElse(DEFAULT_BATCH_TIMEOUT);
this.failFast = failFast;

batchConfigurations = readFromProperties(propertyMapper, BATCH, BatchConfiguration.class);
Expand All @@ -82,6 +87,10 @@ public BatchStorage(IPropertyMapper propertyMapper, Duration defaultStoryExecuti
{
batchConfiguration.overrideStoryExecutionTimeout(this.defaultStoryExecutionTimeout);
}
if (batchConfiguration.getExecutionTimeout() == null)
{
batchConfiguration.setExecutionTimeout(this.defaultBatchExecutionTimeout);
}
if (batchConfiguration.isFailFast() == null)
{
batchConfiguration.setFailFast(failFast);
Expand Down Expand Up @@ -111,6 +120,7 @@ public BatchConfiguration getBatchConfiguration(String batchKey)
BatchConfiguration config = new BatchConfiguration();
config.setName(batchKey);
config.overrideStoryExecutionTimeout(defaultStoryExecutionTimeout);
config.setExecutionTimeout(defaultBatchExecutionTimeout);
config.setMetaFilters(defaultMetaFilters);
config.setFailFast(failFast);
return config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<constructor-arg ref="propertyMapper" />
<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 type="java.time.Duration" value="${batch.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-2023 the original author or authors.
* Copyright 2019-2025 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 @@ -101,6 +101,7 @@ private void createBatchStorage(Map<String, String> batchConfigurations) throws
batchConfigurations.put("batch-2.name", BATCH_2_NAME);
batchConfigurations.put("batch-2.threads", Integer.toString(BATCH_2_THREADS));
batchConfigurations.put("batch-2.story.execution-timeout", BATCH_2_TIMEOUT.toString());
batchConfigurations.put("batch-2.execution-timeout", BATCH_2_TIMEOUT.toString());
batchConfigurations.put("batch-2.meta-filters", BATCH_2_META_FILTERS);
batchConfigurations.put("batch-2.fail-fast", TRUE);
batchConfigurations.put("batch-2.variables.key1", VALUE_1);
Expand All @@ -109,7 +110,7 @@ private void createBatchStorage(Map<String, String> batchConfigurations) throws
when(propertyParser.getPropertiesByPrefix(BATCH)).thenReturn(batchConfigurations);

var propertyMapper = new PropertyMapper(DOT, PropertyNamingStrategies.KEBAB_CASE, propertyParser, Set.of());
batchStorage = new BatchStorage(propertyMapper, EXPECTED_DURATION, null, DEFAULT_META_FILTERS, false);
batchStorage = new BatchStorage(propertyMapper, EXPECTED_DURATION, null, null, DEFAULT_META_FILTERS, false);
}

@Test
Expand Down Expand Up @@ -197,7 +198,7 @@ void shouldWarnAboutPlainSecondsUsage() throws IOException
DEFAULT_RESOURCE_LOCATION));

var propertyMapper = new PropertyMapper(DOT, PropertyNamingStrategies.KEBAB_CASE, propertyParser, Set.of());
batchStorage = new BatchStorage(propertyMapper, null, "300", DEFAULT_META_FILTERS, false);
batchStorage = new BatchStorage(propertyMapper, null, null, "300", DEFAULT_META_FILTERS, false);
assertEquals(List.of(warn("Property `bdd.story-execution-timeout` is deprecated and will be removed"
+ " in VIVIDUS 0.7.0. Please use `story.execution-timeout` instead.")), LOGGER.getLoggingEvents());
var config = batchStorage.getBatchConfiguration("batch-999");
Expand All @@ -213,22 +214,23 @@ void shouldThrowExceptionWhenBothPropertiesSpecified()
var duration = Duration.ofHours(111);
var propertyMapper = new PropertyMapper(DOT, PropertyNamingStrategies.KEBAB_CASE, propertyParser, Set.of());
var iae = assertThrows(IllegalArgumentException.class,
() -> new BatchStorage(propertyMapper, duration, "202", DEFAULT_META_FILTERS, false));
() -> new BatchStorage(propertyMapper, duration, duration, "202", DEFAULT_META_FILTERS, false));
assertEquals(iae.getMessage(), "Conflicting properties are found: `bdd.story-execution-timeout`"
+ " and `story.execution-timeout`. Property `bdd.story-execution-timeout` is deprecated and will be"
+ " removed in VIVIDUS 0.7.0. Please use `story.execution-timeout` instead.");
}

@Test
void shouldUseDefaultTimeout() throws IOException
void shouldUseDefaultTimeouts() throws IOException
{
var propertyParser = mock(PropertyParser.class);
when(propertyParser.getPropertiesByPrefix(BATCH)).thenReturn(Map.of("batch-997.resource-location",
DEFAULT_RESOURCE_LOCATION));

var propertyMapper = new PropertyMapper(DOT, PropertyNamingStrategies.KEBAB_CASE, propertyParser, Set.of());
batchStorage = new BatchStorage(propertyMapper, null, null, DEFAULT_META_FILTERS, false);
batchStorage = new BatchStorage(propertyMapper, null, null, null, DEFAULT_META_FILTERS, false);
var config = batchStorage.getBatchConfiguration("batch-997");
assertEquals(Duration.ofHours(2), config.getStoryExecutionTimeout());
assertEquals(Duration.ofHours(10), config.getExecutionTimeout());
}
}
Loading