Skip to content

Commit

Permalink
[wasm][debugger] Trying to fix firefox flaky tests on CI. (#75090)
Browse files Browse the repository at this point in the history
* Trying to fix firefox tests flaky tests on CI.

* Fix tab taking a long time to open.

* Trying to fix CI.

* Trying to debug on CI.

* Debugging CI.

* Debug on CI.

* debug on ci

* Fix merge

* Test with timeout * 2.

* Debug on CI.

* Removing messages and increasing timeout.

* Undoing the changes on CI

* Removing unrelated changes

* Remove unrelated change

* Applied review changes.

* Trying to fix new tests.

* Update firefox.

Co-authored-by: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com>
  • Loading branch information
thaystg and ilonatommy committed Dec 28, 2022
1 parent 620239a commit 6742b97
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 36 deletions.
2 changes: 1 addition & 1 deletion eng/testing/ProvisioningVersions.props
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
</PropertyGroup>

<PropertyGroup Condition="'$(BrowserHost)' != 'windows'">
<FirefoxRevision>97.0.1</FirefoxRevision>
<FirefoxRevision>108.0.1</FirefoxRevision>
<FirefoxUrl>https://ftp.mozilla.org/pub/firefox/releases/$(FirefoxRevision)/linux-x86_64/en-US/firefox-$(FirefoxRevision).tar.bz2</FirefoxUrl>
<FirefoxBinaryName>firefox</FirefoxBinaryName>
</PropertyGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public static WasmHost RunningOn
#endif
public static bool RunningOnChrome => RunningOn == WasmHost.Chrome;

public static bool RunningOnChromeAndLinux => RunningOn == WasmHost.Chrome && PlatformDetection.IsLinux;

public const int FirefoxProxyPort = 6002;

internal InspectorClient cli;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace DebuggerTests;

public class DebuggerTestFirefox : DebuggerTestBase
{
private new TimeSpan TestTimeout => base.TestTimeout * 5;
internal FirefoxInspectorClient _client;
public DebuggerTestFirefox(ITestOutputHelper testOutput, string driver = "debugger-driver.html"):base(testOutput, driver)
{
Expand Down
69 changes: 40 additions & 29 deletions src/mono/wasm/debugger/DebuggerTestSuite/FirefoxInspectorClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,38 +71,50 @@ protected override async Task<WasmDebuggerConnection> SetupConnection(Uri webser
throw new Exception($"Failed to connect to the proxy at {endpoint}", se);
}
}
public async Task<bool> ProcessTabInfo(Result command, CancellationToken token)
{
var resultTabs = command.Value?["result"]?["value"]?["tabs"];
if (resultTabs == null ||
resultTabs.Value<JArray>()?.Count == 0 ||
resultTabs[0]?["url"]?.Value<string>()?.StartsWith("about:") == true)
return false;
var toCmd = resultTabs[0]?["actor"]?.Value<string>();
var res = await SendCommand("getWatcher", JObject.FromObject(new { type = "getWatcher", isServerTargetSwitchingEnabled = true, to = toCmd}), token);
var watcherId = res.Value?["result"]?["value"]?["actor"]?.Value<string>();
res = await SendCommand("watchResources", JObject.FromObject(new { type = "watchResources", resourceTypes = new JArray("console-message"), to = watcherId}), token);
res = await SendCommand("watchTargets", JObject.FromObject(new { type = "watchTargets", targetType = "frame", to = watcherId}), token);
UpdateTarget(res.Value?["result"]?["value"]?["target"] as JObject);
res = await SendCommand("attach", JObject.FromObject(new
{
type = "attach",
options = JObject.FromObject(new
{
pauseOnExceptions = false,
ignoreCaughtExceptions = true,
shouldShowOverlay = true,
shouldIncludeSavedFrames = true,
shouldIncludeAsyncLiveFrames = false,
skipBreakpoints = false,
logEventBreakpoints = false,
observeAsmJS = true,
breakpoints = new JArray(),
eventBreakpoints = new JArray()
}),
to = ThreadActorId
}), token);
res = await SendCommand("getBreakpointListActor", JObject.FromObject(new { type = "getBreakpointListActor", to = watcherId}), token);
BreakpointActorId = res.Value?["result"]?["value"]?["breakpointList"]?["actor"]?.Value<string>();
return true;
}

public override async Task ProcessCommand(Result command, CancellationToken token)
{
if (command.Value?["result"]?["value"]?["tabs"] != null)
if (await ProcessTabInfo(command, token))
return;
do
{
var toCmd = command.Value?["result"]?["value"]?["tabs"]?[0]?["actor"]?.Value<string>();
var res = await SendCommand("getWatcher", JObject.FromObject(new { type = "getWatcher", isServerTargetSwitchingEnabled = true, to = toCmd}), token);
var watcherId = res.Value?["result"]?["value"]?["actor"]?.Value<string>();
res = await SendCommand("watchResources", JObject.FromObject(new { type = "watchResources", resourceTypes = new JArray("console-message"), to = watcherId}), token);
res = await SendCommand("watchTargets", JObject.FromObject(new { type = "watchTargets", targetType = "frame", to = watcherId}), token);
UpdateTarget(res.Value?["result"]?["value"]?["target"] as JObject);
await SendCommand("attach", JObject.FromObject(new
{
type = "attach",
options = JObject.FromObject(new
{
pauseOnExceptions = false,
ignoreCaughtExceptions = true,
shouldShowOverlay = true,
shouldIncludeSavedFrames = true,
shouldIncludeAsyncLiveFrames = false,
skipBreakpoints = false,
logEventBreakpoints = false,
observeAsmJS = true,
breakpoints = new JArray(),
eventBreakpoints = new JArray()
}),
to = ThreadActorId
}), token);
res = await SendCommand("getBreakpointListActor", JObject.FromObject(new { type = "getBreakpointListActor", to = watcherId}), token);
BreakpointActorId = res.Value?["result"]?["value"]?["breakpointList"]?["actor"]?.Value<string>();
}
command = await SendCommand("listTabs", JObject.FromObject(new { type = "listTabs", to = "root"}), token);
} while (!await ProcessTabInfo(command, token));
}

protected override Task? HandleMessage(string msg, CancellationToken token)
Expand Down Expand Up @@ -187,7 +199,6 @@ public override Task<Result> SendCommand(SessionId sessionId, string method, JOb
{
if (args == null)
args = new JObject();

var tcs = new TaskCompletionSource<Result>();
MessageId msgId;
if (args["to"]?.Value<string>() is not string to_str)
Expand Down
5 changes: 2 additions & 3 deletions src/mono/wasm/debugger/DebuggerTestSuite/FirefoxProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ public FirefoxProvider(string id, ILogger logger) : base(id, logger)
context,
str =>
{
// FIXME: instead of this, we can wait for the port to open
//for running debugger tests on firefox
if (str?.Contains("console.log: \"ready\"") == true)
if (str?.Contains("Started devtools server on ") == true)
return $"http://localhost:{remoteDebuggingPort}";
return null;
Expand Down Expand Up @@ -136,6 +134,7 @@ private static string GetProfilePath(string Id)
user_pref("devtools.debugger.remote-enabled", true);
user_pref("devtools.debugger.prompt-connection", false);
user_pref("devtools.console.stdout.content", true);
user_pref("browser.dom.window.dump.enabled", true);
""";

string profilePath = Path.GetFullPath(Path.Combine(DebuggerTestBase.DebuggerTestAppPath, $"test-profile-{Id}"));
Expand Down
4 changes: 2 additions & 2 deletions src/mono/wasm/debugger/DebuggerTestSuite/MiscTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ public async Task InspectLocalsUsingClassFromLibraryUsingDebugTypeFull()
}
//TODO add tests covering basic stepping behavior as step in/out/over

[Theory]
[ConditionalTheory(nameof(RunningOnChrome))]
[InlineData(
"DebuggerTests.CheckSpecialCharactersInPath",
"dotnet://debugger-test-special-char-in-path.dll/test%23.cs",
Expand All @@ -980,7 +980,7 @@ public async Task InspectLocalsUsingClassFromLibraryUsingDebugTypeFull()
Assert.EndsWith(expectedFileNameEscaped, ret["callFrames"][0]["url"].Value<string>(), StringComparison.InvariantCulture);
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsLinux))]
[ConditionalFact(nameof(RunningOnChromeAndLinux))]
public async Task SetBreakpointInProjectWithColonInSourceName()
{
var bp = await SetBreakpointInMethod("debugger-test-with-colon-in-source-name.dll", "DebuggerTests.CheckColonInSourceName", "Evaluate", 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
App.method_with_structs = exports.DebuggerTests.ValueTypesTest.MethodWithLocalStructs;
App.run_all = exports.DebuggerTest.run_all;
App.static_method_table = {};
console.debug ("#debugger-app-ready#"); console.log ("ready"); // HACK: firefox tests are looking for this "ready"
console.debug ("#debugger-app-ready#");
},
};
function invoke_static_method (method_name, ...args) {
Expand Down

0 comments on commit 6742b97

Please sign in to comment.