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

Automated testing #23

Merged
merged 60 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
3291206
WIP: Init automated testing:
BS-jiriceska Oct 17, 2024
2bc34ce
Add utitlities script.
BS-jiriceska Oct 17, 2024
ead8536
Change utilities to powershell module. Change logical files of DB names.
BS-jiriceska Oct 17, 2024
3229a59
Comment unused code. Some fixes in script config.
BS-jiriceska Oct 17, 2024
be06632
Update CI to run correct web.
BS-jiriceska Oct 17, 2024
5666fc8
Fix CI config.
BS-jiriceska Oct 18, 2024
47a1c78
Fix build warning for newest hotfix.
BS-jiriceska Oct 18, 2024
627fbf4
localhost unlimited expiration for XbyK.
BS-jiriceska Oct 18, 2024
4e0a3c3
Restore of DB without license key.
BS-jiriceska Oct 21, 2024
10fb7ae
Use new XbyK license - settings key.
BS-jiriceska Oct 21, 2024
b84dbc1
Change dev connection strings to trusted connection on SQLEXPRESS.
BS-jiriceska Oct 21, 2024
a41d22b
Add K13 app to pipeline.
BS-jiriceska Oct 21, 2024
d9cadb0
Fix packages.
BS-jiriceska Oct 21, 2024
72b076f
Fix typo sqlcmd.
BS-jiriceska Oct 21, 2024
900f54d
Fix ASPNETCORE_URLS.
BS-jiriceska Oct 21, 2024
0efb771
Unify order of preparing apps (first K13, then XbK). Fix ASPNETCORE_URLS
BS-jiriceska Oct 21, 2024
707fc18
Comment K13 store.
BS-jiriceska Oct 21, 2024
e6032c9
Run applications on different port
BS-jiriceska Oct 23, 2024
f52ea5e
Fix settings for development.
BS-jiriceska Oct 24, 2024
82205bf
Fill CI with data.
BS-jiriceska Oct 24, 2024
fa7ac1b
Merge both jobs together.
BS-jiriceska Oct 24, 2024
c39cdca
Allow to update to latest hotfix.
BS-jiriceska Oct 24, 2024
374e28e
merge main to E2E testing
BS-jiriceska Oct 24, 2024
c6d8229
Finish upgrade to latest hotfix.
BS-jiriceska Oct 25, 2024
8a4dc3e
Change powershell to pwsh.
BS-jiriceska Oct 25, 2024
c70c802
Fix slashes for Ubuntu.
BS-jiriceska Oct 25, 2024
6718ba1
Fix DB update and generating files.
BS-jiriceska Oct 25, 2024
73d7447
CI restore on backup version. Then install latest hotfix.
BS-jiriceska Oct 25, 2024
620b486
Updated DB backup to reflect new version of module - allow CI for cus…
BS-jiriceska Oct 29, 2024
a9c0edf
Create script for reseting database consistency. Move it from .csproj.
BS-jiriceska Oct 30, 2024
c5d7804
Fix path issue.
BS-jiriceska Oct 30, 2024
95935cf
Change dev K13 app to http URL even for CI pipeline.
BS-jiriceska Oct 30, 2024
69f3cbd
Add K13 store ping to health check for XbK.
BS-jiriceska Oct 31, 2024
ee1bbef
Added logging for application startup.
BS-jiriceska Oct 31, 2024
7d8bc96
Try HTTPS communication.
BS-jiriceska Nov 1, 2024
3781e2f
Fix status URL to HTTPS.
BS-jiriceska Nov 1, 2024
865d5eb
Revert HTTPS for K13
BS-jiriceska Nov 1, 2024
4133b61
Add logging for Duende
BS-jiriceska Nov 1, 2024
658483f
Add loging to health check.
BS-jiriceska Nov 1, 2024
5b8f6ab
Change healt check.
BS-jiriceska Nov 1, 2024
63a15de
Log Trace on KX13
BS-jiriceska Nov 1, 2024
725b532
Increase limit of statup of K13. Logging to token client.
BS-jiriceska Nov 1, 2024
77a6114
Revert status check from XbyK to K13 to /status.
BS-jiriceska Nov 1, 2024
d8225ea
Healthcheck changed to getting token from K13.
BS-jiriceska Nov 1, 2024
0924433
Revert too detailed logging.
BS-jiriceska Nov 1, 2024
be63d60
Allowing different version for Ecommerce library and DancingGoat live…
BS-jiriceska Nov 4, 2024
212793d
E2E playwright tests
andrejrblue Nov 4, 2024
ce2ef9c
Merge branch 'feat/automatic_E2E_testing' of https://github.com/Kenti…
BS-jiriceska Nov 4, 2024
df5ef3e
Added E2E tests to pipeline.
BS-jiriceska Nov 4, 2024
82728f7
Updated path of playwright report.
BS-jiriceska Nov 4, 2024
b23d9bc
Update Github action to run only every Friday at 10:00 UTC.
BS-jiriceska Nov 4, 2024
b8d3c7d
Updated DB backup to dont have initialized content.
BS-jiriceska Nov 4, 2024
5e4c30a
Update scripts to more clean solution.
BS-jiriceska Nov 5, 2024
a517c6a
Finishing documentation for startup project.
BS-jiriceska Nov 6, 2024
4b1191c
Test cron.
BS-jiriceska Nov 8, 2024
1051a45
Test cron
BS-jiriceska Nov 8, 2024
a871ae0
Revert changes to ci.yml
BS-jiriceska Nov 8, 2024
172b47c
Add new line on end of ci.yml
BS-jiriceska Nov 8, 2024
28e4551
Fixes after code review.
BS-jiriceska Nov 11, 2024
660fe11
Fixes after CR.
BS-jiriceska Nov 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
232 changes: 232 additions & 0 deletions .github/workflows/e2etest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
name: "E2E: Build and Test"

on:
schedule:
- cron: '0 10 * * 5' # Runs every Friday at 10:00 UTC

jobs:
build_and_test:
name: Test E2E
runs-on: ubuntu-latest
defaults:
run:
shell: pwsh

env:
ASPNETCORE_ENVIRONMENT: CI
XBK_DATABASE_BACKUP_FILENAME: ""
K13_DATABASE_BACKUP_FILENAME: ""
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: 1
XBK_PROJECT_NAME: DancingGoat
K13_PROJECT_NAME: Kentico13_DancingGoat
XBK_STATUS_CHECK_URL: https://localhost:14066/status
K13_STATUS_CHECK_URL: http://localhost:65375/status
XPERIENCE_BY_KENTICO_LICENSE: ${{ secrets.XPERIENCE_BY_KENTICO_LICENSE }}
KENTICO_XPERIENCE_13_LICENSE: ${{ secrets.KENTICO_XPERIENCE_13_LICENSE }}

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
global-json-file: global.json

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: lts/*

- name: Install NPM
run: |
cd test/Playwright
npm ci
npx playwright install --with-deps
cd ../..

- name: Get Database Backup Name
run: |
$latestBackups = Get-Content -Path "./database/backups.txt" -TotalCount 2
"K13_DATABASE_BACKUP_FILENAME=$($latestBackups[0])" >> $env:GITHUB_ENV
"XBK_DATABASE_BACKUP_FILENAME=$($latestBackups[1])" >> $env:GITHUB_ENV

- name: Extract Database Backup
run: |
Expand-Archive `
-Path "./database/${{ env.K13_DATABASE_BACKUP_FILENAME }}.zip" `
-DestinationPath "./database"
Expand-Archive `
-Path "./database/${{ env.XBK_DATABASE_BACKUP_FILENAME }}.zip" `
-DestinationPath "./database"

- name: Install a SQL Server suite of tools (SQLEngine, SQLPackage)
uses: potatoqualitee/mssqlsuite@9a0136e208df60b8ecb62909f076bc34854fa55a # set as a commit hash for security - v1.7
with:
install: sqlpackage, sqlengine
sa-password: Pass@12345
version: 2022

- name: Restore Database .bak
run: |
docker exec sql mkdir /var/opt/mssql/backup
docker cp "./database/${{ env.K13_DATABASE_BACKUP_FILENAME }}" sql:/var/opt/mssql/backup
sqlcmd `
-S localhost `
-d master `
-U "sa" `
-P "Pass@12345" `
-Q "RESTORE DATABASE [Kentico13_DancingGoat] FROM DISK='/var/opt/mssql/backup/${{ env.K13_DATABASE_BACKUP_FILENAME }}' WITH MOVE 'Kentico13_DancingGoat' TO '/var/opt/mssql/data/Kentico13_DancingGoat.mdf', MOVE 'Kentico13_DancingGoat_log' TO '/var/opt/mssql/data/Kentico13_DancingGoat_log.ldf'"
docker cp "./database/${{ env.XBK_DATABASE_BACKUP_FILENAME }}" sql:/var/opt/mssql/backup
sqlcmd `
-S localhost `
-d master `
-U "sa" `
-P "Pass@12345" `
-Q "RESTORE DATABASE [XByK_DancingGoat_K13Ecommerce] FROM DISK='/var/opt/mssql/backup/${{ env.XBK_DATABASE_BACKUP_FILENAME }}' WITH MOVE 'XByK_DancingGoat_K13Ecommerce' TO '/var/opt/mssql/data/XByK_DancingGoat_K13Ecommerce.mdf', MOVE 'XByK_DancingGoat_K13Ecommerce_log' TO '/var/opt/mssql/data/XByK_DancingGoat_K13Ecommerce_log.ldf'"

- name: Imports license key to DB
run: |
sqlcmd `
-S localhost `
-d Kentico13_DancingGoat `
-U "sa" `
-P "Pass@12345" `
-Q "INSERT INTO [dbo].[CMS_LicenseKey] VALUES ('localhost', '${{ env.KENTICO_XPERIENCE_13_LICENSE }}', 'X', '10/20/2025', 1);"
sqlcmd `
-S localhost `
-d XByK_DancingGoat_K13Ecommerce `
-U "sa" `
-P "Pass@12345" `
-Q "UPDATE CMS_SettingsKey SET KeyValue='${{ env.XPERIENCE_BY_KENTICO_LICENSE }}' WHERE KeyName='CMSLicenseKey'"

- name: Reset DB consistency for last applied hotfix
run: |
dotnet build `
--configuration Release
cd scripts
./Reset-DatabaseConsistency.ps1
cd ..

- name: Build Solution for last hotfix
run: |
dotnet build `
--configuration Release `
-p:XbyKVersion=*
cd scripts
./Reset-DatabaseConsistency.ps1 -ExcludeCIRestore
cd ..

- name: Publish Application
run: |
dotnet publish `
./examples/Kentico13_DancingGoatStore `
-c Release `
-o ./publish/K13 `
--no-build `
--no-restore
dotnet publish `
./examples/DancingGoat-K13Ecommerce `
-c Release `
-o ./publish/XbK `
--no-build `
--no-restore

- name: Test Solution
run: |
dotnet test `
--filter TestCategory!~Integration `
--configuration Release `
--no-build `
--no-restore

- name: Run Applications and E2E Tests
run: |
# Run the ASP.NET Core app as a background job
cd ./publish/K13
Start-Job -ScriptBlock { dotnet ./${{ env.K13_PROJECT_NAME }}.dll } -Name ${{ env.K13_PROJECT_NAME }}
Receive-Job -Name ${{ env.K13_PROJECT_NAME }}
cd ../../

# The ASP.NET Core app can take a few seconds to start, so we delay running tests
# until it is ready, and fail if we go over a maximum wait time
$limit = 30
$attempts = 0
$success = $false

while ($attempts -lt $limit -and -not $success) {
Start-Sleep -Seconds 1
try {
$response = Invoke-WebRequest -Uri ${{ env.K13_STATUS_CHECK_URL }} -Method Get -SkipCertificateCheck
if ($response.StatusCode -eq 200) {
Write-Output "K13 store: Application is ready."
$success = $true
}
}
catch {
Write-Output "Attempt $attempts - Application not ready yet."
}
$attempts++
}

if (-not $success) {
Write-Output "K13 store: Application did not respond in time."
exit 1
}

# Run the ASP.NET Core app as a background job
cd ./publish/XbK
Start-Job -ScriptBlock { dotnet ./${{ env.XBK_PROJECT_NAME }}.dll } -Name ${{ env.XBK_PROJECT_NAME }}
Receive-Job -Name ${{ env.XBK_PROJECT_NAME }}
cd ../../

# The ASP.NET Core app can take a few seconds to start, so we delay running tests
# until it is ready, and fail if we go over a maximum wait time
$limit = 30
$attempts = 0
$success = $false

while ($attempts -lt $limit -and -not $success) {
Start-Sleep -Seconds 1
try {
$response = Invoke-WebRequest -Uri ${{ env.XBK_STATUS_CHECK_URL }} -Method Get -SkipCertificateCheck
if ($response.StatusCode -eq 200) {
Write-Output "XbK Application is ready."
$success = $true
}
}
catch {
Write-Output "Attempt $attempts - Application not ready yet."
}
$attempts++
}

if (-not $success) {
Write-Output "XbK Application did not respond in time."
exit 1
}

# Sleep for finishing initialization
Start-Sleep -Seconds 10

# Run the E2E tests
cd test/Playwright
npx playwright test
cd ../..

# Stop the background ASP.NET Core application
Receive-Job -Name ${{ env.K13_PROJECT_NAME }}
Stop-Job -Name ${{ env.K13_PROJECT_NAME }}
Remove-Job -Name ${{ env.K13_PROJECT_NAME }}
Receive-Job -Name ${{ env.XBK_PROJECT_NAME }}
Stop-Job -Name ${{ env.XBK_PROJECT_NAME }}
Remove-Job -Name ${{ env.XBK_PROJECT_NAME }}

- uses: actions/upload-artifact@v4
with:
name: playwright-report
path: ./test/Playwright/playwright-report/
retention-days: 30
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,6 @@ segments_2i
**/App_Data/CMSModules/SmartSearch/*
/examples/DancingGoat-Shopify/assets/ContentItems
/examples/DancingGoat-K13Ecommerce/assets/ContentItems

# Databases backup
/database/*.bak
15 changes: 9 additions & 6 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageVersionOverrideEnabled>false</CentralPackageVersionOverrideEnabled>
<CentralPackageVersionOverrideEnabled>true</CentralPackageVersionOverrideEnabled>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<DisableImplicitNuGetFallbackFolder>true</DisableImplicitNuGetFallbackFolder>
<CentralPackageFloatingVersionsEnabled>true</CentralPackageFloatingVersionsEnabled>
<LastAppliedHotfix>29.5.3</LastAppliedHotfix>
<XbyKVersion Condition="'$(XbyKVersion)' == ''">$(LastAppliedHotfix)</XbyKVersion>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Duende.AccessTokenManagement.OpenIdConnect" Version="3.0.0" />
<PackageVersion Include="Kentico.Xperience.Admin" Version="29.5.3" />
<PackageVersion Include="Kentico.Xperience.WebApp" Version="29.5.3" />
<PackageVersion Include="kentico.xperience.azurestorage" Version="29.5.3" />
<PackageVersion Include="kentico.xperience.imageprocessing" Version="29.5.3" />
<PackageVersion Include="Kentico.Xperience.Core" Version="29.5.3" />
<PackageVersion Include="Kentico.Xperience.Admin" Version="$(LastAppliedHotfix)" />
<PackageVersion Include="Kentico.Xperience.WebApp" Version="$(LastAppliedHotfix)" />
<PackageVersion Include="kentico.xperience.azurestorage" Version="$(LastAppliedHotfix)" />
<PackageVersion Include="kentico.xperience.imageprocessing" Version="$(LastAppliedHotfix)" />
<PackageVersion Include="Kentico.Xperience.Core" Version="$(LastAppliedHotfix)" />
<PackageVersion Include="Scrutor" Version="4.2.2" />
<PackageVersion Include="Microsoft.Extensions.ApiDescription.Client" Version="8.0.8" />
<PackageVersion Include="NSwag.ApiDescription.Client" Version="14.1.0" />
Expand Down
Binary file added database/2024_10_21_Kentico13_DancingGoat.bak.zip
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions database/backups.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
2024_10_21_Kentico13_DancingGoat.bak
2024_11_04_XByK_DancingGoat_K13Ecommerce.bak
Loading