Skip to content

Commit

Permalink
Merge pull request #827 from Lombiq/issue/OFFI-56
Browse files Browse the repository at this point in the history
OFFI-56: Fixing Elasticsearch setup workflow
  • Loading branch information
wAsnk authored Jul 30, 2024
2 parents 88b166c + f6f852c commit c35551e
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 4 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/build-and-test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ jobs:
dotnet-test-process-timeout: 720000
# Running ZAP for security scans in Docker under GHA Windows runners won't work since such virtualization is not
# supported by GHA.
test-filter: FullyQualifiedName!~SecurityScanningTests
# The currently used Elasticsearch setup action (https://github.com/elastic/elastic-github-actions/tree/master/elasticsearch)
# can only be used on Linux.
test-filter: FullyQualifiedName!~SecurityScanningTests&FullyQualifiedName!~BehaviorElasticsearchTests

build-and-test-standard-runners:
if: github.ref_name == github.event.repository.default_branch
Expand All @@ -64,7 +66,9 @@ jobs:
dotnet-test-process-timeout: 840000
# Running ZAP for security scans in Docker under GHA Windows runners won't work since such virtualization is not
# supported by GHA.
test-filter: FullyQualifiedName!~SecurityScanningTests
# The currently used Elasticsearch setup action (https://github.com/elastic/elastic-github-actions/tree/master/elasticsearch)
# can only be used on Linux.
test-filter: FullyQualifiedName!~SecurityScanningTests&FullyQualifiedName!~BehaviorElasticsearchTests

build-and-test-nuget-test:
if: github.ref_name == github.event.repository.default_branch ||
Expand All @@ -81,10 +85,12 @@ jobs:
dotnet-test-process-timeout: 540000
# Running ZAP for security scans in Docker under GHA Windows runners won't work since such virtualization is not
# supported by GHA.
# The currently used Elasticsearch setup action (https://github.com/elastic/elastic-github-actions/tree/master/elasticsearch)
# can only be used on Linux.
# Without quotes, somehow the value won't be passed properly and the test execution will hang, despite seemingly
# every value being the same as with quotes.
# yamllint disable-line rule:quoted-strings
test-filter: 'FullyQualifiedName!~SecurityScanningTests'
test-filter: 'FullyQualifiedName!~SecurityScanningTests&FullyQualifiedName!~BehaviorElasticsearchTests'

powershell-static-code-analysis:
if: github.ref_name == github.event.repository.default_branch ||
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
timeout-minutes: 30
set-up-sql-server: 'true'
set-up-azurite: 'true'
set-up-elasticsearch: 'true'
build-create-binary-log: 'true'
dotnet-test-process-timeout: 600000
build-enable-nuget-caching: 'true'
Expand All @@ -36,6 +37,7 @@ jobs:
timeout-minutes: 50
set-up-sql-server: 'true'
set-up-azurite: 'true'
set-up-elasticsearch: 'true'
build-create-binary-log: 'true'
dotnet-test-process-timeout: 780000
# Temporarily not running Edge tests on the Linux runners until
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"name": "Lombiq.OSOCE.Tests.Elasticsearch",
"displayName": "TEST: Elasticsearch Configuration",
"description": "Elasticsearch Configuration setup recipe for automated UI test execution.",
"author": "Lombiq Technologies",
"website": "https://github.com/Lombiq/Open-Source-Orchard-Core-Extensions",
"version": "1.0",
"issetuprecipe": true,
"categories": [
"test",
"elasticsearch"
],
"tags": [
"test",
"elasticsearch"
],
"steps": [
{
"name": "feature",
"disable": [],
"enable": [
"OrchardCore.Search.Elasticsearch",
"OrchardCore.Search"
]
},
{
"name": "ElasticIndexSettings",
"Indices": [
{
"blogposts": {
"AnalyzerName": "standard",
"IndexLatest": false,
"IndexedContentTypes": [
"BlogPost"
],
"Culture": "any",
"StoreSourceData": true
}
}
]
},
{
"name": "Settings",
"ElasticSettings": {
"SearchIndex": "blogposts",
"DefaultSearchFields": [
"Content.ContentItem.FullText"
],
"AllowElasticQueryStringQueryInSearch": false
}
},
{
"name": "Queries",
"Queries": [
{
"Index": "blogposts",
"Template": "{\r\n \"size\": 1000,\r\n \"query\":{\r\n \"term\":{\r\n \"Content.ContentItem.ContentType\":\"BlogPost\"\r\n }\r\n },\r\n \"fields\": [\r\n \"ContentItemId\", \"ContentItemVersionId\"\r\n ],\r\n \"sort\": [\r\n\t{\"Content.ContentItem.DisplayText.keyword\": {\"order\": \"asc\"}}\r\n ],\r\n \"_source\": true\r\n}",
"ReturnContentItems": false,
"Name": "Blog Posts",
"Source": "Elasticsearch",
"Schema": "{ \"type\": \"ContentItem/BlogPost\" }"
}
]
},
{
"name": "recipes",
"Values": [
{
"executionid": "Lombiq.OSOCE.Web",
"name": "Lombiq.OSOCE.Tests"
}
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@
{
"name": "themes",
"admin": "TheAdmin",
"site": "SafeMode"
"site": "SafeMode"
},
{
"name": "FeatureProfiles",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using Atata;
using Lombiq.Tests.UI.Extensions;
using Lombiq.Tests.UI.Helpers;
using Lombiq.Tests.UI.Pages;
using OpenQA.Selenium;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;

namespace Lombiq.OSOCE.Tests.UI.Tests.ModuleTests;

public class BehaviorElasticsearchTests : UITestBase
{
public BehaviorElasticsearchTests(ITestOutputHelper testOutputHelper)
: base(testOutputHelper)
{
}

[Fact]
public Task ElasticsearchSearchingShouldWork() =>
ExecuteTestAsync(
async context =>
{
await context.SignInDirectlyAndGoToRelativeUrlAsync("/search");

await context.ClickAndFillInWithRetriesAsync(By.Name("Terms"), "man");
await context.ClickReliablyOnAsync(By.XPath("//button[@class='btn btn-primary btn-sm']"));

context.Exists(By.XPath("//h2[contains(., 'Man must explore, and this is exploration at its greatest')]"));
},
setupOperation: async context =>
{
var homepageUri = await context.GoToSetupPageAndSetupOrchardCoreAsync(
new OrchardCoreSetupParameters(context)
{
SiteName = "Lombiq's OSOCE - UI Testing - Elasticsearch",
RecipeId = "Lombiq.OSOCE.Tests.Elasticsearch",
TablePrefix = "OSOCE",
SiteTimeZoneValue = "Europe/Budapest",
});

try
{
context.Exists(By.Id("navbar"));
}
catch (NoSuchElementException)
{
var validationErrors = context.GetAll(By.ClassName("field-validation-error"));

if (validationErrors.Count == 0) throw;

var errors = "\n- " + validationErrors.Select(element => element.Text.Trim()).Join("\n- ");
throw new AssertionException($"Setup has failed with the following validation errors:{errors}");
}

return homepageUri;
},
changeConfigurationAsync: ConfigurationHelper.DisableHtmlValidation);
}

0 comments on commit c35551e

Please sign in to comment.