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

[vividus] Rename batch properties to avoid BDD references #3413

Merged
merged 1 commit into from
Dec 1, 2022
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
14 changes: 7 additions & 7 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ jobs:
./gradlew :vividus-tests:debugStories -Pvividus.configuration.environments=system/saucelabs \
-Pvividus.configuration.suites= \
-Pvividus.configuration.profiles=saucelabs/web,web/desktop/chrome \
-Pvividus.bdd.story-loader.batch-1.resource-location=story/integration \
-Pvividus.bdd.story-loader.batch-1.resource-include-patterns=ProxyStepsTests.story \
-Pvividus.batch-1.resource-location=story/integration \
-Pvividus.batch-1.resource-include-patterns=ProxyStepsTests.story \
-Pvividus.selenium.grid.username=${SAUCELABS_USER} \
-Pvividus.selenium.grid.password=${SAUCELABS_KEY} \
-Pvividus.saucelabs.sauce-connect.command-line-arguments="--proxy-localhost --no-ssl-bump-domains example.com"
Expand Down Expand Up @@ -373,8 +373,8 @@ jobs:
./gradlew :vividus-tests:debugStories -Pvividus.configuration.environments=system/saucelabs/mobile_app/ios \
-Pvividus.configuration.suites= \
-Pvividus.configuration.profiles=saucelabs/mobile_app,mobile_app/ios \
-Pvividus.bdd.story-loader.batch-1.resource-location=story/system/mobile_app \
-Pvividus.bdd.story-loader.batch-1.resource-include-patterns=ProxyMobileStepsTests.story \
-Pvividus.batch-1.resource-location=story/system/mobile_app \
-Pvividus.batch-1.resource-include-patterns=ProxyMobileStepsTests.story \
-Pvividus.selenium.grid.username=${SAUCELABS_USER} \
-Pvividus.selenium.grid.password=${SAUCELABS_KEY} \
-Pvividus.allure.history-directory=output/history/sl-ios-proxy-system-tests \
Expand Down Expand Up @@ -461,7 +461,7 @@ jobs:
-Pvividus.allure.executor.report-name="SauceLabs Android System tests report (Original)" \
-Pvividus.bdd.variables.global.app-url=sauce-storage:vividus-test-app-android-$TEST_APP_VERSION.zip \
-Pvividus.statistics.print-failures=true \
-Pvividus.bdd.story-loader.batch-1.resource-include-patterns=VisualTesting.story \
-Pvividus.batch-1.resource-include-patterns=VisualTesting.story \
-Pvividus.ui.visual.baseline-storage.filesystem.folder=./baselines/original
else
echo No SAUCELABS_USER and/or SAUCELABS_KEY variables, System tests will be skipped
Expand All @@ -485,8 +485,8 @@ jobs:
./gradlew :vividus-tests:debugStories -Pvividus.configuration.environments=system/saucelabs/mobile_app/android \
-Pvividus.configuration.suites= \
-Pvividus.configuration.profiles=saucelabs/mobile_app,mobile_app/android \
-Pvividus.bdd.story-loader.batch-1.resource-location=story/system/mobile_app \
-Pvividus.bdd.story-loader.batch-1.resource-include-patterns=ProxyMobileStepsTests.story \
-Pvividus.batch-1.resource-location=story/system/mobile_app \
-Pvividus.batch-1.resource-include-patterns=ProxyMobileStepsTests.story \
-Pvividus.selenium.grid.username=${SAUCELABS_USER} \
-Pvividus.selenium.grid.password=${SAUCELABS_KEY} \
-Pvividus.allure.history-directory=output/history/sl-android-proxy-system-tests \
Expand Down
16 changes: 8 additions & 8 deletions docs/modules/ROOT/pages/tests-configuration.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,35 +36,35 @@ NOTE: The properties marked with *bold* are mandatory.
|Default value
|Description

|[subs=+quotes]`*bdd.story-loader.batch-<batch-number>.resource-location*`
|[subs=+quotes]`*batch-<batch-number>.resource-location*`
|
|The test project path to the folder with story-files

|`bdd.story-loader.batch-<batch-number>.resource-include-patterns`
|`batch-<batch-number>.resource-include-patterns`
|`<empty>`
|The comma-separated set of https://ant.apache.org/manual/dirtasks.html#patterns[ant-patterns] to match the stories to be included in the batch. Leading and trailing whitespaces in patterns are omitted.

|`bdd.story-loader.batch-<batch-number>.resource-exclude-patterns`
|`batch-<batch-number>.resource-exclude-patterns`
|`<empty>`
|The comma-separated set of https://ant.apache.org/manual/dirtasks.html#patterns[ant-patterns] to match the stories to be excluded from the batch. Leading and trailing whitespaces in patterns are omitted.

|`bdd.batch-<batch-number>.name`
|`batch-<batch-number>.name`
|`batch-<batch-number>`
|The name of the batch to display in the report

|`bdd.batch-<batch-number>.threads`
|`batch-<batch-number>.threads`
|`1`
|The number of parallel threads used to run stories

|`bdd.batch-<batch-number>.meta-filters`
|`batch-<batch-number>.meta-filters`
|suite meta-filter
|The meta-filter used to filter the batch stories and scenarios

|`bdd.batch-<batch-number>.fail-fast`
|`batch-<batch-number>.fail-fast`
|`false`
|If `true` and any failure is occurred during the batch execution, the subsequent batches will not be executed.

|`bdd.batch-<batch-number>.story-execution-timeout`
|`batch-<batch-number>.story-execution-timeout`
|`PT3H`
|The max duration of the single story in the batch.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private String getParentSuiteKey()
private String getBatchName()
{
String runningBatchKey = getRunContext().getRunningBatchKey();
return batchStorage.getBatchExecutionConfiguration(runningBatchKey).getName();
return batchStorage.getBatchConfiguration(runningBatchKey).getName();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
import org.mockito.Mockito;
import org.mockito.Spy;
import org.mockito.junit.jupiter.MockitoExtension;
import org.vividus.batch.BatchExecutionConfiguration;
import org.vividus.batch.BatchConfiguration;
import org.vividus.batch.BatchStorage;
import org.vividus.context.ReportControlContext;
import org.vividus.context.RunTestContext;
Expand Down Expand Up @@ -404,9 +404,9 @@ private void mockRunningBatchName()
private String mockBatchExecutionConfiguration()
{
String batchKey = "batch-1";
BatchExecutionConfiguration config = new BatchExecutionConfiguration();
BatchConfiguration config = new BatchConfiguration();
config.setName(BATCH_NAME);
when(batchStorage.getBatchExecutionConfiguration(batchKey)).thenReturn(config);
when(batchStorage.getBatchConfiguration(batchKey)).thenReturn(config);
return batchKey;
}

Expand Down
16 changes: 8 additions & 8 deletions vividus-engine/src/main/java/org/vividus/BatchedEmbedder.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import org.jbehave.core.embedder.PerformableTree;
import org.jbehave.core.failures.BatchFailures;
import org.jbehave.core.steps.InjectableStepsFactory;
import org.vividus.batch.BatchExecutionConfiguration;
import org.vividus.batch.BatchConfiguration;
import org.vividus.batch.BatchStorage;
import org.vividus.context.RunTestContext;
import org.vividus.context.VariableContext;
Expand Down Expand Up @@ -75,12 +75,12 @@ public void runStoriesAsPaths(Map<String, List<String>> storyPathsBatches)
Entry<String, List<String>> storyPathsBatch = iterator.next();
batch = storyPathsBatch.getKey();

BatchExecutionConfiguration batchExecutionConfiguration = batchStorage.getBatchExecutionConfiguration(
BatchConfiguration batchConfiguration = batchStorage.getBatchConfiguration(
batch);
useEmbedderControls(createEmbedderControls(batchExecutionConfiguration));
useMetaFilters(batchExecutionConfiguration.getMetaFilters());
useEmbedderControls(createEmbedderControls(batchConfiguration));
useMetaFilters(batchConfiguration.getMetaFilters());

failFast = batchExecutionConfiguration.isFailFast();
failFast = batchConfiguration.isFailFast();

EmbedderControls embedderControls = embedderControls();
embedderMonitor.usingControls(embedderControls);
Expand Down Expand Up @@ -157,12 +157,12 @@ private ExecutorService createExecutorService(int threads)
return Executors.newFixedThreadPool(threads, threadFactory);
}

private EmbedderControls createEmbedderControls(BatchExecutionConfiguration batchExecutionConfiguration)
private EmbedderControls createEmbedderControls(BatchConfiguration batchConfiguration)
{
EmbedderControls embedderControls = new EmbedderControls();
embedderControls.useStoryTimeouts(
Long.toString(batchExecutionConfiguration.getStoryExecutionTimeout().toSeconds()));
Optional.ofNullable(batchExecutionConfiguration.getThreads())
Long.toString(batchConfiguration.getStoryExecutionTimeout().toSeconds()));
Optional.ofNullable(batchConfiguration.getThreads())
.ifPresent(embedderControls::useThreads);
embedderControls.doIgnoreFailureInStories(true);
embedderControls.doGenerateViewAfterStories(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.util.Map;
import java.util.Map.Entry;

import org.vividus.batch.BatchResourceConfiguration;
import org.vividus.batch.BatchConfiguration;
import org.vividus.batch.BatchStorage;

/**
Expand All @@ -48,7 +48,7 @@ public Map<String, List<String>> getPaths() throws IOException
if (batchKeyToStoryPaths == null)
{
batchKeyToStoryPaths = new LinkedHashMap<>();
for (Entry<String, BatchResourceConfiguration> batch : batchStorage.getBatchResourceConfigurations()
for (Entry<String, BatchConfiguration> batch : batchStorage.getBatchConfigurations()
.entrySet())
{
batchKeyToStoryPaths.put(batch.getKey(), pathFinder.findPaths(batch.getValue()));
Expand Down
6 changes: 3 additions & 3 deletions vividus-engine/src/main/java/org/vividus/IPathFinder.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 the original author or authors.
* Copyright 2019-2022 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 @@ -19,10 +19,10 @@
import java.io.IOException;
import java.util.List;

import org.vividus.batch.BatchResourceConfiguration;
import org.vividus.batch.BatchConfiguration;

@FunctionalInterface
public interface IPathFinder
{
List<String> findPaths(BatchResourceConfiguration batchResourceConfiguration) throws IOException;
List<String> findPaths(BatchConfiguration batchConfiguration) throws IOException;
}
14 changes: 7 additions & 7 deletions vividus-engine/src/main/java/org/vividus/PathFinder.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2021 the original author or authors.
* Copyright 2019-2022 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 @@ -25,7 +25,7 @@
import java.util.function.Consumer;

import org.springframework.core.io.Resource;
import org.vividus.batch.BatchResourceConfiguration;
import org.vividus.batch.BatchConfiguration;
import org.vividus.resource.ITestResourceLoader;

public class PathFinder implements IPathFinder
Expand All @@ -38,22 +38,22 @@ public PathFinder(ITestResourceLoader testResourceLoader)
}

@Override
public List<String> findPaths(BatchResourceConfiguration batchResourceConfiguration) throws IOException
public List<String> findPaths(BatchConfiguration batchConfiguration) throws IOException
{
List<String> paths = new ArrayList<>();
process(batchResourceConfiguration, batchResourceConfiguration.getResourceIncludePatterns(), paths::add);
process(batchResourceConfiguration, batchResourceConfiguration.getResourceExcludePatterns(), paths::remove);
process(batchConfiguration, batchConfiguration.getResourceIncludePatterns(), paths::add);
process(batchConfiguration, batchConfiguration.getResourceExcludePatterns(), paths::remove);
Collections.sort(paths);
return paths;
}

private void process(BatchResourceConfiguration batchResourceConfiguration, List<String> resourcePatterns,
private void process(BatchConfiguration batchConfiguration, List<String> resourcePatterns,
Consumer<String> consumer) throws IOException
{
for (String resourcePattern : resourcePatterns)
{
Resource[] foundResources = testResourceLoader.getResources(
batchResourceConfiguration.getResourceLocation(), resourcePattern);
batchConfiguration.getResourceLocation(), resourcePattern);
for (Resource resource : foundResources)
{
String resourceUri = resource.getURI().normalize().toASCIIString().replace("+", "%2b");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,24 @@

package org.vividus.batch;

import java.time.Duration;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.apache.commons.lang3.StringUtils;

public class BatchResourceConfiguration
public class BatchConfiguration
{
private String resourceLocation;
private List<String> resourceIncludePatterns = List.of();
private List<String> resourceExcludePatterns = List.of();
private String name;
private Integer threads;
private List<String> metaFilters;
private Duration storyExecutionTimeout;
private Boolean failFast;

public String getResourceLocation()
{
Expand Down Expand Up @@ -59,6 +65,61 @@ public void setResourceExcludePatterns(String resourceExcludePatterns)
this.resourceExcludePatterns = convertToList(resourceExcludePatterns);
}

public String getName()
{
return name;
}

public void setName(String name)
{
this.name = name;
}

public Integer getThreads()
{
return threads;
}

public void setThreads(Integer threads)
{
this.threads = threads;
}

public List<String> getMetaFilters()
{
return metaFilters;
}

public void setMetaFilters(List<String> metaFilters)
{
this.metaFilters = metaFilters;
}

public void setMetaFilters(String metaFilters)
{
setMetaFilters(metaFilters != null ? List.of(StringUtils.split(metaFilters, ',')) : null);
}

public Duration getStoryExecutionTimeout()
{
return storyExecutionTimeout;
}

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

public Boolean isFailFast()
{
return failFast;
}

public void setFailFast(Boolean failFast)
{
this.failFast = failFast;
}

private List<String> convertToList(String list)
{
if (list == null)
Expand Down
Loading