Skip to content

Commit

Permalink
Merge branch 'develop' into feature/netcore3-update
Browse files Browse the repository at this point in the history
  • Loading branch information
rasmus authored Dec 9, 2019
2 parents da0dcae + fcf6f78 commit 525eaa9
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 37 deletions.
47 changes: 28 additions & 19 deletions Source/EventFlow.TestHelpers/MsSql/MsSqlHelpz.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// The MIT License (MIT)
//
// Copyright (c) 2015-2018 Rasmus Mikkelsen
// Copyright (c) 2015-2018 eBay Software Foundation
// Copyright (c) 2015-2019 Rasmus Mikkelsen
// Copyright (c) 2015-2019 eBay Software Foundation
// https://github.com/eventflow/EventFlow
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
Expand All @@ -22,7 +22,8 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;

namespace EventFlow.TestHelpers.MsSql
{
Expand All @@ -43,28 +44,36 @@ public static MsSqlConnectionString CreateConnectionString(string label)
{
var databaseName = $"{label}_{DateTime.Now:yyyy-MM-dd-HH-mm}_{Guid.NewGuid():N}";

var connectionstringParts = new List<string>
var connectionStringBuilder = new SqlConnectionStringBuilder()
{
$"Database={databaseName}"
InitialCatalog = databaseName,
DataSource = FirstNonEmpty(
Environment.GetEnvironmentVariable("EVENTFLOW_MSSQL_SERVER"),
".")
};

var environmentServer = Environment.GetEnvironmentVariable("HELPZ_MSSQL_SERVER");
var environmentPassword = Environment.GetEnvironmentVariable("HELPZ_MSSQL_PASS");
var envrionmentUsername = Environment.GetEnvironmentVariable("HELPZ_MSSQL_USER");
var password = Environment.GetEnvironmentVariable("EVENTFLOW_MSSQL_PASS");
var username = Environment.GetEnvironmentVariable("EVENTFLOW_MSSQL_USER");

connectionstringParts.Add(string.IsNullOrEmpty(environmentServer)
? @"Server=."
: $"Server={environmentServer}");
connectionstringParts.Add(string.IsNullOrEmpty(envrionmentUsername)
? @"Integrated Security=True"
: $"User Id={envrionmentUsername}");
connectionstringParts.Add("Connection Timeout=60");
if (!string.IsNullOrEmpty(environmentPassword))
if (!string.IsNullOrEmpty(username) &&
!string.IsNullOrEmpty(password))
{
connectionstringParts.Add($"Password={environmentPassword}");
connectionStringBuilder.UserID = username;
connectionStringBuilder.Password = password;
}
else
{
connectionStringBuilder.IntegratedSecurity = true;
}

Console.WriteLine($"Using connection string for tests: {connectionStringBuilder.ConnectionString}");

return new MsSqlConnectionString(string.Join(";", connectionstringParts));
return new MsSqlConnectionString(connectionStringBuilder.ConnectionString);
}

private static string FirstNonEmpty(params string[] parts)
{
return parts.First(s => !string.IsNullOrEmpty(s));
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// The MIT License (MIT)
//
// Copyright (c) 2015-2018 Rasmus Mikkelsen
// Copyright (c) 2015-2018 eBay Software Foundation
// Copyright (c) 2015-2019 Rasmus Mikkelsen
// Copyright (c) 2015-2019 eBay Software Foundation
// https://github.com/eventflow/EventFlow
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
Expand Down Expand Up @@ -35,14 +35,17 @@
using FluentAssertions;
using NUnit.Framework;

// ReSharper disable ClassNeverInstantiated.Local

namespace EventFlow.Tests.IntegrationTests.ReadStores
{
[Category(Categories.Integration)]
public class MultipleAggregateReadStoreManagerTests : IntegrationTest
{
private const string ReadModeld = "the one";
private const string ReadModelId = "the one";

[Test]
[Ignore("Test unstable, issue #710")]
public async Task EventOrdering()
{
// Repopulating read models that span multiple aggregates should have their events
Expand All @@ -62,7 +65,10 @@ public async Task EventOrdering()
await ReadModelPopulator.PopulateAsync(typeof(ReadModelAB), CancellationToken.None);

// Assert
var readModelAb = await QueryProcessor.ProcessAsync(new ReadModelByIdQuery<ReadModelAB>(ReadModeld), CancellationToken.None);
var readModelAb = await QueryProcessor.ProcessAsync(
new ReadModelByIdQuery<ReadModelAB>(ReadModelId),
CancellationToken.None);

readModelAb.Indexes.Should().BeEquivalentTo(
new []{0, 1, 2, 3},
o => o.WithStrictOrdering());
Expand Down Expand Up @@ -175,7 +181,7 @@ private class ReadModelLocatorAB : IReadModelLocator
{
public IEnumerable<string> GetReadModelIds(IDomainEvent domainEvent)
{
return new[] {ReadModeld};
return new[] {ReadModelId};
}
}

Expand All @@ -184,7 +190,7 @@ private class ReadModelAB : IReadModel,
IAmReadModelFor<AggregateB, IdB, EventB>
{
private readonly List<int> _indexes = new List<int>();
public IReadOnlyCollection<int> Indexes => _indexes;
public IEnumerable<int> Indexes => _indexes;

public void Apply(IReadModelContext context, IDomainEvent<AggregateA, IdA, EventA> domainEvent)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// The MIT License (MIT)
//
// Copyright (c) 2015-2018 Rasmus Mikkelsen
// Copyright (c) 2015-2018 eBay Software Foundation
// Copyright (c) 2015-2019 Rasmus Mikkelsen
// Copyright (c) 2015-2019 eBay Software Foundation
// https://github.com/eventflow/EventFlow
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
Expand Down Expand Up @@ -130,6 +130,7 @@ public Task<AllCommittedEventsPage> LoadAllCommittedEvents(
var committedDomainEvents = _eventStore
.SelectMany(kv => kv.Value)
.Where(e => e.GlobalSequenceNumber >= startPosition)
.OrderBy(e => e.GlobalSequenceNumber)
.Take(pageSize)
.ToList();

Expand Down Expand Up @@ -166,7 +167,7 @@ public async Task<IReadOnlyCollection<ICommittedDomainEvent>> CommitEventsAsync(
Metadata = e.SerializedMetadata,
GlobalSequenceNumber = globalCount + i + 1,
};
_log.Verbose("Committing event {0}{1}", Environment.NewLine, committedDomainEvent.ToString());
_log.Verbose("Committing event {0}{1}", Environment.NewLine, committedDomainEvent);
return committedDomainEvent;
})
.ToList();
Expand All @@ -181,7 +182,7 @@ public async Task<IReadOnlyCollection<ICommittedDomainEvent>> CommitEventsAsync(

if (updateResult.Last != lastEvent)
{
throw new OptimisticConcurrencyException("");
throw new OptimisticConcurrencyException(string.Empty);
}

return newCommittedDomainEvents;
Expand Down
13 changes: 8 additions & 5 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,33 @@ init:
- ps: git config --global core.autocrlf input
- ps: '[Environment]::SetEnvironmentVariable("LCOW_SUPPORTED", "1", "Machine")'
- ps: Restart-Service docker

version: 0.77.{build}

skip_tags: true

build_script:
- cmd: powershell -NoProfile -ExecutionPolicy unrestricted -Command ".\up_integration-test-env.ps1; .\build.ps1 --bootstrap; .\build.ps1 -Target All;"

# https://www.appveyor.com/docs/services-databases/
# https://www.appveyor.com/docs/windows-images-software/

image: Visual Studio 2019

environment:
HELPZ_POSTGRESQL_PASS: Password12!
HELPZ_MSSQL_SERVER: (local)\SQL2017
HELPZ_MSSQL_USER: sa
HELPZ_MSSQL_PASS: Password12!
EVENTFLOW_MSSQL_SERVER: (local)\SQL2017
EVENTFLOW_MSSQL_USER: sa
EVENTFLOW_MSSQL_PASS: Password12!

test: off

artifacts:
- path: Build\Packages\*nupkg

services:
- postgresql101
- mssql2017
- postgresql101

on_success:
- choco install codecov
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ services:
mem_limit: 4g

eventstore:
image: eventstore/eventstore
image: eventstore/eventstore:release-4.1.3
container_name: eventstore-ef
ports:
- "1113:1113"
Expand Down
4 changes: 2 additions & 2 deletions up_integration-test-env.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ $env:ELASTICSEARCH_URL = "http://localhost:9200"
# Event Store
$env:EVENTSTORE_URL = "tcp://admin:changeit@localhost:1113"

# Helth check
# Health checks
# Event Store
curl --connect-timeout 60 --retry 5 -sL "http://localhost:2113"
# Elasticsearch
curl --connect-timeout 60 --retry 5 -sL "http://localhost:9200"
# RabbitMQ
curl --connect-timeout 60 --retry 5 -sL "http://localhost:15672"
curl --connect-timeout 60 --retry 5 -sL "http://localhost:15672"

0 comments on commit 525eaa9

Please sign in to comment.