Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions GVFS/GVFS.Common/NamedPipes/NamedPipeServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ private void OpenListeningPipe()

private void OnNewConnection(IAsyncResult ar)
{
this.OnNewConnection(ar, createNewThreadIfSynchronous: true);
if (!this.isStopping)
{
this.OnNewConnection(ar, createNewThreadIfSynchronous: true);
}
}

private void OnNewConnection(IAsyncResult ar, bool createNewThreadIfSynchronous)
Expand Down Expand Up @@ -123,13 +126,6 @@ private void OnNewConnection(IAsyncResult ar, bool createNewThreadIfSynchronous)
metadata.Add(TracingConstants.MessageKey.WarningMessage, "OnNewConnection: Connection broken");
this.tracer.RelatedEvent(EventLevel.Warning, "OnNewConnectionn_EndWaitForConnection_IOException", metadata);
}
catch (ObjectDisposedException)
{
if (!this.isStopping)
{
throw;
}
}
catch (Exception e)
{
this.LogErrorAndExit("OnNewConnection caught unhandled exception, exiting process", e);
Expand Down
2 changes: 1 addition & 1 deletion GVFS/GVFS.Common/Prefetch/CommitPrefetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ private static bool TrySchedulePostFetchJob(ITracer tracer, string namedPipeName
{
tracer.RelatedWarning(
metadata: null,
message: "Failed to connect to GVFS. Skipping post-fetch job request.",
message: "Failed to connect to GVFS.Mount process. Skipping post-fetch job request.",
keywords: Keywords.Telemetry);
return false;
}
Expand Down
14 changes: 14 additions & 0 deletions GVFS/GVFS.Common/Tracing/JsonTracer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public class JsonTracer : ITracer

private EventLevel startStopLevel;
private Keywords startStopKeywords;

private bool disposed;

public JsonTracer(string providerName, string activityName, bool disableTelemetry = false)
: this(providerName, Guid.Empty, activityName, enlistmentId: null, mountId: null, disableTelemetry: disableTelemetry)
{
Expand Down Expand Up @@ -101,6 +104,8 @@ public void Dispose()

this.listeners.Clear();
}

this.disposed = true;
}

public virtual void RelatedEvent(EventLevel level, string eventName, EventMetadata metadata)
Expand Down Expand Up @@ -256,6 +261,15 @@ private static string GetCategorizedErrorEventName(Keywords keywords)
private void WriteEvent(string eventName, EventLevel level, Keywords keywords, EventMetadata metadata, EventOpcode opcode)
{
string jsonPayload = metadata != null ? JsonConvert.SerializeObject(metadata) : null;

if (this.disposed)
{
Console.WriteLine("Writing to disposed tracer");
Console.WriteLine(jsonPayload);

throw new ObjectDisposedException(nameof(JsonTracer));
}

foreach (InProcEventListener listener in this.listeners)
{
listener.RecordMessage(eventName, this.activityId, this.parentActivityId, level, keywords, opcode, jsonPayload);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class PrefetchVerbWithoutSharedCacheTests : TestsWithEnlistmentPerFixture
// Set forcePerRepoObjectCache to true to avoid any of the tests inadvertently corrupting
// the cache
public PrefetchVerbWithoutSharedCacheTests()
: base(forcePerRepoObjectCache: true)
: base(forcePerRepoObjectCache: true, skipPrefetchDuringClone: true)
{
this.fileSystem = new SystemIORunner();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ namespace GVFS.FunctionalTests.Tests.EnlistmentPerFixture
public abstract class TestsWithEnlistmentPerFixture
{
private readonly bool forcePerRepoObjectCache;
private readonly bool skipPrefetchDuringClone;

public TestsWithEnlistmentPerFixture(bool forcePerRepoObjectCache = false)
public TestsWithEnlistmentPerFixture(bool forcePerRepoObjectCache = false, bool skipPrefetchDuringClone = false)
{
this.forcePerRepoObjectCache = forcePerRepoObjectCache;
this.skipPrefetchDuringClone = skipPrefetchDuringClone;
}

public GVFSFunctionalTestEnlistment Enlistment
Expand All @@ -23,7 +25,7 @@ public virtual void CreateEnlistment()
{
if (this.forcePerRepoObjectCache)
{
this.Enlistment = GVFSFunctionalTestEnlistment.CloneAndMountWithPerRepoCache(GVFSTestConfig.PathToGVFS);
this.Enlistment = GVFSFunctionalTestEnlistment.CloneAndMountWithPerRepoCache(GVFSTestConfig.PathToGVFS, this.skipPrefetchDuringClone);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using GVFS.FunctionalTests.Tools;
using GVFS.Tests.Should;
using NUnit.Framework;
using System.IO;

namespace GVFS.FunctionalTests.Tests.MultiEnlistmentTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using GVFS.FunctionalTests.Tools;
using NUnit.Framework;
using System.Collections.Generic;
using System.IO;

namespace GVFS.FunctionalTests.Tests.MultiEnlistmentTests
{
Expand Down
13 changes: 6 additions & 7 deletions GVFS/GVFS.FunctionalTests/Tools/GVFSFunctionalTestEnlistment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ public string Commitish
get; private set;
}

public static GVFSFunctionalTestEnlistment CloneAndMountWithPerRepoCache(string pathToGvfs, string commitish = null)
public static GVFSFunctionalTestEnlistment CloneAndMountWithPerRepoCache(string pathToGvfs, bool skipPrefetch)
{
string enlistmentRoot = GVFSFunctionalTestEnlistment.GetUniqueEnlistmentRoot();
string localCache = GVFSFunctionalTestEnlistment.GetRepoSpecificLocalCacheRoot(enlistmentRoot);
return CloneAndMount(pathToGvfs, enlistmentRoot, commitish, localCache);
return CloneAndMount(pathToGvfs, enlistmentRoot, null, localCache, skipPrefetch);
}

public static GVFSFunctionalTestEnlistment CloneAndMount(string pathToGvfs, string commitish = null, string localCacheRoot = null)
Expand Down Expand Up @@ -153,11 +153,10 @@ public void DeleteEnlistment()
}
}

public void CloneAndMount()
public void CloneAndMount(bool skipPrefetch)
{
this.gvfsProcess.Clone(this.RepoUrl, this.Commitish);
this.gvfsProcess.Clone(this.RepoUrl, this.Commitish, skipPrefetch);

this.MountGVFS();
GitProcess.Invoke(this.RepoRoot, "checkout " + this.Commitish);
GitProcess.Invoke(this.RepoRoot, "branch --unset-upstream");
GitProcess.Invoke(this.RepoRoot, "config core.abbrev 40");
Expand Down Expand Up @@ -265,7 +264,7 @@ public string GetObjectPathTo(string objectHash)
objectHash.Substring(2));
}

private static GVFSFunctionalTestEnlistment CloneAndMount(string pathToGvfs, string enlistmentRoot, string commitish, string localCacheRoot)
private static GVFSFunctionalTestEnlistment CloneAndMount(string pathToGvfs, string enlistmentRoot, string commitish, string localCacheRoot, bool skipPrefetch = false)
{
GVFSFunctionalTestEnlistment enlistment = new GVFSFunctionalTestEnlistment(
pathToGvfs,
Expand All @@ -276,7 +275,7 @@ private static GVFSFunctionalTestEnlistment CloneAndMount(string pathToGvfs, str

try
{
enlistment.CloneAndMount();
enlistment.CloneAndMount(skipPrefetch);
}
catch (Exception e)
{
Expand Down
33 changes: 9 additions & 24 deletions GVFS/GVFS.FunctionalTests/Tools/GVFSProcess.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using GVFS.Tests.Should;
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;

namespace GVFS.FunctionalTests.Tools
{
Expand All @@ -18,14 +16,15 @@ public GVFSProcess(string pathToGVFS, string enlistmentRoot, string localCacheRo
this.localCacheRoot = localCacheRoot;
}

public void Clone(string repositorySource, string branchToCheckout)
public void Clone(string repositorySource, string branchToCheckout, bool skipPrefetch)
{
string args = string.Format(
"clone \"{0}\" \"{1}\" --branch \"{2}\" --no-mount --no-prefetch --local-cache-path \"{3}\"",
"clone \"{0}\" \"{1}\" --branch \"{2}\" --local-cache-path \"{3}\" {4}",
repositorySource,
this.enlistmentRoot,
branchToCheckout,
this.localCacheRoot);
this.localCacheRoot,
skipPrefetch ? "--no-prefetch" : string.Empty);
this.CallGVFS(args, failOnError: true);
}

Expand All @@ -38,10 +37,8 @@ public void Mount()

public bool TryMount(out string output)
{
string mountCommand = "mount \"" + this.enlistmentRoot + "\" --internal_use_only_service_name " + GVFSServiceProcess.TestServiceName;

this.IsEnlistmentMounted().ShouldEqual(false, "GVFS is already mounted");
output = this.CallGVFS(mountCommand);
output = this.CallGVFS("mount \"" + this.enlistmentRoot + "\"");
return this.IsEnlistmentMounted();
}

Expand All @@ -59,11 +56,7 @@ public void Repair()

public string Diagnose()
{
string diagnoseArgs = string.Join(
" ",
"diagnose \"" + this.enlistmentRoot + "\"",
"--internal_use_only_service_name " + GVFSServiceProcess.TestServiceName);
return this.CallGVFS(diagnoseArgs);
return this.CallGVFS("diagnose \"" + this.enlistmentRoot + "\"");
}

public string Status()
Expand All @@ -80,11 +73,7 @@ public void Unmount()
{
if (this.IsEnlistmentMounted())
{
string unmountArgs = string.Join(
" ",
"unmount \"" + this.enlistmentRoot + "\"",
"--internal_use_only_service_name " + GVFSServiceProcess.TestServiceName);
string result = this.CallGVFS(unmountArgs, failOnError: true);
string result = this.CallGVFS("unmount \"" + this.enlistmentRoot + "\"", failOnError: true);
this.IsEnlistmentMounted().ShouldEqual(false, "GVFS did not unmount: " + result);
}
}
Expand All @@ -97,18 +86,14 @@ public bool IsEnlistmentMounted()

public string RunServiceVerb(string argument)
{
string serviceVerbArgs = string.Join(
" ",
"service " + argument,
"--internal_use_only_service_name " + GVFSServiceProcess.TestServiceName);
return this.CallGVFS(serviceVerbArgs, failOnError: true);
return this.CallGVFS("service " + argument, failOnError: true);
}

private string CallGVFS(string args, bool failOnError = false)
{
ProcessStartInfo processInfo = null;
processInfo = new ProcessStartInfo(this.pathToGVFS);
processInfo.Arguments = args;
processInfo.Arguments = args + " --internal_use_only_service_name " + GVFSServiceProcess.TestServiceName;

processInfo.WindowStyle = ProcessWindowStyle.Hidden;
processInfo.UseShellExecute = false;
Expand Down
1 change: 0 additions & 1 deletion GVFS/GVFS/CommandLine/GVFSVerb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using GVFS.Common.Tracing;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Security;
Expand Down
2 changes: 1 addition & 1 deletion Scripts/Mac/RunFunctionalTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ sudo mkdir /GVFS.FT
sudo chown $USER /GVFS.FT

$SRCDIR/ProjFS.Mac/Scripts/LoadPrjFSKext.sh
$PUBLISHDIR/GVFS.FunctionalTests --full-suite
$PUBLISHDIR/GVFS.FunctionalTests --full-suite $2