Skip to content

Commit 213784e

Browse files
authored
Add gatling integration tests module (#381)
* Add gatling integration tests module * add Gatling test task with paged task variables query * make mvn build output quiet * Add default transactional strategy executor instance and shutdown hook
1 parent cf11bd0 commit 213784e

File tree

14 files changed

+1622
-2
lines changed

14 files changed

+1622
-2
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
cache: maven
2929

3030
- name: Build with Maven
31-
run: mvn -B -ntp install
31+
run: mvn -B -q -ntp install
3232

3333
- name: Upload coverage to Codecov
3434
uses: codecov/codecov-action@v3

autoconfigure/src/main/java/com/introproventures/graphql/jpa/query/autoconfigure/TransactionalDelegateExecutionStrategy.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import graphql.execution.NonNullableFieldWasNullException;
99
import java.util.concurrent.CompletableFuture;
1010
import java.util.concurrent.Executor;
11+
import java.util.concurrent.ExecutorService;
1112
import java.util.concurrent.Executors;
1213
import java.util.function.Supplier;
1314
import org.slf4j.Logger;
@@ -96,8 +97,14 @@ public CompletableFuture<ExecutionResult> execute(
9697

9798
public static final class Builder {
9899

100+
private static final ExecutorService EXECUTOR_SERVICE = Executors.newCachedThreadPool();
101+
102+
static {
103+
Runtime.getRuntime().addShutdownHook(new Thread(EXECUTOR_SERVICE::shutdown));
104+
}
105+
99106
private TransactionTemplate transactionTemplate;
100-
private Supplier<Executor> executor = Executors::newCachedThreadPool;
107+
private Supplier<Executor> executor = () -> EXECUTOR_SERVICE;
101108
private ExecutionStrategy delegate = new AsyncExecutionStrategy();
102109

103110
private Builder() {}

tests/gatling/pom.xml

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>com.introproventures</groupId>
8+
<artifactId>graphql-jpa-query-tests</artifactId>
9+
<version>1.1.2-SNAPSHOT</version>
10+
<relativePath>../pom.xml</relativePath>
11+
</parent>
12+
13+
<artifactId>graphql-jpa-query-tests-gatling</artifactId>
14+
15+
<properties>
16+
<activiti-cloud.version>8.0.0</activiti-cloud.version>
17+
<gatling.version>3.9.5</gatling.version>
18+
<gatling-maven-plugin.version>4.6.0</gatling-maven-plugin.version>
19+
</properties>
20+
21+
<dependencies>
22+
<dependency>
23+
<groupId>com.introproventures</groupId>
24+
<artifactId>graphql-jpa-query-boot-starter</artifactId>
25+
</dependency>
26+
<!-- <dependency>-->
27+
<!-- <groupId>com.introproventures</groupId>-->
28+
<!-- <artifactId>graphql-jpa-query-web</artifactId>-->
29+
<!-- </dependency>-->
30+
<dependency>
31+
<groupId>org.springframework.boot</groupId>
32+
<artifactId>spring-boot-starter-graphql</artifactId>
33+
</dependency>
34+
<dependency>
35+
<groupId>org.springframework.boot</groupId>
36+
<artifactId>spring-boot-starter-web</artifactId>
37+
</dependency>
38+
<dependency>
39+
<groupId>org.springframework.boot</groupId>
40+
<artifactId>spring-boot-starter-data-jpa</artifactId>
41+
</dependency>
42+
<dependency>
43+
<groupId>org.activiti.cloud</groupId>
44+
<artifactId>activiti-cloud-services-query-liquibase</artifactId>
45+
<version>${activiti-cloud.version}</version>
46+
</dependency>
47+
<dependency>
48+
<groupId>org.activiti.cloud</groupId>
49+
<artifactId>activiti-cloud-services-query-model</artifactId>
50+
<version>${activiti-cloud.version}</version>
51+
</dependency>
52+
<dependency>
53+
<groupId>org.postgresql</groupId>
54+
<artifactId>postgresql</artifactId>
55+
<scope>runtime</scope>
56+
</dependency>
57+
<dependency>
58+
<groupId>org.projectlombok</groupId>
59+
<artifactId>lombok</artifactId>
60+
<optional>true</optional>
61+
</dependency>
62+
<dependency>
63+
<groupId>io.gatling.highcharts</groupId>
64+
<artifactId>gatling-charts-highcharts</artifactId>
65+
<version>${gatling.version}</version>
66+
<scope>test</scope>
67+
</dependency>
68+
<dependency>
69+
<groupId>org.springframework.boot</groupId>
70+
<artifactId>spring-boot-testcontainers</artifactId>
71+
<scope>test</scope>
72+
</dependency>
73+
<dependency>
74+
<groupId>org.testcontainers</groupId>
75+
<artifactId>junit-jupiter</artifactId>
76+
<scope>test</scope>
77+
</dependency>
78+
<dependency>
79+
<groupId>org.testcontainers</groupId>
80+
<artifactId>postgresql</artifactId>
81+
<scope>test</scope>
82+
</dependency>
83+
</dependencies>
84+
85+
<build>
86+
<plugins>
87+
<plugin>
88+
<groupId>org.springframework.boot</groupId>
89+
<artifactId>spring-boot-maven-plugin</artifactId>
90+
<executions>
91+
<execution>
92+
<goals>
93+
<goal>repackage</goal>
94+
</goals>
95+
</execution>
96+
<execution>
97+
<id>pre-integration-test</id>
98+
<phase>pre-integration-test</phase>
99+
<goals>
100+
<goal>start</goal>
101+
</goals>
102+
<configuration>
103+
<skip>${skipTests}</skip>
104+
<mainClass>com.introproventures.graphql.jpa.query.example.TestApplication</mainClass>
105+
<useTestClasspath>true</useTestClasspath>
106+
<classesDirectory>${project.build.testOutputDirectory}${path.separator}${project.build.outputDirectory}</classesDirectory>
107+
<jvmArguments>
108+
-Xms512m
109+
-Xmx1024m
110+
</jvmArguments>
111+
</configuration>
112+
</execution>
113+
<execution>
114+
<id>post-integration-test</id>
115+
<phase>post-integration-test</phase>
116+
<configuration>
117+
<skip>${skipTests}</skip>
118+
</configuration>
119+
<goals>
120+
<goal>stop</goal>
121+
</goals>
122+
</execution>
123+
</executions>
124+
</plugin>
125+
<plugin>
126+
<groupId>io.gatling</groupId>
127+
<artifactId>gatling-maven-plugin</artifactId>
128+
<version>${gatling-maven-plugin.version}</version>
129+
<executions>
130+
<execution>
131+
<phase>integration-test</phase>
132+
<goals>
133+
<goal>test</goal>
134+
</goals>
135+
</execution>
136+
</executions>
137+
<configuration>
138+
<skip>${skipTests}</skip>
139+
<runMultipleSimulations>true</runMultipleSimulations>
140+
<jvmArgs>
141+
<arg>-XX:ActiveProcessorCount=2</arg>
142+
<arg>-Djava.net.preferIPv6Addresses=false</arg>
143+
</jvmArgs>
144+
<overrideJvmArgs>true</overrideJvmArgs>
145+
<!-- Enterprise Cloud (https://cloud.gatling.io/) configuration reference: https://gatling.io/docs/gatling/reference/current/extensions/maven_plugin/#working-with-gatling-enterprise-cloud -->
146+
<!-- Enterprise Self-Hosted configuration reference: https://gatling.io/docs/gatling/reference/current/extensions/maven_plugin/#working-with-gatling-enterprise-self-hosted -->
147+
</configuration>
148+
</plugin>
149+
</plugins>
150+
</build>
151+
152+
<repositories>
153+
<repository>
154+
<id>activiti-releases</id>
155+
<url>https://artifacts.alfresco.com/nexus/content/repositories/activiti-releases</url>
156+
</repository>
157+
</repositories>
158+
159+
</project>
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* Copyright 2017 IntroPro Ventures, Inc. and/or its affiliates.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.introproventures.graphql.jpa.query.example;
17+
18+
import static graphql.schema.GraphQLScalarType.newScalar;
19+
20+
import com.introproventures.graphql.jpa.query.autoconfigure.EnableGraphQLJpaQuerySchema;
21+
import com.introproventures.graphql.jpa.query.autoconfigure.GraphQLJPASchemaBuilderCustomizer;
22+
import com.introproventures.graphql.jpa.query.schema.JavaScalars;
23+
import java.util.Date;
24+
import org.activiti.cloud.services.query.model.ProcessInstanceEntity;
25+
import org.activiti.cloud.services.query.model.VariableValue;
26+
import org.springframework.beans.factory.annotation.Value;
27+
import org.springframework.boot.SpringApplication;
28+
import org.springframework.boot.autoconfigure.SpringBootApplication;
29+
import org.springframework.context.annotation.Bean;
30+
import org.springframework.context.annotation.Configuration;
31+
32+
@SpringBootApplication
33+
public class Application {
34+
35+
// docker run -it --rm -p 5432:5432 -e POSTGRES_PASSWORD=password postgres
36+
public static void main(String[] args) {
37+
SpringApplication.run(Application.class, args);
38+
}
39+
40+
@Configuration(proxyBeanMethods = false)
41+
@EnableGraphQLJpaQuerySchema(basePackageClasses = ProcessInstanceEntity.class)
42+
static class Config {
43+
44+
@Bean
45+
GraphQLJPASchemaBuilderCustomizer graphQLJPASchemaBuilderCustomizer(
46+
@Value("${activiti.cloud.graphql.jpa-query.date-format:yyyy-MM-dd'T'HH:mm:ss.SSSX}") String dateFormatString
47+
) {
48+
return builder ->
49+
builder
50+
.name("Query")
51+
.description("Activiti Cloud Query Schema")
52+
.scalar(
53+
VariableValue.class,
54+
newScalar()
55+
.name("VariableValue")
56+
.description("VariableValue type")
57+
.coercing(new JavaScalars.GraphQLObjectCoercing())
58+
.build()
59+
)
60+
.scalar(
61+
Date.class,
62+
newScalar()
63+
.name("Date")
64+
.description("Date type with '" + dateFormatString + "' format")
65+
.coercing(new JavaScalars.GraphQLDateCoercing(dateFormatString))
66+
.build()
67+
);
68+
}
69+
}
70+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
2+
server:
3+
compression:
4+
enabled: false
5+
tomcat:
6+
connection-timeout: 5s
7+
threads:
8+
max: 200
9+
min-spare: 100
10+
11+
spring:
12+
jpa:
13+
hibernate.ddl-auto: validate
14+
generate-ddl: false
15+
show-sql: false
16+
defer-datasource-initialization: false
17+
open-in-view: false
18+
database-platform: org.hibernate.dialect.PostgreSQLDialect
19+
properties:
20+
hibernate.format_sql: true
21+
hibernate.temp.use_jdbc_metadata_defaults: false
22+
hibernate.query.fail_on_pagination_over_collection_fetch: true
23+
h2:
24+
console.enabled: true
25+
26+
datasource:
27+
url: jdbc:postgresql://localhost:5432/postgres
28+
username: postgres
29+
password: password
30+
31+
graphql:
32+
jpa:
33+
query:
34+
name: Activiti
35+
description: GraphQL Jpa Query Activiti Schema Example
36+
enabled: true
37+
web:
38+
enabled: true
39+
graphiql:
40+
enabled: true
41+
sql:
42+
init:
43+
mode: always
44+
45+
logging:
46+
level:
47+
org.hibernate: INFO
48+
com.introproventures.graphql.jpa.query.schema: INFO
49+
50+
debug: false

0 commit comments

Comments
 (0)