Skip to content

Commit

Permalink
Switch to Testcontainers
Browse files Browse the repository at this point in the history
- Easier to run and debug integration tests
- No scripts to maintain
- Bit slower because it's one/two containers per test assembly but otherwise better control over lifetime
  • Loading branch information
mausch committed Nov 6, 2023
1 parent 7361207 commit 6fea424
Show file tree
Hide file tree
Showing 37 changed files with 5,873 additions and 369 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/solrnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
run: ./integration_tests.sh
env:
SOLR_VERSION: ${{ matrix.solr_version }}
timeout-minutes: 5
timeout-minutes: 7
- uses: actions/upload-artifact@v3
with:
name: test-results ${{ matrix.solr_version }}
Expand Down
7 changes: 4 additions & 3 deletions AutofacContrib.SolrNet.Tests/AutofacIntegrationFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections.Generic;
using Autofac;
using SolrNet;
using SolrNet.Tests.Common;
using Xunit;
using Xunit.Abstractions;

Expand All @@ -21,7 +22,7 @@ public AutofacIntegrationFixture(ITestOutputHelper testOutputHelper)
public void Ping_And_Query()
{
var builder = new ContainerBuilder();
builder.RegisterModule(new SolrNetModule("http://localhost:8983/solr/techproducts"));
builder.RegisterModule(new SolrNetModule($"{TestContainers.BaseUrl}solr/techproducts"));
var container = builder.Build();
var solr = container.Resolve<ISolrOperations<AutofacFixture.Entity>>();
solr.Ping();
Expand All @@ -32,7 +33,7 @@ public void Ping_And_Query()
public void DictionaryDocument()
{
var builder = new ContainerBuilder();
builder.RegisterModule(new SolrNetModule("http://localhost:8983/solr/techproducts"));
builder.RegisterModule(new SolrNetModule($"{TestContainers.BaseUrl}solr/techproducts"));
var container = builder.Build();
var solr = container.Resolve<ISolrOperations<Dictionary<string, object>>>();
var results = solr.Query(SolrQuery.All);
Expand All @@ -49,7 +50,7 @@ public void DictionaryDocument()
public void DictionaryDocument_add()
{
var builder = new ContainerBuilder();
builder.RegisterModule(new SolrNetModule("http://localhost:8983/solr/techproducts"));
builder.RegisterModule(new SolrNetModule($"{TestContainers.BaseUrl}solr/techproducts"));
var container = builder.Build();
var solr = container.Resolve<ISolrOperations<Dictionary<string, object>>>();
solr.Add(new Dictionary<string, object> {
Expand Down
108 changes: 90 additions & 18 deletions AutofacContrib.SolrNet.Tests/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@
"System.ComponentModel": "4.0.1"
}
},
"BouncyCastle.Cryptography": {
"type": "Transitive",
"resolved": "2.2.1",
"contentHash": "A6Zr52zVqJKt18ZBsTnX0qhG0kwIQftVAjLmszmkiR/trSp8H+xj1gUOzk7XHwaKgyREMSV1v9XaKrBUeIOdvQ=="
},
"Castle.Core": {
"type": "Transitive",
"resolved": "4.2.1",
Expand Down Expand Up @@ -99,6 +104,24 @@
"Microsoft.NETCore.App": "1.0.5"
}
},
"Docker.DotNet": {
"type": "Transitive",
"resolved": "3.125.15",
"contentHash": "XN8FKxVv8Mjmwu104/Hl9lM61pLY675s70gzwSj8KR5pwblo8HfWLcCuinh9kYsqujBkMH4HVRCEcRuU6al4BQ==",
"dependencies": {
"Newtonsoft.Json": "13.0.1",
"System.Buffers": "4.5.1",
"System.Threading.Tasks.Extensions": "4.5.4"
}
},
"Docker.DotNet.X509": {
"type": "Transitive",
"resolved": "3.125.15",
"contentHash": "ONQN7ImrL3tHStUUCCPHwrFFQVpIpE+7L6jaDAMwSF+yTEmeWBmRARQZDRuvfj/+WtB8RR0oTW0tT3qQMSyHOw==",
"dependencies": {
"Docker.DotNet": "3.125.15"
}
},
"Libuv": {
"type": "Transitive",
"resolved": "1.9.1",
Expand All @@ -107,6 +130,11 @@
"Microsoft.NETCore.Platforms": "1.0.1"
}
},
"Microsoft.Bcl.AsyncInterfaces": {
"type": "Transitive",
"resolved": "6.0.0",
"contentHash": "UcSjPsst+DfAdJGVDsu346FX0ci0ah+lw3WRtn18NUwEqRt70HaOQ7lI72vy3+1LxtqI3T5GWwV39rQSrCzAeg=="
},
"Microsoft.CodeAnalysis.Analyzers": {
"type": "Transitive",
"resolved": "1.1.0",
Expand Down Expand Up @@ -276,6 +304,11 @@
"resolved": "2.0.0",
"contentHash": "UC87vRDUB7/vSaNY/FVhbdAyRkfFBTkYmcUoglxk6TyTojhSqYaG5pZsoP4e1ZuXktFXJXJBTvK8U/QwCo0z3g=="
},
"Microsoft.Extensions.Logging.Abstractions": {
"type": "Transitive",
"resolved": "6.0.4",
"contentHash": "K14wYgwOfKVELrUh5eBqlC8Wvo9vvhS3ZhIvcswV2uS/ubkTRPSQsN557EZiYUSSoZNxizG+alN4wjtdyLdcyw=="
},
"Microsoft.Extensions.Primitives": {
"type": "Transitive",
"resolved": "2.0.0",
Expand Down Expand Up @@ -645,6 +678,24 @@
"resolved": "4.3.0",
"contentHash": "VB5cn/7OzUfzdnC8tqAIMQciVLiq2epm2NrAm1E9OjNRyG4lVhfR61SMcLizejzQP8R8Uf/0l5qOIbUEi+RdEg=="
},
"SharpZipLib": {
"type": "Transitive",
"resolved": "1.4.2",
"contentHash": "yjj+3zgz8zgXpiiC3ZdF/iyTBbz2fFvMxZFEBPUcwZjIvXOf37Ylm+K58hqMfIBt5JgU/Z2uoUS67JmTLe973A=="
},
"SSH.NET": {
"type": "Transitive",
"resolved": "2020.0.2",
"contentHash": "G0dNlTBAM00KZXv1wWVwgg26d9/METcM6qWBpNQwllzQmmbu+Zu+FS1L1X4fFgGdPu3e8k9mmTBu6SwtQ0614g==",
"dependencies": {
"SshNet.Security.Cryptography": "[1.3.0]"
}
},
"SshNet.Security.Cryptography": {
"type": "Transitive",
"resolved": "1.3.0",
"contentHash": "5pBIXRjcSO/amY8WztpmNOhaaCNHY/B6CcYDI7FSTgqSyo/ZUojlLiKcsl+YGbxQuLX439qIkMfP0PHqxqJi/Q=="
},
"System.AppContext": {
"type": "Transitive",
"resolved": "4.3.0",
Expand All @@ -655,15 +706,8 @@
},
"System.Buffers": {
"type": "Transitive",
"resolved": "4.3.0",
"contentHash": "ratu44uTIHgeBeI0dE8DWvmXVBSo4u7ozRZZHOMmK/JPpYyo0dAfgSiHlpiObMQ5lEtEyIXA40sKRYg5J6A8uQ==",
"dependencies": {
"System.Diagnostics.Debug": "4.3.0",
"System.Diagnostics.Tracing": "4.3.0",
"System.Resources.ResourceManager": "4.3.0",
"System.Runtime": "4.3.0",
"System.Threading": "4.3.0"
}
"resolved": "4.5.1",
"contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg=="
},
"System.Collections": {
"type": "Transitive",
Expand Down Expand Up @@ -1488,8 +1532,8 @@
},
"System.Runtime.CompilerServices.Unsafe": {
"type": "Transitive",
"resolved": "4.4.0",
"contentHash": "9dLLuBxr5GNmOfl2jSMcsHuteEg32BEfUotmmUkmZjpR3RpVHE8YQwt0ow3p6prwA1ME8WqDVZqrr8z6H8G+Kw=="
"resolved": "6.0.0",
"contentHash": "/iUeP3tq1S0XdNNoMz5C9twLSrM/TH+qElHkXWaPvuNOt+99G75NrV0OS2EqHx5wMN7popYjpc8oTjC1y16DLg=="
},
"System.Runtime.Extensions": {
"type": "Transitive",
Expand Down Expand Up @@ -1814,6 +1858,23 @@
"System.Text.Encoding": "4.3.0"
}
},
"System.Text.Encodings.Web": {
"type": "Transitive",
"resolved": "6.0.0",
"contentHash": "Vg8eB5Tawm1IFqj4TVK1czJX89rhFxJo9ELqc/Eiq0eXy13RK00eubyU6TJE6y+GQXjyV5gSfiewDUZjQgSE0w==",
"dependencies": {
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
}
},
"System.Text.Json": {
"type": "Transitive",
"resolved": "6.0.8",
"contentHash": "WhW6zPEgRZoo+c1NEvSSmrME4+LqXmW6tcsRFsEiSMeco+qZ9rpLs7tT53EIkE/s9GNTYS4/STQoaGiKDSWifQ==",
"dependencies": {
"System.Runtime.CompilerServices.Unsafe": "6.0.0",
"System.Text.Encodings.Web": "6.0.0"
}
},
"System.Text.RegularExpressions": {
"type": "Transitive",
"resolved": "4.3.0",
Expand Down Expand Up @@ -1872,13 +1933,8 @@
},
"System.Threading.Tasks.Extensions": {
"type": "Transitive",
"resolved": "4.3.0",
"contentHash": "npvJkVKl5rKXrtl1Kkm6OhOUaYGEiF9wFbppFRWSMoApKzt2PiPHT2Bb8a5sAWxprvdOAtvaARS9QYMznEUtug==",
"dependencies": {
"System.Collections": "4.3.0",
"System.Runtime": "4.3.0",
"System.Threading.Tasks": "4.3.0"
}
"resolved": "4.5.4",
"contentHash": "zteT+G8xuGu6mS+mzDzYXbzS7rd3K6Fjb9RiZlYlJPam2/hU7JCBZBVEcywNuR+oZ1ncTvc/cq0faRr3P01OVg=="
},
"System.Threading.Tasks.Parallel": {
"type": "Transitive",
Expand Down Expand Up @@ -2020,6 +2076,21 @@
"System.Xml.XPath": "4.0.1"
}
},
"Testcontainers": {
"type": "Transitive",
"resolved": "3.5.0",
"contentHash": "UYMCZ778ZjjHPZtr5VpemtI8kjkchFJf+taoH4fUwuzBXbWm+0VgAfBTzOIfrKSVBCKqG0gPm5PSOU8eAhFTpg==",
"dependencies": {
"BouncyCastle.Cryptography": "2.2.1",
"Docker.DotNet": "3.125.15",
"Docker.DotNet.X509": "3.125.15",
"Microsoft.Bcl.AsyncInterfaces": "6.0.0",
"Microsoft.Extensions.Logging.Abstractions": "6.0.4",
"SSH.NET": "2020.0.2",
"SharpZipLib": "1.4.2",
"System.Text.Json": "6.0.8"
}
},
"xunit.abstractions": {
"type": "Transitive",
"resolved": "2.0.3",
Expand Down Expand Up @@ -2086,6 +2157,7 @@
"Castle.Windsor": "[4.1.0, )",
"CommonServiceLocator": "[2.0.2, )",
"SolrNet.Core": "[1.0.20, )",
"Testcontainers": "[3.5.0, )",
"xunit.assert": "[2.4.1, )"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Castle.Windsor;
using Xunit;
using SolrNet;
using SolrNet.Tests.Common;
using Xunit.Abstractions;

namespace Castle.Facilities.SolrNetIntegration.Tests {
Expand All @@ -23,7 +24,7 @@ public void Ping_Query()
var configStore = new DefaultConfigurationStore();
var configuration = new MutableConfiguration("facility");
configuration.Attribute("type", typeof(SolrNetFacility).AssemblyQualifiedName);
configuration.CreateChild("solrURL", "http://localhost:8983/solr/techproducts");
configuration.CreateChild("solrURL", $"{TestContainers.BaseUrl}solr/techproducts");
configStore.AddFacilityConfiguration(typeof(SolrNetFacility).FullName, configuration);
var container = new WindsorContainer(configStore);

Expand All @@ -35,7 +36,7 @@ public void Ping_Query()
[Fact]
public void DictionaryDocument()
{
var solrFacility = new SolrNetFacility("http://localhost:8983/solr/techproducts");
var solrFacility = new SolrNetFacility($"{TestContainers.BaseUrl}solr/techproducts");
var container = new WindsorContainer();
container.AddFacility(solrFacility);
var solr = container.Resolve<ISolrOperations<Dictionary<string, object>>>();
Expand All @@ -52,7 +53,7 @@ public void DictionaryDocument()
[Fact]
public void DictionaryDocument_add()
{
var solrFacility = new SolrNetFacility("http://localhost:8983/solr/techproducts");
var solrFacility = new SolrNetFacility($"{TestContainers.BaseUrl}solr/techproducts");
var container = new WindsorContainer();
container.AddFacility(solrFacility);
var solr = container.Resolve<ISolrOperations<Dictionary<string, object>>>();
Expand Down
Loading

0 comments on commit 6fea424

Please sign in to comment.