Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Toxantron committed Feb 10, 2023
2 parents da96b6b + c985e9d commit b067df8
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 7 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.7.1
3.7.2
55 changes: 53 additions & 2 deletions docs/tutorials/Log4Net.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ In this tutorial log4net will be added to an existing project.
This file have to be set to **copy to your output directory** (Properties -> Copy to output directory -> Copy always).

This configuration will configure log4net with a rolling file appender. You can find other appender configurations in the [log4net documentation](https://logging.apache.org/log4net/release/config-examples.html).
4. Add an additional config section and configuration to your `app.config` of your start project:
4. (Without Asp-Net Core) Add an additional config section and configuration to your `app.config` of your start project:
````xml
<?xml version="1.0" encoding="utf-8"?>
<configuration>
Expand All @@ -60,4 +60,55 @@ In this tutorial log4net will be added to an existing project.
````

This will configure the common logging adapter to load the previously added config file.
5. Test your configuration after a rebuild
5. (With Asp-Net Core) Add an additional entry to your 'appsettings.json':
```json
"LogConfiguration": {
"factoryAdapter": {
"type": "Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net208",
"arguments": {
"configType": "FILE-WATCH",
"configFile": "Config/log4net.config"
}
}
},
```
6. (With Asp-Net Core) Add code to load the configuration to your `Program.cs` between the HeartOfGold ctor and the 'Load()' call.
```cs
// MORYX modifies current directory
var moryxRuntime = new HeartOfGold(args);

// Configure Logging with log4net:
var config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.Build();

var logConfiguration = new LogConfiguration();
config.GetSection("LogConfiguration").Bind(logConfiguration);
LogManager.Configure(logConfiguration);

moryxRuntime.Load();
```
7. (With Asp-Net Core | Optional) Add logging to the asp runtime:
- Add the nuget package `Microsoft.Extensions.Logging.Log4Net.AspNetCore` (Note: You might have to update your `log4net` version to a version that is compatible with both, your `Common.Logging.Log4Net208` and the new package)
- In your `Program.cs` add ConfigureLogging call to the host builder:
```cs
var host = Host.CreateDefaultBuilder(args)

.ConfigureServices(sc =>
{
sc.AddMoryxKernel(moryxRuntime);
sc.AddMoryxFacades(moryxRuntime);
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseContentRoot(directory);
webBuilder.UseStartup<Startup>();
})
.ConfigureLogging(loggingBuilder =>
{
loggingBuilder.AddLog4Net(logConfiguration.FactoryAdapter.Arguments["configFile"], true);
})
.Build();
```
- In the `ConfigureServices` method in your `Startup` class add `services.AddLogging()`
8. Test your configuration after a rebuild
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class HeaderedCommunicationSocketTests : CommunicationSocketsTestsBase<Bi
/// <param name="numberOfClients">How many clients should be connected simultaneously.</param>
/// <param name="numberOfMessages">How many messages shall each client send/receive.</param>
/// <param name="payloadMultiplier">The payload is one 32-Bit integer. To create large packets the payload length may multiplied by using this parameter.</param>
[Ignore("Test fails because of timing issue on different system")]
[Test(Description = "Send and receive data from client and server")]
[TestCase(1, 1, 0, Description = "One Client, sending 1 Message without PayLoad")]
[TestCase(5, 100, 0, Description = "Five Clients, sending 100 Messages without PayLoad")]
Expand Down Expand Up @@ -86,6 +87,7 @@ public enum ShutdownType
/// </summary>
/// <param name="numberOfClients">How many clients should be connected simultaneously.</param>
/// <param name="shutdowntype">Shall the server disconnect first, or the clients.</param>
[Ignore("Test fails because of timing issue on different system")]
[Test(Description = "The server or the clients disconnect while data is been transferred.")]
[TestCase(1, ShutdownType.ShutdownClient, Description = "One client disconnects from server while data transfer")]
[TestCase(1, ShutdownType.ShutdownServer, Description = "One client is disconnected by server while data transfer")]
Expand Down Expand Up @@ -143,6 +145,7 @@ public void SendDataPacketsWhileDisconnecting(int numberOfClients, ShutdownType
ServerConnections.ForEach(s => Assert.AreEqual(BinaryConnectionState.Disconnected, s.LastStateChangeEvents.LastOrDefault(), "Serverconnection did not receive Disconnected-Event"));
}

[Ignore("Test fails because of timing issue on different system")]
[TestCase(true, Description = "Server closes the connection upon receiving faulty message")]
[TestCase(false, Description = "Client closes the connection upon receiving faulty message")]
public void ReconnectAfterInvalidMessage(bool clientSendsMessage)
Expand Down Expand Up @@ -182,6 +185,7 @@ public void ReconnectAfterInvalidMessage(bool clientSendsMessage)
/// </summary>
/// <param name="numberOfClients">How many clients should be connected simultaneously.</param>
/// <param name="numberOfMessages">Number of messages that are sent before reconnect and after reconnect</param>
[Ignore("Test fails because of timing issue on different system")]
[Test(Description = "Clients reconnect on a existant connection and sends messages")]
[TestCase(1, 200, Description = "1 Client reconnects, 200 messages")]
[TestCase(10, 200, Description = "10 Client reconnects, 200 messages")]
Expand Down Expand Up @@ -220,7 +224,7 @@ public void ReconnectingClientsWhenClientsConnected(int numberOfClients, int num
Console.WriteLine("Sending {0} messages", numberOfMessages);

SendMessages(numberOfClients, numberOfMessages, 1, Clients, "ClientIdx");

// Assert
Assert.IsTrue(WaitForMessageReception(new TimeSpan(0, 0, 0, 5), numberOfMessages, ServerConnections));
}
Expand All @@ -230,6 +234,7 @@ public void ReconnectingClientsWhenClientsConnected(int numberOfClients, int num
/// </summary>
/// <param name="numberOfClients">How many clients should be connected simultaneously.</param>
/// <param name="numberOfMessages">Number of messages that are sent before reconnect and after reconnect</param>
[Ignore("Test fails because of timing issue on different system")]
[Test(Description = "Clients reconnect on a closed connection and sends messages")]
[TestCase(1, 200, Description = "1 Client reconnects, 200 messages")]
[TestCase(10, 200, Description = "10 Client reconnects, 200 messages")]
Expand Down
7 changes: 4 additions & 3 deletions src/Tests/Moryx.Tests/Threading/ParallelOperationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ public void ExecuteParallelWithException(bool critical)
Assert.AreEqual(!critical, _logger.Messages.Any(m => m.Level == LogLevel.Error), "Warning received");
}


//[Test]
[Ignore("Test fails because of timing issue on different system")]
[Test]
public void ScheduleExecutionWithStop()
{
StateObject state = new StateObject();
Expand Down Expand Up @@ -132,7 +132,8 @@ public void ScheduleExecutionWithWrongStop()
Assert.AreEqual(3, state.Counter, "Last check");
}

//[Test]
[Ignore("Test fails because of timing issue on different system")]
[Test]
public void ScheduleExecutionWithDispose()
{
StateObject state = new StateObject();
Expand Down

0 comments on commit b067df8

Please sign in to comment.