Skip to content

Commit

Permalink
Merge pull request #621 from WideSpectrumComputing/master
Browse files Browse the repository at this point in the history
fix: resolve GH #615 - ConnectivityMonitor tests wrong thing
  • Loading branch information
akornich authored Feb 10, 2022
2 parents f0ca7d9 + 715564f commit 269c335
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 98 deletions.
11 changes: 11 additions & 0 deletions Rollbar/IRollbarConnectivityMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,16 @@ bool IsDisabled
{
get;
}

/// <summary>
/// Disables this instance.
/// </summary>
/// <remarks>
/// Any concrete Connectivity Monitor implementation may not be 100% accurate for all the possible
/// network environments. So, you may have to disable it in case it does not properly detect
/// specific network conditions. If disabled it will be assumed to always have its
/// IsConnectivityOn property returning true.
/// </remarks>
void Disable();
}
}
15 changes: 9 additions & 6 deletions Rollbar/Infrastructure/RollbarConnectivityMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ internal class RollbarConnectivityMonitor
: IRollbarConnectivityMonitor
, IDisposable
{
private readonly object _connectivityStatusSyncLock = new object();
private TimeSpan _currentMonitoringInterval;
private Timer? _monitoringTimer;
private readonly object _connectivityStatusSyncLock = new();
private readonly TimeSpan _minMonitoringInterval;
private readonly TimeSpan _maxMonitoringInterval;
private TimeSpan _currentMonitoringInterval;
private Timer? _monitoringTimer;

#region singleton implementation

Expand Down Expand Up @@ -84,7 +84,7 @@ private NestedSingleInstance()
/// <value><c>true</c> if this instance is connectivity on; otherwise, <c>false</c>.</value>
public bool IsConnectivityOn
{
get; // NOTE: Simplest way to fake no-connectivity is to always return false from the getter
get; // NOTE: Simplest way to fake no-connectivity is to always return false from this getter
private set;
}

Expand All @@ -110,6 +110,10 @@ public void OverrideAsOffline()
/// <summary>
/// Disables this instance.
/// </summary>
/// <remarks>Any concrete Connectivity Monitor implementation may not be 100% accurate for all the possible
/// network environments. So, you may have to disable it in case it does not properly detect
/// specific network conditions. If disabled it will be assumed to always have its
/// IsConnectivityOn property returning true.</remarks>
public void Disable()
{
lock(this._connectivityStatusSyncLock)
Expand Down Expand Up @@ -234,7 +238,7 @@ public static bool TestApiServer()
TcpClient? client = null;
try
{
client = new TcpClient("www.rollbar.com", 80);
client = new TcpClient(@"api.rollbar.com", 443);
result = true;
}
catch(SocketException ex)
Expand All @@ -255,7 +259,6 @@ public static bool TestApiServer()

private bool _disposedValue = false; // To detect redundant calls


/// <summary>
/// Releases unmanaged and - optionally - managed resources.
/// </summary>
Expand Down
85 changes: 36 additions & 49 deletions Rollbar/Infrastructure/_Infrastructure.cd
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram MajorVersion="1" MinorVersion="1" MembersFormat="FullSignature">
<Class Name="Rollbar.AccessTokenQueuesMetadata">
<Class Name="Rollbar.Infrastructure.AccessTokenQueuesMetadata">
<Position X="10.75" Y="1" Width="6.25" />
<TypeIdentifier>
<HashCode>QAAAQEAAAAAAAAIAAAAAAAAAEAABAAADAABAAAAAEAA=</HashCode>
<HashCode>QAAAQEAAAAAAAAIAAAAAAAAAEAABAAADAAAAAAAAEAA=</HashCode>
<FileName>Infrastructure\AccessTokenQueuesMetadata.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="Rollbar.PayloadQueue">
<Class Name="Rollbar.Infrastructure.PayloadQueue">
<Position X="5.25" Y="1" Width="5.25" />
<TypeIdentifier>
<HashCode>gABAAAAAABIEAEIAEAAAAAAAIEAABAAAAAIIARAIACQ=</HashCode>
<HashCode>gABAAAAAABIEAEIAEAAAAAAAIEAABAAAAAIIARAIAAQ=</HashCode>
<FileName>Infrastructure\PayloadQueue.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="Rollbar.RollbarRateLimit">
<Class Name="Rollbar.Infrastructure.RollbarRateLimit">
<Position X="17.25" Y="1" Width="5.25" />
<Compartments>
<Compartment Name="Nested Types" Collapsed="false" />
</Compartments>
<NestedTypes>
<Class Name="Rollbar.RollbarRateLimit.RollbarRateLimitHeaders">
<Class Name="Rollbar.Infrastructure.RollbarRateLimit.RollbarRateLimitHeaders">
<TypeIdentifier>
<NewMemberFileName>InternalInfrastructure\RollbarRateLimit.cs</NewMemberFileName>
<NewMemberFileName>Infrastructure\RollbarRateLimit.cs</NewMemberFileName>
</TypeIdentifier>
</Class>
</NestedTypes>
Expand All @@ -33,94 +33,81 @@
<FileName>Infrastructure\RollbarRateLimit.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="Rollbar.RollbarResponse">
<Class Name="Rollbar.Infrastructure.RollbarResponse">
<Position X="12.5" Y="5.5" Width="4" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAQAAQAAAAAQAAAAAAAAQAAAAAAABAAA=</HashCode>
<FileName>Infrastructure\RollbarResponse.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="Rollbar.RollbarClient">
<Position X="5.25" Y="7" Width="7" />
<Class Name="Rollbar.Infrastructure.PayloadBundle">
<Position X="16.75" Y="8.25" Width="11.25" />
<TypeIdentifier>
<HashCode>CAAAAAAEAgCAAAQAAhAAAAACAQABAAAAAAIAAADAABA=</HashCode>
<FileName>Infrastructure\RollbarClient.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="Rollbar.PayloadBundle">
<Position X="16.75" Y="8" Width="11.25" />
<TypeIdentifier>
<HashCode>EAQAAAAABAAAAAAJAEIQgSQigAIHAoAAAABACAAAKAA=</HashCode>
<HashCode>EAQAAAAABAAAAAAJAEAQgSQigAIHAoAAAABACAAAKAA=</HashCode>
<FileName>Infrastructure\PayloadBundle.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="Rollbar.ConnectivityMonitor">
<Position X="22.75" Y="1" Width="5.25" />
<Compartments>
<Compartment Name="Nested Types" Collapsed="false" />
</Compartments>
<NestedTypes>
<Class Name="Rollbar.ConnectivityMonitor.NestedSingleInstance">
<TypeIdentifier>
<NewMemberFileName>InternalInfrastructure\ConnectivityMonitor.cs</NewMemberFileName>
</TypeIdentifier>
</Class>
</NestedTypes>
<TypeIdentifier>
<HashCode>ARAgAARAAQAQQAAQAEAAAAAAAoCAAAAAQAAAAAAAAAA=</HashCode>
<FileName>Infrastructure\ConnectivityMonitor.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="Rollbar.RollbarErrorUtility">
<Class Name="Rollbar.Infrastructure.RollbarErrorUtility">
<Position X="0.5" Y="16.25" Width="9.75" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAA=</HashCode>
<FileName>Infrastructure\RollbarErrorUtility.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="Rollbar.RollbarLoggerBlockingWrapper">
<Class Name="Rollbar.Infrastructure.RollbarLoggerBlockingWrapper">
<Position X="0.5" Y="8" Width="4.25" />
<TypeIdentifier>
<HashCode>AAAIAAAAACABAYAABAAAABAAAAkAAAAAAAEAQkAABAA=</HashCode>
<FileName>Infrastructure\RollbarLoggerBlockingWrapper.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="Rollbar.RollbarResult">
<Class Name="Rollbar.Infrastructure.RollbarResult">
<Position X="12" Y="13.75" Width="3.25" />
<TypeIdentifier>
<HashCode>AAACAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAAA=</HashCode>
<FileName>Infrastructure\RollbarResult.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="Rollbar.RollbarUtility">
<Class Name="Rollbar.Infrastructure.RollbarUtility">
<Position X="0.5" Y="14.25" Width="9.75" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAIAAAAAAQAAAA=</HashCode>
<FileName>Infrastructure\RollbarUtility.cs</FileName>
</TypeIdentifier>
</Class>
<Interface Name="Rollbar.IPayloadQueue">
<Class Name="Rollbar.Infrastructure.RollbarConnectivityMonitor">
<Position X="22.75" Y="1" Width="3.5" />
<Compartments>
<Compartment Name="Nested Types" Collapsed="false" />
</Compartments>
<NestedTypes>
<Class Name="Rollbar.Infrastructure.RollbarConnectivityMonitor.NestedSingleInstance">
<TypeIdentifier>
<NewMemberFileName>Infrastructure\RollbarConnectivityMonitor.cs</NewMemberFileName>
</TypeIdentifier>
</Class>
</NestedTypes>
<TypeIdentifier>
<HashCode>ARAgAABAASAQQAAQAAIAAAAAAoCAAAEAQABgAAAAAAA=</HashCode>
<FileName>Infrastructure\RollbarConnectivityMonitor.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Interface Name="Rollbar.Infrastructure.IPayloadQueue">
<Position X="0.5" Y="0.75" Width="4.5" />
<TypeIdentifier>
<HashCode>gABAAAAAAAIEAAIAAAAAAAAAAEAABAAAAAAIARAIAAQ=</HashCode>
<FileName>Infrastructure\IPayloadQueue.cs</FileName>
</TypeIdentifier>
</Interface>
<Interface Name="Rollbar.IPayloadQueuesRegistry">
<Position X="0.5" Y="4.75" Width="4.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAABAAABAABAAAAAEAA=</HashCode>
<FileName>Infrastructure\IPayloadQueuesRegistry.cs</FileName>
</TypeIdentifier>
</Interface>
<Enum Name="Rollbar.InternalRollbarError">
<Enum Name="Rollbar.Infrastructure.InternalRollbarError">
<Position X="13.25" Y="8.5" Width="2.5" />
<TypeIdentifier>
<HashCode>AAAQAAAAgAAAAAAgAAFCAEAIAAAAAAYCAAAAIAAAwEA=</HashCode>
<HashCode>AAAQAAUAgAAAEAAgAAFCAEAIAAACAAYCAAAAIAAAwEA=</HashCode>
<FileName>Infrastructure\InternalRollbarError.cs</FileName>
</TypeIdentifier>
</Enum>
Expand Down
31 changes: 12 additions & 19 deletions Rollbar/_RollbarInfrastructure.cd
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram MajorVersion="1" MinorVersion="1" GroupingSetting="Access" MembersFormat="FullSignature">
<Class Name="Rollbar.RollbarQueueController">
<Class Name="Rollbar.Infrastructure.RollbarQueueController">
<Position X="0.5" Y="8" Width="4" />
<Compartments>
<Compartment Name="Internal" Collapsed="true" />
<Compartment Name="Private" Collapsed="true" />
<Compartment Name="Nested Types" Collapsed="false" />
</Compartments>
<NestedTypes>
<Class Name="Rollbar.RollbarQueueController.NestedSingleInstance" Collapsed="true">
<Class Name="Rollbar.Infrastructure.RollbarQueueController.NestedSingleInstance" Collapsed="true">
<TypeIdentifier>
<NewMemberFileName>RollbarQueueController.cs</NewMemberFileName>
<NewMemberFileName>Infrastructure\RollbarQueueController.cs</NewMemberFileName>
</TypeIdentifier>
</Class>
<Enum Name="Rollbar.RollbarQueueController.PayloadTraceSources">
<Enum Name="Rollbar.Infrastructure.RollbarQueueController.PayloadTraceSources">
<TypeIdentifier>
<NewMemberFileName>RollbarQueueController.cs</NewMemberFileName>
<NewMemberFileName>Infrastructure\RollbarQueueController.cs</NewMemberFileName>
</TypeIdentifier>
</Enum>
</NestedTypes>
Expand All @@ -32,10 +32,6 @@
</Compartments>
<NestedTypes>
<Class Name="Rollbar.RollbarInfrastructure.NestedSingleInstance" Collapsed="true">
<Compartments>
<Compartment Name="Internal" Collapsed="true" />
<Compartment Name="Private" Collapsed="true" />
</Compartments>
<TypeIdentifier>
<NewMemberFileName>RollbarInfrastructure.cs</NewMemberFileName>
</TypeIdentifier>
Expand All @@ -57,10 +53,6 @@
</Compartments>
<NestedTypes>
<Class Name="Rollbar.RollbarTelemetryCollector.NestedSingleInstance" Collapsed="true">
<Compartments>
<Compartment Name="Internal" Collapsed="true" />
<Compartment Name="Private" Collapsed="true" />
</Compartments>
<TypeIdentifier>
<NewMemberFileName>Telemetry\RollbarTelemetryCollector.cs</NewMemberFileName>
</TypeIdentifier>
Expand All @@ -73,11 +65,12 @@
<Lollipop Position="0.2" />
</Class>
<Class Name="Rollbar.RollbarException">
<Position X="15.75" Y="6.25" Width="6.25" />
<Position X="14" Y="0.75" Width="6.25" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAACAAAAA=</HashCode>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAgAAAEAAAAAAAAACAAAAA=</HashCode>
<FileName>RollbarException.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Interface Name="Rollbar.ITraceable">
<Position X="0.5" Y="0.5" Width="2.75" />
Expand All @@ -101,7 +94,7 @@
</TypeIdentifier>
</Interface>
<Interface Name="Rollbar.IRollbarInfrastructureOptions">
<Position X="5" Y="2.25" Width="3" />
<Position X="5" Y="2.25" Width="4" />
<TypeIdentifier>
<HashCode>AAAACAAAAAAAAAAAAAAAEAAAAABAAAAIAAAAAAAAAAA=</HashCode>
<FileName>IRollbarInfrastructureOptions.cs</FileName>
Expand All @@ -121,10 +114,10 @@
<FileName>ErrorLevel.cs</FileName>
</TypeIdentifier>
</Enum>
<Enum Name="Rollbar.InternalRollbarError">
<Position X="15.75" Y="9.75" Width="3" />
<Enum Name="Rollbar.Infrastructure.InternalRollbarError">
<Position X="14" Y="4.75" Width="3" />
<TypeIdentifier>
<HashCode>AAAQAAUAgAAAAAAgAAFCAEAIAAACAAYCAAAAIAAAwEA=</HashCode>
<HashCode>AAAQAAUAgAAAEAAgAAFCAEAIAAACAAYCAAAAIAAAwEA=</HashCode>
<FileName>Infrastructure\InternalRollbarError.cs</FileName>
</TypeIdentifier>
</Enum>
Expand Down
20 changes: 2 additions & 18 deletions SdkCommon.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,12 @@
</ItemGroup>

<PropertyGroup Label="SDK Release Essential Info">
<SdkVersion>5.1.0</SdkVersion> <!-- Required: major.minor.patch -->
<SdkVersion>5.1.1</SdkVersion> <!-- Required: major.minor.patch -->
<SdkVersionSuffix></SdkVersionSuffix> <!-- Optional. Examples: alpha, beta, preview, RC etc. -->
<SdkLtsRelease>false</SdkLtsRelease> <!-- Optional. Examples: false (default) or true. -->
<SdkReleaseNotes> <!-- Required -->

Since v4:

- feat: optioanl RollbarInfrastructure concept
- feat: optional explicit RollbarInfrastructure initialization
- feat: structured Rollbar configuration
- feat: Blazor browser-side support
- feat: resolve #532 - Make RollbarMiddlewareException wrapper optional based on config settings
- feat: resolve #585 - Would like to have an ability to log HttpRequest Body via ILogger
- fix: OfflinePersistence module's dependency on SQLite native bits
- refactor: Simplified and upgraded Rollbar.OfflinePersistence dependencies and project settings
- refactor: resolve #587 - Update Rollbar.NET's dependency on Newtonsoft.Json package to current version 13.0
- refactor: clean up the SDK explicit targets to only currently supported .NET versions
- refactor: clear all the VS build warnings and Intelli-sense messages
- refactor: addressed SonarCloud detected reliability issues
- refactor: addressed SonarCloud detected security hotspots
- refactor: addressed SonarCloud detected code smells
- chore: remove unused files from the repo root
- fix: resolve GH #615 - ConnectivityMonitor tests wrong thing

</SdkReleaseNotes>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

namespace UnitTest.Rollbar {
using System;
using System.Diagnostics;
using System.Threading;

using global::Rollbar;
using global::Rollbar.Infrastructure;

using Microsoft.VisualStudio.TestTools.UnitTesting;


[TestClass]
[TestCategory(nameof(ConnectivityMonitorFixture))]
public class ConnectivityMonitorFixture
[TestCategory(nameof(RollbarConnectivityMonitorFixture))]
public class RollbarConnectivityMonitorFixture
{
[TestInitialize]
public void SetupFixture()
Expand All @@ -24,6 +21,14 @@ public void TearDownFixture()
{
}

[TestMethod]
public void TestApiServerTest()
{
bool isConnected = RollbarConnectivityMonitor.TestApiServer();
Assert.IsTrue(isConnected, "Access to api.rollbar.com:443");
}


//[TestMethod]
//public void ManualTest() {
//bool lastState = false;
Expand Down

0 comments on commit 269c335

Please sign in to comment.