public static void SetupTest(TestContext context) { _adlsClient = SdkUnitTest.SetupSuperClient(); _adlsClient.DeleteRecursive(RemotePath); _adlsClient.CreateDirectory(RemotePath); AdlsClient.ConcatenateStreamListThreshold = 10; }
/// <summary> /// Setsup the super client and returns /// </summary> /// <returns></returns> private static AdlsClient SetupSuperClient() { string clientId = SdkUnitTest.ReadSetting("AccountOwnerClientId"); string clientSecret = SdkUnitTest.ReadSetting("AccountOwnerClientSecret"); string domain = SdkUnitTest.ReadSetting("Domain"); string clientAccountPath = SdkUnitTest.ReadSetting("Account"); var creds = new ClientCredential(clientId, clientSecret); ServiceClientCredentials clientCreds = ApplicationTokenProvider.LoginSilentAsync(domain, creds).GetAwaiter().GetResult(); return(AdlsClient.CreateClient(clientAccountPath, clientCreds)); }
public static void SetupClient(TestContext context) { _adlsClient = SdkUnitTest.SetupSuperClient(); _adlsClient.DeleteRecursive(RemotePath); _oneLevelDirCount = 3; _oneLevelFileCnt = 2; _recurseLevel = 3; _oneFileSize = 100; DataCreator.CreateDirRecursiveRemote(_adlsClient, UnitTestPath, _recurseLevel, _oneLevelDirCount, _oneLevelFileCnt, _oneLevelFileCnt, _oneFileSize, _oneFileSize); }
public static void SetupClient(TestContext context) { _nonOwner1ObjectId = SdkUnitTest.ReadSetting("NonOwner1ObjectId"); _nonOwner2ObjectId = SdkUnitTest.ReadSetting("NonOwner2ObjectId"); _group1Id = SdkUnitTest.ReadSetting("Group1Id"); _adlsClient = SetupSuperClient(); _adlsClient.DeleteRecursive("/Test2"); _oneLevelDirCount = 3; _oneLevelFileCnt = 2; _recurseLevel = 3; _oneFileSize = 100; DataCreator.CreateDirRecursiveRemote(_adlsClient, remotePath, _recurseLevel, _oneLevelDirCount, _oneLevelFileCnt, _oneLevelFileCnt, _oneFileSize, _oneFileSize); }
public static void SetupClassTests(TestContext context) { _adlsClient = SdkUnitTest.SetupSuperClient(); _adlsClient.DeleteRecursive(RemotePath); if (!Directory.Exists(LocalPath)) { Directory.CreateDirectory(LocalPath); } DataCreator.CreateDirRecursiveRemote(_adlsClient, RemotePathDownload, 2, 3, 3, 4, LowFileSize, HighFileSize, true); DataCreator.BuffSize = DataCreatorBuffSize; DataCreator.CreateDirRecursiveLocal(LocalPathUpload1, 1, 3, 3, 4, LowFileSize, HighFileSize, "", true); DataCreator.CreateDirRecursiveLocal(LocalPathUpload2, 1, 3, 3, 4, LowFileSize, HighFileSize, "", true); }
public void SerialCreateAndAppend() { int count = 3; string path = RemotePath + "/SerialCreateAndAppend"; int totLength = 8 * 1024 * 1024; string text1 = SdkUnitTest.RandomString(totLength); byte[] textByte1 = Encoding.UTF8.GetBytes(text1); for (int index = 0; index < count; index++) { using (var stream = _adlsClient.CreateFile(path + index, IfExists.Overwrite, _arrayPool, 4 * 1024 * 1024)) { // Flush in empty buffer, no return called stream.Flush(); // Rent called stream.Write(textByte1, 0, textByte1.Length); //Return called stream.Flush(); stream.Flush(); // Rent called stream.Write(textByte1, 0, textByte1.Length); // Rent should not be called stream.Write(textByte1, 0, textByte1.Length); } } ; Assert.IsTrue(_arrayPool.NumberOfRentCalled == count * 2); Assert.IsTrue(_arrayPool.NumberOfReturnCalled == count * 2); for (int index = 0; index < count; index++) { string output = ""; using (var istream = _adlsClient.GetReadStream(path + index)) { int noOfBytes; byte[] buffer = new byte[2 * 1024 * 1024]; do { noOfBytes = istream.Read(buffer, 0, buffer.Length); output += Encoding.UTF8.GetString(buffer, 0, noOfBytes); } while (noOfBytes > 0); } Assert.IsTrue(output.Equals(text1 + text1 + text1)); } ; _arrayPool.Reset(); }
public void TestRestry3() { int port = 8083; AdlsClient adlsClient = AdlsClient.CreateClientWithoutAccntValidation(MockWebServer.Host + ":" + port, TestToken); MockWebServer server = new MockWebServer(port); server.StartServer(); server.EnqueMockResponse(new MockResponse(502, "Bad Gateway")); server.EnqueMockResponse(new MockResponse(200, "OK")); adlsClient.SetInsecureHttp(); AdlsOutputStream ostream = null; try { ostream = adlsClient.CreateFile("/Test/dir", IfExists.Overwrite, ""); } catch (IOException) { Assert.Fail("The request should have passed"); } server.EnqueMockResponse(new MockResponse(502, "Bad Gateway")); server.EnqueMockResponse(new MockResponse(503, "Service Unavailable")); server.EnqueMockResponse(new MockResponse(504, "Gateway Timeout")); server.EnqueMockResponse(new MockResponse(503, "Service Unavailable")); server.EnqueMockResponse(new MockResponse(503, "Service Unavailable")); try { byte[] buff = Encoding.UTF8.GetBytes(SdkUnitTest.RandomString(5 * 1024 * 1024)); ostream.Write(buff, 0, buff.Length); Assert.Fail("The request should not have passed"); } catch (IOException) { } server.EnqueMockResponse(new MockResponse(200, "OK")); try { ostream.Dispose(); } catch (IOException) { Assert.Fail("This request should have passed"); } server.StopServer(); }
public static void SetupClient(TestContext context) { _adlsClient = SdkUnitTest.SetupSuperClient(); _adlsClient.DeleteRecursive(RemotePath); if (!Directory.Exists(LocalPath)) { Directory.CreateDirectory(LocalPath); } DataCreator.CreateDirRecursiveRemote(_adlsClient, RemotePathDownload, 2, 3, 3, 4, LowFileSize, HighFileSize, true); DataCreator.BuffSize = DataCreatorBuffSize; CopyFileJob.ReadForwardBuffSize = ReadBufferForwardSize; AdlsOutputStream.BufferCapacity = CopyBufferSize; // Below are the settings that forces download to be chunked for sizes greater than chunk size FileDownloader.SkipChunkingWeightThreshold = TransferChunkSize; FileDownloader.NumLargeFileThreshold = Int64.MaxValue; DataCreator.CreateDirRecursiveLocal(LocalPathUpload1, 1, 3, 3, 4, LowFileSize, HighFileSize, "", true); DataCreator.CreateDirRecursiveLocal(LocalPathUpload2, 1, 3, 3, 4, LowFileSize, HighFileSize, "", true); }
public static void SetupTest(TestContext context) { _shoudRunLinkTests = bool.Parse((string)context.Properties["LinkTestsEnabled"]); if (!_shoudRunLinkTests) { return; } // TODO Refactor this into separate functions methods LinkPath1 = context.Properties["LinkPaths"].ToString().Split(',')[0].TrimEnd('/'); int slashIndex = 0; // After the loop for LinkPath1 = /abc/def/xyz, createDirsRoot = {"/abc", "/abc/def/"} while (true) { slashIndex = LinkPath1.IndexOf('/', slashIndex + 1); if (slashIndex == -1) { break; } createDirsRoot.Add(LinkPath1.Substring(0, slashIndex)); } LinkPath1Root = createDirsRoot[0]; _adlsClient = SdkUnitTest.SetupSuperClient(); var random = new System.Random(); foreach (var dirRoot in createDirsRoot) { foreach (var index in Enumerable.Range(0, random.Next() % 7)) // Create between 0 to 6 directories { var dirName = dirRoot + SdkUnitTest.RandomString(10) + "/"; createdDirs.Add(dirName); _adlsClient.CreateDirectory(dirName); } } string text = "I am the first line"; byte[] textByte = Encoding.UTF8.GetBytes(text); foreach (var dirs in createdDirs) { foreach (var index in Enumerable.Range(0, random.Next() % 7)) // Create between 0 to 6 files { var fileName = dirs + SdkUnitTest.RandomString(10) + ".txt"; createdFiles.Add(fileName); using (var ostream = _adlsClient.CreateFile(fileName, IfExists.Overwrite)) { ostream.Write(textByte, 0, textByte.Length); } } } _aclEntriesToSet = new List <AclEntry>() { new AclEntry(AclType.user, SdkUnitTest.NonOwner1ObjectId, AclScope.Access, AclAction.ReadWrite), new AclEntry(AclType.user, SdkUnitTest.NonOwner2ObjectId, AclScope.Access, AclAction.WriteOnly), new AclEntry(AclType.user, SdkUnitTest.Group1Id, AclScope.Default, AclAction.WriteExecute) }; }
public static void SetupTest(TestContext context) { _arrayPool = new FixedStandardArrayPool <byte>(4 * 1024 * 1024, 2); _adlsClient = SdkUnitTest.SetupSuperClient(); }