-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
DataMovementTestBase
pull out shared functionality (#37493)
* move job part plan file utility out of testbase * file util * remove empty setup method * pull out and rename enum * remove dmlibtestbase from rehydrate tests * remove recordings
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Azure.Storage.Test | ||
{ | ||
public static class DataProvider | ||
{ | ||
public static Dictionary<string, string> BuildTags() | ||
=> new() | ||
{ | ||
{ "tagKey0", "tagValue0" }, | ||
{ "tagKey1", "tagValue1" } | ||
}; | ||
|
||
public static Dictionary<string, string> BuildMetadata() | ||
=> new(StringComparer.OrdinalIgnoreCase) | ||
{ | ||
{ "foo", "bar" }, | ||
{ "meta", "data" }, | ||
{ "Capital", "letter" }, | ||
{ "UPPER", "case" } | ||
}; | ||
|
||
public static string GetNewString(int length = 20, Random random = null) | ||
{ | ||
random ??= new Random(); | ||
var buffer = new char[length]; | ||
for (var i = 0; i < length; i++) | ||
{ | ||
buffer[i] = (char)('a' + random.Next(0, 25)); | ||
} | ||
return new string(buffer); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System.Collections.Generic; | ||
using System.IO; | ||
|
||
namespace Azure.Storage.Test.Shared | ||
{ | ||
internal static class FileUtil | ||
{ | ||
public static List<string> ListFileNamesRecursive(string directory) | ||
{ | ||
List<string> files = new List<string>(); | ||
|
||
// Create a queue of folders to enumerate files from, starting with provided path | ||
Queue<string> folders = new(); | ||
folders.Enqueue(directory); | ||
|
||
while (folders.Count > 0) | ||
{ | ||
// Grab a folder from the queue | ||
string dir = folders.Dequeue(); | ||
|
||
// Try to enumerate and queue all subdirectories of the current folder | ||
try | ||
{ | ||
foreach (string subdir in Directory.EnumerateDirectories(dir)) | ||
{ | ||
folders.Enqueue(subdir); | ||
} | ||
} | ||
catch | ||
{ | ||
// If we lack permissions to enumerate, throw if the caller specifies | ||
// that we shouldn't continue on error. | ||
// | ||
// TODO: Logging for missing permissions to enumerate folder | ||
// | ||
// Afterthought: once logging is implemented, we can just log any problems | ||
// (whether with given dir or subdir), and skip if told to/throw if not. No need for | ||
// the `dir == _basePath` check (which right now is just a filler signal | ||
// for something going wrong, as opposed to an "success" with an empty list). | ||
if (dir == directory) | ||
{ | ||
throw; | ||
} | ||
|
||
// Otherwise, just log the failed subdirectory and continue to list as many | ||
// files as accessible. | ||
continue; | ||
} | ||
|
||
// Send all files in the directory to the scan results | ||
foreach (string file in Directory.EnumerateFiles(dir)) | ||
{ | ||
files.Add(file); | ||
} | ||
} | ||
return files; | ||
} | ||
} | ||
} |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.