Skip to content

Commit

Permalink
Move EventLog tests to not run on CI (#32501)
Browse files Browse the repository at this point in the history
* Move EventLog tests to not run on CI

We are hitting Win32 API issues when calling specific EventLog features.
As the risk of changes in EventLog is low we decided to turn off some
tests in CI and run them manually before a release.
  • Loading branch information
ViktorHofer authored Feb 18, 2020
1 parent ed12fa7 commit 48a222c
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
// See the LICENSE file in the project root for more information.

using Xunit;
using Microsoft.DotNet.XUnitExtensions;

namespace System.Diagnostics.Tests
{
public class EventLogEntryCollectionTests
{
private const string message = "EntryCollectionMessage";

[Trait(XunitConstants.Category, XunitConstants.IgnoreForCI)] // Unreliable Win32 API call
[ConditionalFact(typeof(Helpers), nameof(Helpers.IsElevatedAndSupportsEventLogs))]
public void CopyingEventLogEntryCollection()
{
Expand Down Expand Up @@ -44,6 +46,7 @@ public void CopyingEventLogEntryCollection()
}
}

[Trait(XunitConstants.Category, XunitConstants.IgnoreForCI)] // Unreliable Win32 API call
[ConditionalFact(typeof(Helpers), nameof(Helpers.IsElevatedAndSupportsEventLogs))]
public void CheckingEntryEqualityWithNull()
{
Expand All @@ -69,6 +72,7 @@ public void CheckingEntryEqualityWithNull()
}
}

[Trait(XunitConstants.Category, XunitConstants.IgnoreForCI)] // Unreliable Win32 API call
[ConditionalFact(typeof(Helpers), nameof(Helpers.IsElevatedAndSupportsEventLogs))]
public void CheckingEntryEqualityAndIndex()
{
Expand Down Expand Up @@ -99,6 +103,7 @@ public void CheckingEntryEqualityAndIndex()
}
}

[Trait(XunitConstants.Category, XunitConstants.IgnoreForCI)] // Unreliable Win32 API call
[ConditionalFact(typeof(Helpers), nameof(Helpers.IsElevatedAndSupportsEventLogs))]
public void CheckingEntryInEquality()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System.Threading;
using Xunit;
using Microsoft.DotNet.XUnitExtensions;

namespace System.Diagnostics.Tests
{
Expand Down Expand Up @@ -52,13 +53,15 @@ private void RaisingEvent(string log, string methodName, bool waitOnEvent = true
}
}

[Trait(XunitConstants.Category, XunitConstants.IgnoreForCI)] // Unreliable Win32 API call
[ConditionalFact(typeof(Helpers), nameof(Helpers.IsElevatedAndSupportsEventLogs))]
public void EntryWrittenEventRaised()
{
RaisingEvent("EnableEvent", nameof(EntryWrittenEventRaised));
Assert.NotEqual(0, eventCounter);
}

[Trait(XunitConstants.Category, XunitConstants.IgnoreForCI)] // Unreliable Win32 API call
[ConditionalFact(typeof(Helpers), nameof(Helpers.IsElevatedAndSupportsEventLogs))]
public void EntryWrittenEventRaiseDisable()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
// See the LICENSE file in the project root for more information.

using Xunit;
using Microsoft.DotNet.XUnitExtensions;

namespace System.Diagnostics.Tests
{
public class EventLogSourceCreationTests
{
[ActiveIssue("https://github.com/dotnet/runtime/issues/32241")]
[Trait(XunitConstants.Category, "EventLog")] // Unreliable Win32 API call
[ConditionalFact(typeof(Helpers), nameof(Helpers.IsElevatedAndSupportsEventLogs))]
public void CheckSourceExistenceAndDeletion()
{
Expand All @@ -28,6 +29,7 @@ public void CheckSourceExistenceAndDeletion()
Assert.False(EventLog.SourceExists(source));
}

[Trait(XunitConstants.Category, "EventLog")] // Unreliable Win32 API call
[ConditionalFact(typeof(Helpers), nameof(Helpers.IsElevatedAndSupportsEventLogs))]
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
public void LogNameWithSame8FirstChars_NetCore()
Expand All @@ -54,6 +56,7 @@ public void LogNameWithSame8FirstChars_NetCore()
}
}

[Trait(XunitConstants.Category, "EventLog")] // Unreliable Win32 API call
[ConditionalFact(typeof(Helpers), nameof(Helpers.IsElevatedAndSupportsEventLogs))]
[SkipOnTargetFramework(~TargetFrameworkMonikers.NetFramework)]
public void LogNameWithSame8FirstChars_NetFramework()
Expand Down Expand Up @@ -142,6 +145,7 @@ public void SourceDataNull()
Assert.Throws<ArgumentNullException>(() => EventLog.CreateEventSource(null));
}

[Trait(XunitConstants.Category, "EventLog")] // Unreliable Win32 API call
[ConditionalFact(typeof(Helpers), nameof(Helpers.IsElevatedAndSupportsEventLogs))]
public void SourceAlreadyExistsWhenCreatingSource()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.IO;
using System.Linq;
using Xunit;
using Microsoft.DotNet.XUnitExtensions;

namespace System.Diagnostics.Tests
{
Expand All @@ -22,6 +23,7 @@ public void EventLogReinitializationException()
}
}

[Trait(XunitConstants.Category, XunitConstants.IgnoreForCI)] // Unreliable Win32 API call
[ConditionalFact(typeof(Helpers), nameof(Helpers.IsElevatedAndSupportsEventLogs))]
public void ClearLog()
{
Expand Down Expand Up @@ -57,6 +59,7 @@ public void ApplicationEventLog_Count()
}
}

[Trait(XunitConstants.Category, XunitConstants.IgnoreForCI)] // Unreliable Win32 API call
[ConditionalFact(typeof(Helpers), nameof(Helpers.IsElevatedAndSupportsEventLogs))]
public void DeleteLog()
{
Expand Down Expand Up @@ -128,6 +131,7 @@ public void EventLogs_Get()
Assert.Contains(eventLogCollection, eventlog => eventlog.Log.Equals("System"));
}

[Trait(XunitConstants.Category, XunitConstants.IgnoreForCI)] // Unreliable Win32 API call
[ConditionalFact(typeof(Helpers), nameof(Helpers.IsElevatedAndSupportsEventLogs))]
public void GetMaxKilobytes_Set()
{
Expand Down Expand Up @@ -162,6 +166,7 @@ public void MaxKilobytesOutOfRangeException()
}
}

[Trait(XunitConstants.Category, XunitConstants.IgnoreForCI)] // Unreliable Win32 API call
[ConditionalFact(typeof(Helpers), nameof(Helpers.IsElevatedAndSupportsEventLogs))]
public void OverflowAndRetention_Set()
{
Expand Down Expand Up @@ -190,6 +195,7 @@ public void OverflowAndRetention_Set()
}
}

[Trait(XunitConstants.Category, XunitConstants.IgnoreForCI)] // Unreliable Win32 API call
[ConditionalFact(typeof(Helpers), nameof(Helpers.IsElevatedAndSupportsEventLogs))]
public void Overflow_OverWriteOlderAndRetention_Set()
{
Expand Down Expand Up @@ -248,6 +254,7 @@ public void MachineName_Set()
}
}

[Trait(XunitConstants.Category, XunitConstants.IgnoreForCI)] // Unreliable Win32 API call
[ConditionalFact(typeof(Helpers), nameof(Helpers.IsElevatedAndSupportsEventLogs))]
public void RegisterDisplayLogName()
{
Expand Down Expand Up @@ -314,6 +321,7 @@ public void InvalidMachineName()
Assert.Throws<ArgumentException>(() => EventLog.DeleteEventSource("", ""));
}

[Trait(XunitConstants.Category, XunitConstants.IgnoreForCI)] // Unreliable Win32 API call
[ConditionalFact(typeof(Helpers), nameof(Helpers.IsElevatedAndSupportsEventLogs))]
public void LogDisplayNameDefault()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System.ComponentModel;
using Xunit;
using Microsoft.DotNet.XUnitExtensions;

namespace System.Diagnostics.Tests
{
Expand Down Expand Up @@ -121,6 +122,7 @@ private EventLogEntry WriteLogEntryEvent(string source, bool data = false)
}
}

[Trait(XunitConstants.Category, XunitConstants.IgnoreForCI)] // Unreliable Win32 API call
[ConditionalTheory(typeof(Helpers), nameof(Helpers.IsElevatedAndSupportsEventLogs))]
[InlineData(false)]
[InlineData(true)]
Expand Down Expand Up @@ -153,6 +155,7 @@ public void WriteEntry(bool sourceFlag)
}
}

[Trait(XunitConstants.Category, XunitConstants.IgnoreForCI)] // Unreliable Win32 API call
[ConditionalTheory(typeof(Helpers), nameof(Helpers.IsElevatedAndSupportsEventLogs))]
[InlineData(false)]
[InlineData(true)]
Expand Down Expand Up @@ -182,6 +185,7 @@ public void WriteEntryWithType(bool sourceFlag)
}
}

[Trait(XunitConstants.Category, XunitConstants.IgnoreForCI)] // Unreliable Win32 API call
[ConditionalTheory(typeof(Helpers), nameof(Helpers.IsElevatedAndSupportsEventLogs))]
[InlineData(false)]
[InlineData(true)]
Expand Down Expand Up @@ -211,6 +215,7 @@ public void WriteEntryWithTypeAndId(bool sourceFlag)
}
}

[Trait(XunitConstants.Category, XunitConstants.IgnoreForCI)] // Unreliable Win32 API call
[ConditionalTheory(typeof(Helpers), nameof(Helpers.IsElevatedAndSupportsEventLogs))]
[InlineData(false)]
[InlineData(true)]
Expand Down Expand Up @@ -246,6 +251,7 @@ public void WriteEntryWithTypeIdAndCategory(bool sourceFlag)
}
}

[Trait(XunitConstants.Category, XunitConstants.IgnoreForCI)] // Unreliable Win32 API call
[ConditionalTheory(typeof(Helpers), nameof(Helpers.IsElevatedAndSupportsEventLogs))]
[InlineData(false)]
[InlineData(true)]
Expand Down Expand Up @@ -302,6 +308,7 @@ public void WriteEntryWithNullOrEmptySource()
Assert.Throws<ArgumentException>(() => EventLog.WriteEntry("", message));
}

[Trait(XunitConstants.Category, XunitConstants.IgnoreForCI)] // Unreliable Win32 API call
[ConditionalTheory(typeof(Helpers), nameof(Helpers.IsElevatedAndSupportsEventLogs))]
[InlineData(false)]
[InlineData(true)]
Expand All @@ -328,6 +335,7 @@ public void WriteEvent(bool SourceFlag)
}
}

[Trait(XunitConstants.Category, XunitConstants.IgnoreForCI)] // Unreliable Win32 API call
[ConditionalTheory(typeof(Helpers), nameof(Helpers.IsElevatedAndSupportsEventLogs))]
[InlineData(false)]
[InlineData(true)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Globalization;
using System.Text;
using Xunit;
using Microsoft.DotNet.XUnitExtensions;

namespace System.Diagnostics.Tests
{
Expand Down Expand Up @@ -87,6 +88,7 @@ public void CloseSucceeds()
listener.Close(); // shouldn't fail.
}

[Trait(XunitConstants.Category, XunitConstants.IgnoreForCI)] // Unreliable Win32 API call
[ConditionalFact(typeof(Helpers), nameof(Helpers.IsElevatedAndSupportsEventLogs))]
public void WriteTest()
{
Expand All @@ -113,7 +115,7 @@ public void WriteTest()
}
}

[ActiveIssue("https://github.com/dotnet/corefx/issues/40224", TestPlatforms.Windows)]
[Trait(XunitConstants.Category, XunitConstants.IgnoreForCI)] // Unreliable Win32 API call
[ConditionalTheory(typeof(Helpers), nameof(Helpers.IsElevatedAndSupportsEventLogs))]
[InlineData(TraceEventType.Information, EventLogEntryType.Information, ushort.MaxValue + 1, ushort.MaxValue)]
[InlineData(TraceEventType.Error, EventLogEntryType.Error, ushort.MinValue - 1, ushort.MinValue)]
Expand Down Expand Up @@ -155,6 +157,7 @@ public static IEnumerable<object[]> GetTraceDataParams_MemberData()
yield return new object[] { new object[] { "one string + null", null } };
}

[Trait(XunitConstants.Category, XunitConstants.IgnoreForCI)] // Unreliable Win32 API call
[ConditionalTheory(typeof(Helpers), nameof(Helpers.IsElevatedAndSupportsEventLogs))]
[MemberData(nameof(GetTraceDataParams_MemberData))]
public void TraceDataParamsData(object[] parameters)
Expand Down Expand Up @@ -195,7 +198,7 @@ public static IEnumerable<object[]> GetTraceEventFormat_MemberData()
yield return new object[] { null, new object[] { "thanks, 00", "i like it...", 111 } };
}

[ActiveIssue("https://github.com/dotnet/corefx/issues/40224", TestPlatforms.Windows)]
[Trait(XunitConstants.Category, XunitConstants.IgnoreForCI)] // Unreliable Win32 API call
[ConditionalTheory(typeof(Helpers), nameof(Helpers.IsElevatedAndSupportsEventLogs))]
[MemberData(nameof(GetTraceEventFormat_MemberData))]
public void TraceEventFormatAndParams(string format, object[] parameters)
Expand Down Expand Up @@ -251,6 +254,7 @@ public void TraceEventFormatAndParams(string format, object[] parameters)
}
}

[Trait(XunitConstants.Category, XunitConstants.IgnoreForCI)] // Unreliable Win32 API call
[ConditionalFact(typeof(Helpers), nameof(Helpers.IsElevatedAndSupportsEventLogs))]
public void TraceWithFilters()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Diagnostics.Eventing.Reader;
using System.Security.Principal;
using Xunit;
using Microsoft.DotNet.XUnitExtensions;

namespace System.Diagnostics.Tests
{
Expand All @@ -29,6 +30,7 @@ public void GetPropertyValues()
}

[ActiveIssue("https://github.com/dotnet/corefx/issues/34547")]
[Trait(XunitConstants.Category, XunitConstants.IgnoreForCI)] // Unreliable Win32 API call
[ConditionalTheory(typeof(Helpers), nameof(Helpers.SupportsEventLogs))]
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
[InlineData("System")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Diagnostics.Eventing.Reader;
using System.Threading;
using Xunit;
using Microsoft.DotNet.XUnitExtensions;

namespace System.Diagnostics.Tests
{
Expand Down Expand Up @@ -94,13 +95,15 @@ private void RaisingEvent(string log, string methodName, bool waitOnEvent = true
}
}

[Trait(XunitConstants.Category, XunitConstants.IgnoreForCI)] // Unreliable Win32 API call
[ConditionalFact(typeof(Helpers), nameof(Helpers.IsElevatedAndSupportsEventLogs))]
public void RecordWrittenEventRaised()
{
RaisingEvent("EnableEvent", nameof(RecordWrittenEventRaised));
Assert.NotEqual(0, eventCounter);
}

[Trait(XunitConstants.Category, XunitConstants.IgnoreForCI)] // Unreliable Win32 API call
[ConditionalFact(typeof(Helpers), nameof(Helpers.IsElevatedAndSupportsEventLogs))]
public void RecordWrittenEventRaiseDisable()
{
Expand Down

0 comments on commit 48a222c

Please sign in to comment.