Skip to content

Commit cc40fd0

Browse files
committed
[JBTM-3794] Write Test CI to test annotation example
1 parent ea72317 commit cc40fd0

File tree

7 files changed

+220
-0
lines changed

7 files changed

+220
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
3+
# URL to be invoked
4+
URL="http://localhost:8082/trip/book?hotelName=Rex&flightNumber=123"
5+
6+
# Function to validate the response
7+
validate_response() {
8+
local response="$1"
9+
10+
# Check if the expected JSON string is present in the response
11+
if [ "$response" = "CONFIRMED" ]; then
12+
echo "Validation successful: Expected response found."
13+
else
14+
echo "Validation failed: Expected response not found."
15+
fi
16+
}
17+
18+
# Invoke the URL using curl and capture the response
19+
response=$(curl -XPOST "$URL")
20+
21+
echo $response
22+
23+
# Check if curl was successful
24+
if [ $? -eq 0 ]; then
25+
echo "URL invoked successfully."
26+
# Validate the response
27+
28+
29+
# Extract the id value using jq
30+
id=$(echo "$response" | jq -r '.id')
31+
echo "Extracted id: $id"
32+
33+
# Invoke the second URL using the extracted id
34+
if [ -n "$id" ]; then
35+
response_status=$(curl "http://localhost:8082/trip/status?sraId=$id")
36+
echo $response_status
37+
validate_response "$response_status"
38+
39+
40+
else
41+
echo "Failed to extract the id from the response."
42+
fi
43+
44+
else
45+
echo "Failed to invoke the URL. Please check if the URL is valid and accessible."
46+
fi

rts/at/annotation/pom.xml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,34 @@
5959
<scope>provided</scope>
6060
</dependency>
6161
</dependencies>
62+
<profiles>
63+
<profile>
64+
<id>unix</id>
65+
<activation>
66+
<file>
67+
<exists>${basedir}/run.sh</exists>
68+
</file>
69+
</activation>
70+
<build>
71+
<plugins>
72+
<plugin>
73+
<artifactId>exec-maven-plugin</artifactId>
74+
<groupId>org.codehaus.mojo</groupId>
75+
<executions>
76+
<execution>
77+
<id>Execute Run Scripts</id>
78+
<phase>post-integration-test</phase>
79+
<goals>
80+
<goal>exec</goal>
81+
</goals>
82+
<configuration>
83+
<executable>${basedir}/run.sh</executable>
84+
</configuration>
85+
</execution>
86+
</executions>
87+
</plugin>
88+
</plugins>
89+
</build>
90+
</profile>
91+
</profiles>
6292
</project>

rts/at/annotation/run.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
3+
# Change the following variables to match your WildFly installation
4+
#JBOSS_HOME="/home/mshikalw/Documents/AllGitFork/wildfly/build/target/wildfly-28.0.2.Final-SNAPSHOT"
5+
WILDFLY_BIN="$JBOSS_HOME/bin"
6+
7+
8+
# Source file path (replace with the path of the file you want to copy)
9+
SOURCE_FILE="$JBOSS_HOME/docs/examples/configs/standalone-rts.xml"
10+
11+
# Destination directory path (replace with the path of the directory where you want to copy the file)
12+
DESTINATION_DIR="$JBOSS_HOME/standalone/configuration/"
13+
14+
# Check if the source file exists
15+
if [ -f "$SOURCE_FILE" ]; then
16+
# Check if the destination directory exists
17+
if [ -d "$DESTINATION_DIR" ]; then
18+
# Use 'cp' command to copy the file
19+
cp "$SOURCE_FILE" "$DESTINATION_DIR"
20+
echo "File copied successfully to $DESTINATION_DIR"
21+
else
22+
echo "Destination directory $DESTINATION_DIR does not exist."
23+
fi
24+
else
25+
echo "Source file $SOURCE_FILE does not exist."
26+
fi
27+
28+
## Start Wilfly server
29+
30+
echo "Starting wildfly server"
31+
32+
# Call and run start-wildfly-coordinator.sh
33+
source ./start-wildfly-coordinator.sh
34+
35+
36+
echo "Starting all services"
37+
38+
# Call and run start-services.sh
39+
source ./start-services.sh
40+
41+
42+
echo "Invoking trip service"
43+
44+
# Call and run invoke-trip-service-url.sh
45+
source ./invoke-trip-service-url.sh
46+
47+
48+
echo "Stopping wildfly server"
49+
50+
# Call and run scrstop-wildfly-coordinatoript.sh
51+
source stop-wildfly-coordinator.sh
52+
53+
54+
echo "Stopping all services"
55+
56+
# Call and run stop-services.sh using the 'source' or '.' command
57+
source ./stop-services.sh
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
############################
4+
5+
# Step 1: Clean and package the Maven project, skipping tests
6+
mvn clean package -DskipTests
7+
8+
# Step 2: Run flight-service in the background
9+
java -jar flight-service/target/quarkus-app/quarkus-run.jar &
10+
11+
# Step 3: Run hotel-service in the background
12+
java -jar hotel-service/target/quarkus-app/quarkus-run.jar &
13+
14+
# Step 4: Run trip-service in the background
15+
java -jar trip-service/target/quarkus-app/quarkus-run.jar &
16+
17+
# Wait for a few seconds to give time for the services to start
18+
sleep 10
19+
20+
# Check if the services are running
21+
if $(jps | grep -q "quarkus-run.jar"); then
22+
echo "All services started successfully!"
23+
else
24+
echo "Failed to start one or more services. Please check the logs for more information."
25+
fi
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
# Start WildFly
4+
echo "Starting WildFly..."
5+
#JBOSS_HOME="/home/mshikalw/Documents/AllGitFork/wildfly/build/target/wildfly-28.0.2.Final-SNAPSHOT"
6+
WILDFLY_BIN=$JBOSS_HOME/bin
7+
8+
$WILDFLY_BIN/standalone.sh -c standalone-rts.xml > /dev/null 2>&1 &
9+
10+
# Wait for a few seconds to give time for the server to start
11+
sleep 10
12+
13+
# Check if WildFly is running
14+
if $(jps | grep -q "jboss-modules"); then
15+
echo "WildFly started successfully!"
16+
else
17+
echo "Failed to start WildFly. Please check the logs for more information."
18+
fi

rts/at/annotation/stop-services.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
# Function to stop a service by its process name
4+
stop_service() {
5+
local service_name="$1"
6+
pkill -f "$service_name"
7+
}
8+
9+
# Stop the flight-service
10+
stop_service "flight-service"
11+
12+
# Stop the hotel-service
13+
stop_service "hotel-service"
14+
15+
# Stop the trip-service
16+
stop_service "trip-service"
17+
18+
# Wait for a few seconds to give time for the services to stop
19+
sleep 5
20+
21+
# Check if the services are still running
22+
if $(jps | grep -q "quarkus-run.jar"); then
23+
echo "Failed to stop one or more services. Please check the logs for more information."
24+
else
25+
echo "All services stopped successfully!"
26+
fi
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
# Stop WildFly
4+
echo "Stopping WildFly..."
5+
#JBOSS_HOME="/home/mshikalw/Documents/AllGitFork/wildfly/build/target/wildfly-28.0.2.Final-SNAPSHOT"
6+
WILDFLY_BIN=$JBOSS_HOME/bin
7+
8+
$WILDFLY_BIN/jboss-cli.sh --connect command=:shutdown
9+
10+
# Wait for a few seconds to give time for the server to stop
11+
sleep 10
12+
13+
# Check if WildFly is still running
14+
if $(jps | grep -q "jboss-modules"); then
15+
echo "Failed to stop WildFly. Please check the logs for more information."
16+
else
17+
echo "WildFly stopped successfully!"
18+
fi

0 commit comments

Comments
 (0)