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

SQLTest healthcheck update to align with msqlserver:CU28-2019 #105

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
3 changes: 3 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@
</dependency>
</dependencies>
<build>
<!-- To avoid problems with concurrency we change the directories of the reports and outputs -->
<testOutputDirectory>${basedir}/target/test-classes/${dirtarget}</testOutputDirectory>
<outputDirectory>${basedir}/target/classes/${dirtarget}</outputDirectory>
<pluginManagement>
<plugins>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,25 @@ void testCancelOrder() throws ElementNotFoundException {
expectedStatesPriorCancelling.add("stockconfirmed");
LinkedList<String> expectedStatesPostCancelling = new LinkedList<>();
expectedStatesPostCancelling.add("cancelled");
LinkedList <String> expectedStatesBeforeLongDelay = new LinkedList<>();
expectedStatesBeforeLongDelay.add("paid");

login();
toOrdersPage(driver, waiter);
createOrder();
long startTime = System.currentTimeMillis();
checkLastOrderState( expectedStatesPriorCancelling);
cancelLastOrder();
long endTime = System.currentTimeMillis();
long duration =endTime-startTime;
log.debug("The time invested in place the order was: {}s", duration);
if(duration<=3000) {
cancelLastOrder();
checkLastOrderState(expectedStatesPostCancelling);
}
else {
checkLastOrderState(expectedStatesBeforeLongDelay);
}

checkLastOrderState( expectedStatesPostCancelling);
logout();
}

Expand All @@ -109,6 +120,7 @@ void testCancelOrder() throws ElementNotFoundException {
private void checkLastOrderState( List<String> expectedStates) throws ElementNotFoundException {
int maxIterations = 10;
String actualState = "";

for (int iter = 0; iter < maxIterations; iter++) {
log.debug("Performing iteration {} over the orders", iter);
toOrdersPage(driver, waiter);
Expand All @@ -125,6 +137,7 @@ private void checkLastOrderState( List<String> expectedStates) throws ElementNot
waiter.waitUntil(ExpectedConditions.not(ExpectedConditions.textToBePresentInElement(statusElement
, actualState)),
"The actual state remains untouched");
log.debug("Refreshing the webpage to update order status...");
} catch (Exception ex) {
log.debug("Timeout the element remains with the previous state, previous was{}current is:{}", actualState, statusElement.getText());
}
Expand Down
2 changes: 1 addition & 1 deletion sut/src/Services/Services.Common/Services.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" />
<PackageReference Include="Polly" />
<PackageReference Include="Swashbuckle.AspNetCore" />
<PackageReference Include="System.Data.SqlClient" />
<PackageReference Include="System.Data.SqlClient" />
<PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" />
<PackageReference Include="Azure.Identity" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" />
Expand Down
15 changes: 10 additions & 5 deletions sut/src/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:

sqldata:
container_name: sqldata_${tjobname}
image: mcr.microsoft.com/mssql/server:2019-latest
image: mcr.microsoft.com/mssql/server:2019-CU28-ubuntu-20.04
environment:
- SA_PASSWORD=Pass@word
- ACCEPT_EULA=Y
Expand All @@ -18,9 +18,11 @@ services:
networks:
- jenkins_network
healthcheck:
test: "/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P \"Pass@word\" -Q \"SELECT name FROM master.sys.databases\""
timeout: 20s
test: "/opt/mssql-tools18/bin/sqlcmd -C -S localhost -U SA -P \"Pass@word\" -Q \"SELECT name FROM master.sys.databases\""
interval: 10s
timeout: 3s
retries: 10
start_period: 20s

nosqldata:
container_name: nosqldata_${tjobname}
Expand Down Expand Up @@ -149,8 +151,9 @@ services:
healthcheck:
test: "curl -f http://localhost/hc || exit 1"
interval: 30s
timeout: 30s
retries: 10
timeout: 3s
retries: 15
start_period: 25s
environment:
- ASPNETCORE_ENVIRONMENT=Development
- Kestrel__Endpoints__HTTP__Url=http://0.0.0.0:80
Expand Down Expand Up @@ -184,6 +187,8 @@ services:
context: .
dockerfile: Services/Ordering/Ordering.BackgroundTasks/Dockerfile
depends_on:
ordering-api:
condition: service_healthy
sqldata:
condition: service_healthy
rabbitmq:
Expand Down