Skip to content

Commit

Permalink
Adapt testing props
Browse files Browse the repository at this point in the history
  • Loading branch information
pavetok committed Feb 24, 2024
1 parent 85b86ac commit c3787d9
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 67 deletions.
20 changes: 10 additions & 10 deletions baker/ansible/sources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
ansible.builtin.command:
cmd: >-
mvn
--no-snapshot-updates
--batch-mode
enforcer:enforce
spotless:check
pmd:check
compiler:compile
spotbugs:check
--define devenv={{ devenv }}
enforcer:enforce
spotless:check
pmd:check
compiler:compile
spotbugs:check
--activate-profiles {{ devenv }}
--no-snapshot-updates
--batch-mode
chdir: "{{ project.dir }}"
strip_empty_ends: false
changed_when: false
Expand All @@ -28,8 +28,8 @@
# list all top level playbooks
cmd: >-
ansible-lint
sources.yaml
stacks.yaml
sources.yaml
stacks.yaml
strip_empty_ends: false
changed_when: false

Expand Down
11 changes: 5 additions & 6 deletions baker/ansible/tasks/app/build-and-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
ansible.builtin.command:
cmd: >-
mvn clean {{ maven_phase|mandatory }}
--activate-profiles {{ devenv }}
--no-snapshot-updates
--batch-mode
--fail-fast
Expand Down Expand Up @@ -33,12 +34,10 @@
- name: Analyze coverage
ansible.builtin.command:
cmd: >-
mvn
--no-snapshot-updates
--batch-mode
--projects :tool
clean
antrun:run@coverage
mvn clean antrun:run@coverage
--no-snapshot-updates
--batch-mode
--projects :tool
chdir: "{{ project.dir }}"
strip_empty_ends: false
changed_when: true
43 changes: 20 additions & 23 deletions baker/ansible/tasks/product/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,36 @@
ansible.builtin.command:
cmd: >-
docker compose
--file compose.yaml
--profile {{ opsenv }}
up
--remove-orphans
--quiet-pull
--no-deps
--detach
--file compose.yaml
--profile {{ opsenv }}
up
--remove-orphans
--quiet-pull
--no-deps
--detach
chdir: "{{ stack_dir }}/target/image-context"
strip_empty_ends: false
changed_when: true

- name: Test stand
ansible.builtin.command:
cmd: >-
mvn
--no-snapshot-updates
--batch-mode
--threads 2
--projects :e2e
mvn clean test
--activate-profiles {{ devenv }}
--no-snapshot-updates
--batch-mode
--threads 2
--projects :e2e
--also-make
--define skipUnits
{% if hostvars.gear.is_virtual.rc == 0 %}
--activate-profiles docker
{% endif %}
--also-make
clean
test
--define devenv={{ devenv }}
--define skipUnits=true
--define props={{ opsenv }}
{% if reminder is defined %}
--define testing.sharding.reminder={{ reminder }}
--define testing.client.host=sepuling
{% endif %}
{% if modulus is defined %}
--define testing.sharding.modulus={{ modulus }}
--define testing.sharding.modulus={{ modulus }}
{% endif %}
{% if reminder is defined %}
--define testing.sharding.reminder={{ reminder }}
{% endif %}
chdir: "{{ project.dir }}"
strip_empty_ends: false
Expand Down
18 changes: 1 addition & 17 deletions test/e2e/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
<artifactId>e2e</artifactId>
<packaging>jar</packaging>

<properties>
<testingClientHost>localhost</testingClientHost>
</properties>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
Expand All @@ -30,15 +26,6 @@
</dependency>
</dependencies>

<profiles>
<profile>
<id>docker</id>
<properties>
<testingClientHost>sepuling</testingClientHost>
</properties>
</profile>
</profiles>

<build>
<plugins>
<plugin>
Expand All @@ -47,10 +34,7 @@
<configuration>
<skipTests>${skipTests}</skipTests>
<test>smecalculus.bezmen.FuncSuite</test>
<systemPropertyVariables>
<testing.client.host>${testingClientHost}</testing.client.host>
</systemPropertyVariables>
<systemPropertiesFile>src/main/resources/testing.properties</systemPropertiesFile>
<systemPropertiesFile>src/test/resources/testing.properties</systemPropertiesFile>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import smecalculus.bezmen.configuration.ClientKeys;
import smecalculus.bezmen.configuration.ClientProps;
import smecalculus.bezmen.configuration.TestingProps;
import smecalculus.bezmen.messaging.BezmenClient;
import smecalculus.bezmen.messaging.BezmenClientJavaHttp;

Expand All @@ -15,8 +15,8 @@ public class StandBeans {

@Bean
ClientProps clientProps(Environment environment) {
var host = environment.getRequiredProperty(ClientKeys.HOST_KEY, String.class);
var port = environment.getRequiredProperty(ClientKeys.POST_KEY, Integer.class);
var host = environment.getRequiredProperty(TestingProps.HOST_KEY, String.class);
var port = environment.getRequiredProperty(TestingProps.PORT_KEY, Integer.class);
return new ClientProps(host, port);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
testing.client.host=localhost
testing.client.port=8080
testing.sharding.modulus=1
testing.sharding.reminder=0

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package smecalculus.bezmen.configuration;

public abstract class TestingProps {
public static final String HOST_KEY = "testing.client.host";
public static final String PORT_KEY = "testing.client.port";
public static final String MODULUS_KEY = "testing.sharding.modulus";
public static final String REMINDER_KEY = "testing.sharding.reminder";
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package smecalculus.bezmen.testing;

import static java.util.Objects.requireNonNull;
import static org.junit.jupiter.api.extension.ConditionEvaluationResult.disabled;
import static org.junit.jupiter.api.extension.ConditionEvaluationResult.enabled;
import static smecalculus.bezmen.configuration.TestingProps.MODULUS_KEY;
import static smecalculus.bezmen.configuration.TestingProps.REMINDER_KEY;

import org.junit.jupiter.api.extension.ConditionEvaluationResult;
import org.junit.jupiter.api.extension.ExecutionCondition;
Expand All @@ -11,14 +14,14 @@ public class ShardingExtension implements ExecutionCondition {

@Override
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
int modulus = Integer.getInteger("testing.sharding.modulus", 1);
int modulus = requireNonNull(Integer.getInteger(MODULUS_KEY));
if (modulus <= 1) {
return enabled("without sharding");
}
if (context.getTestMethod().isEmpty()) {
return enabled("classes always enabled");
}
var reminder = Integer.getInteger("testing.sharding.reminder", 0);
var reminder = requireNonNull(Integer.getInteger(REMINDER_KEY));
var testId = context.getUniqueId().hashCode();
if (testId % modulus == reminder) {
return enabled("shard match: " + reminder);
Expand Down

0 comments on commit c3787d9

Please sign in to comment.