Skip to content
Closed
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using GVFS.FunctionalTests.Tools;
using GVFS.Tests.Should;
using NUnit.Framework;
using System;

namespace GVFS.FunctionalTests.Tests.MultiEnlistmentTests
{
Expand All @@ -9,6 +10,19 @@ namespace GVFS.FunctionalTests.Tests.MultiEnlistmentTests
public class ServiceVerbTests : TestsWithMultiEnlistment
{
private static readonly string[] EmptyRepoList = new string[] { };
private readonly string fixtureServiceName = "Test.GVFS.Service.ServiceVerbTests." + Guid.NewGuid().ToString("N");

[OneTimeSetUp]
public void StartFixtureService()
{
GVFSServiceProcess.InstallService(this.fixtureServiceName);
}

[OneTimeTearDown]
public void StopFixtureService()
{
GVFSServiceProcess.UninstallService(this.fixtureServiceName);
}

[TestCase]
public void ServiceCommandsWithNoRepos()
Expand All @@ -21,20 +35,22 @@ public void ServiceCommandsWithNoRepos()
[TestCase]
public void ServiceCommandsWithMultipleRepos()
{
GVFSFunctionalTestEnlistment enlistment1 = this.CreateNewEnlistment();
GVFSFunctionalTestEnlistment enlistment2 = this.CreateNewEnlistment();
GVFSFunctionalTestEnlistment enlistment1 = this.CreateNewEnlistment(serviceName: this.fixtureServiceName);
GVFSFunctionalTestEnlistment enlistment2 = this.CreateNewEnlistment(serviceName: this.fixtureServiceName);

string[] repoRootList = new string[] { enlistment1.EnlistmentRoot, enlistment2.EnlistmentRoot };

GVFSProcess gvfsProcess1 = new GVFSProcess(
GVFSTestConfig.PathToGVFS,
enlistment1.EnlistmentRoot,
enlistment1.LocalCacheRoot);
enlistment1.LocalCacheRoot,
this.fixtureServiceName);

GVFSProcess gvfsProcess2 = new GVFSProcess(
GVFSTestConfig.PathToGVFS,
enlistment2.EnlistmentRoot,
enlistment2.LocalCacheRoot);
enlistment2.LocalCacheRoot,
this.fixtureServiceName);

this.RunServiceCommandAndCheckOutput("--list-mounted", expectedRepoRoots: repoRootList);
this.RunServiceCommandAndCheckOutput("--unmount-all", expectedRepoRoots: repoRootList);
Expand All @@ -57,14 +73,15 @@ public void ServiceCommandsWithMultipleRepos()
[TestCase]
public void ServiceCommandsWithMountAndUnmount()
{
GVFSFunctionalTestEnlistment enlistment1 = this.CreateNewEnlistment();
GVFSFunctionalTestEnlistment enlistment1 = this.CreateNewEnlistment(serviceName: this.fixtureServiceName);

string[] repoRootList = new string[] { enlistment1.EnlistmentRoot };

GVFSProcess gvfsProcess1 = new GVFSProcess(
GVFSTestConfig.PathToGVFS,
enlistment1.EnlistmentRoot,
enlistment1.LocalCacheRoot);
enlistment1.LocalCacheRoot,
this.fixtureServiceName);

this.RunServiceCommandAndCheckOutput("--list-mounted", expectedRepoRoots: repoRootList);

Expand All @@ -88,7 +105,8 @@ private void RunServiceCommandAndCheckOutput(string argument, string[] expectedR
GVFSProcess gvfsProcess = new GVFSProcess(
GVFSTestConfig.PathToGVFS,
enlistmentRoot: null,
localCacheRoot: null);
localCacheRoot: null,
serviceName: this.fixtureServiceName);

string result = gvfsProcess.RunServiceVerb(argument);
result.ShouldContain(expectedRepoRoots);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ protected virtual void OnTearDownEnlistmentsDeleted()
protected GVFSFunctionalTestEnlistment CreateNewEnlistment(
string localCacheRoot = null,
string branch = null,
bool skipPrefetch = false)
bool skipPrefetch = false,
string serviceName = null)
{
GVFSFunctionalTestEnlistment output = GVFSFunctionalTestEnlistment.CloneAndMount(
GVFSTestConfig.PathToGVFS,
branch,
localCacheRoot,
skipPrefetch);
skipPrefetch,
serviceName);
this.enlistmentsToDelete.Add(output);
return output;
}
Expand Down
35 changes: 26 additions & 9 deletions GVFS/GVFS.FunctionalTests/Tools/GVFSFunctionalTestEnlistment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,20 @@ public class GVFSFunctionalTestEnlistment
private static readonly string ZeroBackgroundOperations = "Background operations: 0" + Environment.NewLine;

private GVFSProcess gvfsProcess;
private readonly string serviceName;

private GVFSFunctionalTestEnlistment(string pathToGVFS, string enlistmentRoot, string repoUrl, string commitish, string localCacheRoot = null)
private GVFSFunctionalTestEnlistment(
string pathToGVFS,
string enlistmentRoot,
string repoUrl,
string commitish,
string localCacheRoot = null,
string serviceName = null)
{
this.EnlistmentRoot = enlistmentRoot;
this.RepoUrl = repoUrl;
this.Commitish = commitish;
this.serviceName = serviceName;

if (localCacheRoot == null)
{
Expand All @@ -43,7 +51,7 @@ private GVFSFunctionalTestEnlistment(string pathToGVFS, string enlistmentRoot, s
}

this.LocalCacheRoot = localCacheRoot;
this.gvfsProcess = new GVFSProcess(pathToGVFS, this.EnlistmentRoot, this.LocalCacheRoot);
this.gvfsProcess = new GVFSProcess(pathToGVFS, this.EnlistmentRoot, this.LocalCacheRoot, this.serviceName);
}

public string EnlistmentRoot
Expand All @@ -57,6 +65,7 @@ public string RepoUrl
}

public string LocalCacheRoot { get; }
public string ServiceName => this.serviceName;

public string RepoBackingRoot
{
Expand Down Expand Up @@ -102,24 +111,25 @@ public static GVFSFunctionalTestEnlistment CloneAndMountWithPerRepoCache(string
{
string enlistmentRoot = GVFSFunctionalTestEnlistment.GetUniqueEnlistmentRoot();
string localCache = GVFSFunctionalTestEnlistment.GetRepoSpecificLocalCacheRoot(enlistmentRoot);
return CloneAndMount(pathToGvfs, enlistmentRoot, null, localCache, skipPrefetch);
return CloneAndMount(pathToGvfs, enlistmentRoot, null, localCache, skipPrefetch, serviceName: null);
}

public static GVFSFunctionalTestEnlistment CloneAndMount(
string pathToGvfs,
string commitish = null,
string localCacheRoot = null,
bool skipPrefetch = false)
bool skipPrefetch = false,
string serviceName = null)
{
string enlistmentRoot = GVFSFunctionalTestEnlistment.GetUniqueEnlistmentRoot();
return CloneAndMount(pathToGvfs, enlistmentRoot, commitish, localCacheRoot, skipPrefetch);
return CloneAndMount(pathToGvfs, enlistmentRoot, commitish, localCacheRoot, skipPrefetch, serviceName);
}

public static GVFSFunctionalTestEnlistment CloneAndMountEnlistmentWithSpacesInPath(string pathToGvfs, string commitish = null)
public static GVFSFunctionalTestEnlistment CloneAndMountEnlistmentWithSpacesInPath(string pathToGvfs, string commitish = null, string serviceName = null)
{
string enlistmentRoot = GVFSFunctionalTestEnlistment.GetUniqueEnlistmentRootWithSpaces();
string localCache = GVFSFunctionalTestEnlistment.GetRepoSpecificLocalCacheRoot(enlistmentRoot);
return CloneAndMount(pathToGvfs, enlistmentRoot, commitish, localCache);
return CloneAndMount(pathToGvfs, enlistmentRoot, commitish, localCache, skipPrefetch: false, serviceName: serviceName);
}

public static string GetUniqueEnlistmentRoot()
Expand Down Expand Up @@ -387,14 +397,21 @@ public string GetObjectPathTo(string objectHash)
objectHash.Substring(2));
}

private static GVFSFunctionalTestEnlistment CloneAndMount(string pathToGvfs, string enlistmentRoot, string commitish, string localCacheRoot, bool skipPrefetch = false)
private static GVFSFunctionalTestEnlistment CloneAndMount(
string pathToGvfs,
string enlistmentRoot,
string commitish,
string localCacheRoot,
bool skipPrefetch = false,
string serviceName = null)
{
GVFSFunctionalTestEnlistment enlistment = new GVFSFunctionalTestEnlistment(
pathToGvfs,
enlistmentRoot ?? GetUniqueEnlistmentRoot(),
GVFSTestConfig.RepoToClone,
commitish ?? Properties.Settings.Default.Commitish,
localCacheRoot ?? GVFSTestConfig.LocalCacheRoot);
localCacheRoot ?? GVFSTestConfig.LocalCacheRoot,
serviceName);

try
{
Expand Down
8 changes: 6 additions & 2 deletions GVFS/GVFS.FunctionalTests/Tools/GVFSHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,13 @@ public static void ModifiedPathsShouldNotContain(GVFSFunctionalTestEnlistment en
}
}

public static string GetInternalParameter(string maintenanceJob = "null", string packfileMaintenanceBatchSize = "null")
public static string GetInternalParameter(
string maintenanceJob = "null",
string packfileMaintenanceBatchSize = "null",
string serviceName = null)
{
return $"\"{{\\\"ServiceName\\\":\\\"{GVFSServiceProcess.TestServiceName}\\\"," +
string effectiveServiceName = string.IsNullOrWhiteSpace(serviceName) ? GVFSServiceProcess.TestServiceName : serviceName;
return $"\"{{\\\"ServiceName\\\":\\\"{effectiveServiceName}\\\"," +
"\\\"StartedByService\\\":false," +
$"\\\"MaintenanceJob\\\":{maintenanceJob}," +
$"\\\"PackfileMaintenanceBatchSize\\\":{packfileMaintenanceBatchSize}}}\"";
Expand Down
18 changes: 12 additions & 6 deletions GVFS/GVFS.FunctionalTests/Tools/GVFSProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,23 @@ public class GVFSProcess
private readonly string pathToGVFS;
private readonly string enlistmentRoot;
private readonly string localCacheRoot;
private readonly string serviceName;

public GVFSProcess(GVFSFunctionalTestEnlistment enlistment)
: this(GVFSTestConfig.PathToGVFS, enlistment.EnlistmentRoot, Path.Combine(enlistment.EnlistmentRoot, GVFSTestConfig.DotGVFSRoot))
: this(
GVFSTestConfig.PathToGVFS,
enlistment.EnlistmentRoot,
Path.Combine(enlistment.EnlistmentRoot, GVFSTestConfig.DotGVFSRoot),
enlistment.ServiceName)
{
}

public GVFSProcess(string pathToGVFS, string enlistmentRoot, string localCacheRoot)
public GVFSProcess(string pathToGVFS, string enlistmentRoot, string localCacheRoot, string serviceName = null)
{
this.pathToGVFS = pathToGVFS;
this.enlistmentRoot = enlistmentRoot;
this.localCacheRoot = localCacheRoot;
this.serviceName = serviceName;
}

public void Clone(string repositorySource, string branchToCheckout, bool skipPrefetch)
Expand Down Expand Up @@ -141,13 +147,13 @@ public string LooseObjectStep()
return this.CallGVFS(
"dehydrate \"" + this.enlistmentRoot + "\"",
expectedExitCode: SuccessExitCode,
internalParameter: GVFSHelpers.GetInternalParameter("\\\"LooseObjects\\\""));
internalParameter: GVFSHelpers.GetInternalParameter("\\\"LooseObjects\\\"", serviceName: this.serviceName));
}

public string PackfileMaintenanceStep(long? batchSize)
{
string sizeString = batchSize.HasValue ? $"\\\"{batchSize.Value}\\\"" : "null";
string internalParameter = GVFSHelpers.GetInternalParameter("\\\"PackfileMaintenance\\\"", sizeString);
string internalParameter = GVFSHelpers.GetInternalParameter("\\\"PackfileMaintenance\\\"", sizeString, this.serviceName);
return this.CallGVFS(
"dehydrate \"" + this.enlistmentRoot + "\"",
expectedExitCode: SuccessExitCode,
Expand All @@ -156,7 +162,7 @@ public string PackfileMaintenanceStep(long? batchSize)

public string PostFetchStep()
{
string internalParameter = GVFSHelpers.GetInternalParameter("\\\"PostFetch\\\"");
string internalParameter = GVFSHelpers.GetInternalParameter("\\\"PostFetch\\\"", serviceName: this.serviceName);
return this.CallGVFS(
"dehydrate \"" + this.enlistmentRoot + "\"",
expectedExitCode: SuccessExitCode,
Expand Down Expand Up @@ -246,7 +252,7 @@ private string CallGVFS(string args, int expectedExitCode = DoNotCheckExitCode,

if (internalParameter == null)
{
internalParameter = GVFSHelpers.GetInternalParameter();
internalParameter = GVFSHelpers.GetInternalParameter(serviceName: this.serviceName);
}

processInfo.Arguments = args + " " + TestConstants.InternalUseOnlyFlag + " " + internalParameter;
Expand Down
Loading
Loading