public void Run(TestConfig config) { IDatabase db = config.GetDatabase(); Root root = new Root(); var r = new RecordFull(); root.r = r; db.Root = root; db.Commit(); // delete the object from the database r.Deallocate(); db.Commit(); db.Close(); db = config.GetDatabase(false); // r was explicitly deleted from the database but it's // still referenced by db.Root. Loading root object will // try to recursively load Record object but since it's // been deleted, we should get an exception Tests.AssertDatabaseException(() => { root = (Root)db.Root; }, DatabaseException.ErrorCode.DELETED_OBJECT); r = root.r; db.Close(); }
public void Run(TestConfig config) { int count = config.Count; var res = new TestResult(); config.Result = res; IDatabase db = config.GetDatabase(); IIndex<string, StringInt> root = (IIndex<string, StringInt>)db.Root; Tests.Assert(null == root); root = db.CreateIndex<string, StringInt>(IndexType.Unique); db.Root = root; string[] strs = new string[] { "one", "two", "three", "four" }; int no = 1; for (var i = 0; i < count; i++) { foreach (string s in strs) { var s2 = String.Format("{0}-{1}", s, i); var o = new StringInt(s, no++); root[s2] = o; } } CheckStrings(root, strs, count); db.Close(); db = config.GetDatabase(false); root = (IIndex<string, StringInt>)db.Root; Tests.Assert(null != root); CheckStrings(root, strs, count); db.Close(); }
public void Run(TestConfig config) { Debug.Assert(!config.IsTransient); IDatabase db = DatabaseFactory.CreateDatabase(); Tests.AssertDatabaseException( () => { var r = db.Root; }, DatabaseException.ErrorCode.DATABASE_NOT_OPENED); db = config.GetDatabase(); Root root = new Root(); var idx = db.CreateIndex<string, RecordFull>(IndexType.NonUnique); root.idx = idx; db.Root = root; db.Commit(); for (int i = 0; i < 10; i++) { var r = new RecordFull(i); idx.Put(r.StrVal, r); } var f = db.File; OsFile of = (OsFile)f; of.Close(); IDatabase db2 = config.GetDatabase(false); try { db.Close(); } catch { } db2.Close(); }
public BaseCalculationStrategy(ResultConfig resultConfig, TestConfig testConfig, IDictionary<Question, IList<IAnswerItem>> answers) { this.ResultConfig = resultConfig; this.TestConfig = testConfig; this.Answers = answers; this.Results = new List<IResultItem>(); }
public static void TestImages(TestConfig config, ProfileImages images) { Assert.IsTrue(images.Profiles.Count > 0); string profileSize = config.Client.Config.Images.ProfileSizes.First(); TestImagesInternal(config, images.Profiles.Select(s => s.FilePath), profileSize); }
public ConfigRoot() { Number = 5; Test = new TestConfig() { Number = 10 }; }
void addTest(string name, int spriteCount, bool animate, int workload) { TestConfig tst = new TestConfig(); tst.spriteCount = spriteCount; tst.TestName = name; tst.workload = workload; tst.animate = animate; this.queuedTests.Add (tst); }
private void AssertIndexedOr(int[] values, int expectedResultCount) { var config = new TestConfig (values.Length); while (config.MoveNext()) { AssertIndexedOr(values, expectedResultCount, config.RootIndex(), config.ConnectLeft ()); } }
public void Init() { NetcoLogger.LoggerFactory = new ConsoleLoggerFactory(); const string credentialsFilePath = @"..\..\Files\AmazonCredentials.csv"; var cc = new CsvContext(); this.Config = cc.Read< TestConfig >( credentialsFilePath, new CsvFileDescription { FirstLineHasColumnNames = true, IgnoreUnknownColumns = true } ).FirstOrDefault(); if( this.Config != null ) this.AmazonFactory = new AmazonFactory( this.Config.AccessKeyId, this.Config.SecretAccessKeyId ); }
private static void TestImagesInternal(TestConfig config, IEnumerable<string> images, string posterSize) { foreach (string imageData in images) { Uri url = config.Client.GetImageUrl(posterSize, imageData); Uri urlSecure = config.Client.GetImageUrl(posterSize, imageData, true); Assert.IsTrue(TestHelpers.InternetUriExists(url)); Assert.IsTrue(TestHelpers.InternetUriExists(urlSecure)); } }
public void Initialize() { // setup a default config this.testConfig = new TestConfig { LogFileName = "default.log", LogFilePath = @".\logs", LogLevel = Configuration.LogLevel.Info, LogLimitInKiloBytes = 5000, }; }
public static void LoadConfigurationFile(TestConfig config) { string configFileName = string.Format(FullFileNameFormat, Assembly.GetExecutingAssembly().GetName().Name); string fileToCopy = string.Format(CopyFileNameFormat, config); if(File.Exists(configFileName)) File.Delete(configFileName); File.Copy(fileToCopy, configFileName,true); AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE",configFileName); typeof(ConfigurationManager).GetField("s_initState", BindingFlags.NonPublic | BindingFlags.Static).SetValue(null, 0); }
public static void TestImages(TestConfig config, Images images) { Assert.IsTrue(images.Backdrops.Count > 0); Assert.IsTrue(images.Posters.Count > 0); string backdropSize = config.Client.Config.Images.BackdropSizes.First(); string posterSize = config.Client.Config.Images.PosterSizes.First(); TestImagesInternal(config, images.Backdrops.Select(s => s.FilePath), backdropSize); TestImagesInternal(config, images.Posters.Select(s => s.FilePath), posterSize); }
public void ConsistencyTest() { concurrentUpdateLog = new ConcurrentDictionary<string, ConcurrentBag<string>>(); var testConfig = new TestConfig(2, 55); concurrentUpdatesCount = 0; TestDoc[] documents; var expectedVersionLog = String.Empty; for (int i = 1; i <= testConfig.NumberOfUpdatesPerDocument; i++) expectedVersionLog += (i + ";"); using(var documentStore = NewRemoteDocumentStore(requestedStorage:"esent",runInMemory:false)) { if(documentStore.DatabaseCommands.GetStatistics().SupportsDtc == false) return; documentStore.Conventions.ShouldCacheRequest = url => false; documentStore.Conventions.ShouldAggressiveCacheTrackChanges = false; documentStore.Conventions.ShouldSaveChangesForceAggressiveCacheCheck = false; documentStore.JsonRequestFactory.DisableAllCaching(); var documentIds = RunParallelUpdates(testConfig, documentStore); documents = LoadAllDocuments(documentIds, documentStore); Trace.WriteLine(string.Format("Number of concurrency exceptions: {0}", concurrencyExceptionCount)); Trace.WriteLine(string.Format("Number of updates: {0}", documents.Sum(d => d.Version))); } Assert.Equal(documents.Length, testConfig.NumberOfDocuments); Assert.Equal(testConfig.NumberOfDocuments * testConfig.NumberOfUpdatesPerDocument, concurrentUpdatesCount); foreach (var docKvp in concurrentUpdateLog) { var docVersionLogSteps = docKvp.Value.OrderBy(row => row.Length).ToList(); expectedVersionLog = String.Empty; Trace.WriteLine("doc key : " + docKvp.Key); //validate that steps for each document were submitted only once for (int i = 1; i <= testConfig.NumberOfUpdatesPerDocument; i++) { expectedVersionLog += (i + ";"); Trace.WriteLine(expectedVersionLog); Assert.True(docVersionLogSteps.Count(versionLog => versionLog.Equals(expectedVersionLog)) == 1); //must occur exactly once } } foreach (var document in documents) Assert.Equal(document.VersionLog, expectedVersionLog); Assert.True(documents.All(d => d.Version == testConfig.NumberOfUpdatesPerDocument)); }
public void TestBlobImpl(TestConfig config) { int n; IDatabase db = config.GetDatabase(false); IBlob blob = db.CreateBlob(); Stream blobStrm = blob.GetStream(); byte[] b = new byte[] { 1, 2, 3, 4, 5, 6}; byte[] b2 = new byte[6]; blobStrm.Write(b, 0, b.Length); Tests.Assert(blobStrm.CanRead); Tests.Assert(blobStrm.CanSeek); Tests.Assert(blobStrm.CanWrite); long len = 6; long pos = 3; Tests.Assert(blobStrm.Length == len); blobStrm.Flush(); Tests.Assert(6 == blobStrm.Position); blobStrm.Position = pos; Tests.Assert(pos == blobStrm.Position); Tests.AssertException<ArgumentException>(() => { blobStrm.Position = -1; }); blobStrm.Seek(0, SeekOrigin.Begin); Tests.Assert(0 == blobStrm.Position); n = blobStrm.Read(b2, 0, 6); Tests.Assert(n == 6); Tests.Assert(ByteArraysEqual(b, b2)); Tests.Assert(6 == blobStrm.Position); n = blobStrm.Read(b2, 0, 1); Tests.Assert(n == 0); blobStrm.Seek(0, SeekOrigin.Begin); blobStrm.Seek(3, SeekOrigin.Current); Tests.Assert(3 == blobStrm.Position); blobStrm.Read(b2, 0, 3); Tests.Assert(6 == blobStrm.Position); Tests.Assert(b2[0] == 4); blobStrm.Seek(-3, SeekOrigin.End); Tests.Assert(3 == blobStrm.Position); Tests.AssertException<ArgumentException>(() => { blobStrm.Seek(-10, SeekOrigin.Current); }); blobStrm.Seek(0, SeekOrigin.End); Tests.Assert(len == blobStrm.Position); blobStrm.Write(b, 0, b.Length); len += b.Length; Tests.Assert(blobStrm.Length == len); blobStrm.SetLength(8); Tests.Assert(blobStrm.Length == 8); blobStrm.SetLength(20); Tests.Assert(blobStrm.Length == 20); blob.Deallocate(); }
public void Run(TestConfig config) { int count = config.Count; var res = new TestRawResult(); config.Result = res; int nHashMembers = count * 10; var start = DateTime.Now; IDatabase db = config.GetDatabase(); TestRaw root = (TestRaw)db.Root; if (count % 2 != 0) { // Silence compiler about unused nil variable. // This shouldn't happen since we never pass count // that is an odd number Debug.Assert(false); root.nil = new object(); } root = new TestRaw(); Tests.Assert(root.nil == null); L1List list = null; for (int i = 0; i < count; i++) { list = new L1List(i, list); } root.list = list; root.map = new Hashtable(); for (int i = 0; i < nHashMembers; i++) { root.map["key-" + i] = "value-" + i; } db.Root = root; res.InsertTime = DateTime.Now - start; start = DateTime.Now; L1List elem = root.list; for (int i = count; --i >= 0; ) { Tests.Assert(elem.obj.Equals(i)); elem = elem.next; } for (int i = nHashMembers; --i >= 0; ) { Tests.Assert(root.map["key-" + i].Equals("value-" + i)); } res.TraverseTime = DateTime.Now - start; db.Close(); }
// TODO: use more databases from TestConfig public void Run(TestConfig config) { config.Result = new TestResult(); bool ack = false; bool async = true; int port = defaultPort; // start the master thread int nIterations = config.Count; Thread t1 = new Thread(() => { Master(port, async, ack, nIterations); }); t1.Name = "ReplicMaster"; t1.Start(); Thread t2 = new Thread(() => { Slave(port, async, ack); }); t2.Name = "ReplicSlave"; t2.Start(); t1.Join(); t2.Join(); }
public void Run(TestConfig config) { int count = config.Count; var res = new TestConcurResult(); config.Result = res; TestConcur.nElements = count; var start = DateTime.Now; db = config.GetDatabase(); L2List list = (L2List)db.Root; Tests.Assert(list == null); list = new L2List(); list.head = new L2Elem(); list.head.next = list.head.prev = list.head; db.Root = list; for (int i = 1; i < nElements; i++) { L2Elem elem = new L2Elem(); elem.count = i; elem.linkAfter(list.head); } res.InsertTime = DateTime.Now - start; start = DateTime.Now; Thread[] threads = new Thread[nThreads]; for (int i = 0; i < nThreads; i++) { threads[i] = new Thread(new ThreadStart(run)); threads[i].Start(); } #if !CF for (int i = 0; i < nThreads; i++) { threads[i].Join(); } #endif db.Close(); res.AccessTime = DateTime.Now - start; }
public void Run(TestConfig config) { int count = config.Count; var res = new TestGcResult(); config.Result = res; IDatabase db = config.GetDatabase(); Root root = new Root(); IIndex<string, PObject> strIndex = root.strIndex = db.CreateIndex<string, PObject>(IndexType.Unique); IIndex<long, PObject> intIndex = root.intIndex = db.CreateIndex<long, PObject>(IndexType.Unique); db.Root = root; long insKey = 1999; long remKey = 1999; for (int i = 0; i < count; i++) { if (i > nObjectsInTree) { remKey = (3141592621L * remKey + 2718281829L) % 1000000007L; intIndex.Remove(new Key(remKey)); strIndex.Remove(new Key(remKey.ToString())); } PObject obj = new PObject(); insKey = (3141592621L * insKey + 2718281829L) % 1000000007L; obj.intKey = insKey; obj.strKey = insKey.ToString(); obj.next = new PObject(); intIndex[obj.intKey] = obj; strIndex[obj.strKey] = obj; if (i > 0) { Tests.Assert(root.list.intKey == i - 1); } root.list = new PObject(); root.list.intKey = i; root.Store(); if (i % 1000 == 0) db.Commit(); } db.Close(); }
public static void TestImages(TestConfig config, Images images) { Assert.IsTrue(images.Backdrops.Count > 0); Assert.IsTrue(images.Posters.Count > 0); Debug.WriteLine("Found {0} backdrops, {1} posters.", images.Backdrops.Count, images.Posters.Count); List<string> backdropSizes = config.Client.Config.Images.BackdropSizes; List<string> posterSizes = config.Client.Config.Images.PosterSizes; Debug.WriteLine("Found {0} backdrop sizes, {1} poster sizes.", backdropSizes.Count, posterSizes.Count); Debug.WriteLine("Total: {0} backdrops", images.Backdrops.Count * backdropSizes.Count); foreach (ImageData imageData in images.Backdrops) { foreach (string size in backdropSizes) { Uri url = config.Client.GetImageUrl(size, imageData.FilePath); Uri urlSecure = config.Client.GetImageUrl(size, imageData.FilePath, true); Assert.IsTrue(TestHelpers.InternetUriExists(url)); Assert.IsTrue(TestHelpers.InternetUriExists(urlSecure)); } } Debug.WriteLine("Total: {0} posters", images.Posters.Count * posterSizes.Count); foreach (ImageData imageData in images.Posters) { foreach (string size in posterSizes) { Uri url = config.Client.GetImageUrl(size, imageData.FilePath); Uri urlSecure = config.Client.GetImageUrl(size, imageData.FilePath, true); Assert.IsTrue(TestHelpers.InternetUriExists(url)); Assert.IsTrue(TestHelpers.InternetUriExists(urlSecure)); } } }
public void Run(TestConfig config) { var res = new TestBlobResult(); config.Result = res; string dir = FindSrcImplDirectory(); if (null == dir) { res.Ok = false; return; } string[] files = Directory.GetFiles(dir, "*.cs"); res.Count = files.Length; var start = DateTime.Now; InsertFiles(config, files); res.InsertTime = DateTime.Now - start; start = DateTime.Now; VerifyFiles(config, files); res.ReadTime = DateTime.Now - start; TestBlobImpl(config); }
public void LoggingIsConfiguredProperly() { this.testConfig = new TestConfig { LogLevel = Configuration.LogLevel.Error, LogFilePath = @".\path\to\logs", LogFileName = "test_log.log", LogLimitInKiloBytes = 10000, }; Logger logger = Logger.GetLogger("LoggerTests", this.testConfig); LoggingConfiguration nLogConfig = NLogManager.Configuration; Assert.AreEqual(2, nLogConfig.AllTargets.Count, "There should be exactly 2 targets"); Target consoleTarget = nLogConfig.AllTargets.FirstOrDefault(t => t.Name.Equals("Console", StringComparison.InvariantCultureIgnoreCase)); Assert.IsNotNull(consoleTarget, "There is no console target"); FileTarget fileTarget = (FileTarget)nLogConfig.AllTargets.FirstOrDefault(t => t.Name.Equals("File", StringComparison.InvariantCultureIgnoreCase)); Assert.IsNotNull(fileTarget, "There is no file target"); Assert.IsTrue(fileTarget.FileName.ToString().Contains(Path.Combine(this.testConfig.LogFilePath, this.testConfig.LogFileName)), "The file name is incorrect."); Assert.AreEqual(this.testConfig.LogLimitInKiloBytes * 1024, fileTarget.ArchiveAboveSize, "The log limit is incorrect."); }
void InsertFiles(TestConfig config, string[] files) { int rc; byte[] buf = new byte[1024]; IDatabase db = config.GetDatabase(); IIndex<string, IBlob> root = (IIndex<string, IBlob>)db.Root; Tests.Assert(root == null); root = db.CreateIndex<string, IBlob>(IndexType.Unique); db.Root = root; foreach (string file in files) { FileStream fin = new FileStream(file, FileMode.Open, FileAccess.Read); IBlob blob = db.CreateBlob(); Stream bout = blob.GetStream(); while ((rc = fin.Read(buf, 0, buf.Length)) > 0) { bout.Write(buf, 0, rc); } root[file] = blob; fin.Close(); bout.Close(); } db.Close(); }
public XamlTest() { TestConfig.Start(); _renderer = ServiceLocator.Current.GetService <IRenderer>(); }
public ActivatorCreationStrategy(ObjectBuilder objectBuilder, ArgumentsForConstructors argumentsForConstructors, TestConfig testConfig) { _objectBuilder = objectBuilder; _argumentsForConstructors = argumentsForConstructors; _testConfig = testConfig; }
/// <summary> /// Starts a newly created project from the web API project template without a given set of project options. /// </summary> /// <param name="outputWriter">The output logger to add telemetry information during the creation and startup process.</param> /// <returns> /// A web API project with a full set of endpoint services to interact with the API. /// </returns> public static async Task <WebApiProject> StartNewAsync(ITestOutputHelper outputWriter) { Guard.NotNull(outputWriter, nameof(outputWriter), "Cannot create web API services without a test output logger"); return(await StartNewAsync(TestConfig.Create(), outputWriter)); }
public ConfigurationServiceManager(string headerName = "X-IDENTITY", string headerValue = "SERVICE=HRBC") : base(TestConfig.GetValueFromConfig("ConfigurationServiceURL")) { if (headerName != null && headerValue != null) { Connection.DeleteAllCookies(); Connection.Headers.Clear(); AddHeader(headerName, headerValue); } }
public void DurableHandleV2_WithLeaseV2_WithoutHandleCaching() { /// 1. Client requests a durable handle with LeaseV2 context, SMB2_LEASE_HANDLE_CACHING bit is not set in LeaseState. /// 2. Durable Handle v2 is not granted. /// #region Check Applicability TestConfig.CheckDialect(DialectRevision.Smb30); TestConfig.CheckCapabilities(NEGOTIATE_Response_Capabilities_Values.GLOBAL_CAP_LEASING); TestConfig.CheckCreateContext(CreateContextTypeValue.SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2, CreateContextTypeValue.SMB2_CREATE_REQUEST_LEASE_V2); #endregion string content = Smb2Utility.CreateRandomString(testConfig.WriteBufferLengthInKb); Guid clientGuid = Guid.NewGuid(); durableHandleUncSharePath = Smb2Utility.GetUncPath(testConfig.SutComputerName, testConfig.BasicFileShare); string fileName = GetTestFileName(durableHandleUncSharePath); #region client connect to server BaseTestSite.Log.Add( LogEntryKind.Comment, "Client connects to server and opens file with a durable handle v2, SMB2_LEASE_HANDLE_CACHING bit is not set in LeaseState."); uint treeIdBeforeDisconnection; Connect(DialectRevision.Smb30, clientBeforeDisconnection, clientGuid, testConfig.AccountCredential, ConnectShareType.BasicShareWithoutAssert, out treeIdBeforeDisconnection, null); Guid createGuid = Guid.NewGuid(); Guid leaseKey = Guid.NewGuid(); // SMB2_LEASE_HANDLE_CACHING bit is not set in LeaseState LeaseStateValues leaseState = LeaseStateValues.SMB2_LEASE_READ_CACHING | LeaseStateValues.SMB2_LEASE_WRITE_CACHING; FILEID fileIdBeforeDisconnection; Smb2CreateContextResponse[] serverCreateContexts = null; status = clientBeforeDisconnection.Create( treeIdBeforeDisconnection, fileName, CreateOptions_Values.FILE_NON_DIRECTORY_FILE, out fileIdBeforeDisconnection, out serverCreateContexts, RequestedOplockLevel_Values.OPLOCK_LEVEL_LEASE, new Smb2CreateContextRequest[] { new Smb2CreateDurableHandleRequestV2 { CreateGuid = createGuid, }, new Smb2CreateRequestLeaseV2 { LeaseKey = leaseKey, LeaseState = leaseState, } }, shareAccess: ShareAccess_Values.NONE, checker: (header, response) => { BaseTestSite.Assert.AreEqual( Smb2Status.STATUS_SUCCESS, header.Status, "{0} should be successful, actually server returns {1}.", header.Command, Smb2Status.GetStatusCode(header.Status)); // Durable Handle should not be granted. CheckCreateContextResponsesNotExist( serverCreateContexts, new DefaultDurableHandleV2ResponseChecker( BaseTestSite, 0, uint.MaxValue)); }); #endregion clientBeforeDisconnection.TreeDisconnect(treeIdBeforeDisconnection); clientBeforeDisconnection.LogOff(); clientBeforeDisconnection.Disconnect(); }
public WorkflowTest() { TestConfig.Start(); _dbContext = ServiceLocator.Current.GetService <IDbContext>(); _workflow = ServiceLocator.Current.GetService <IWorkflowEngine>(); }
public void Initialize() { TestConfig config = JsonConvert.DeserializeObject <TestConfig>(File.ReadAllText("ApiKey.txt")); MIF.SetConfigForTesting(config); }
public void BVT_SetGetIntegrityInfo() { #region Check Applicability TestConfig.CheckDialect(DialectRevision.Smb30); TestConfig.CheckIOCTL(CtlCode_Values.FSCTL_SET_INTEGRITY_INFORMATION, CtlCode_Values.FSCTL_GET_INTEGRITY_INFORMATION); #endregion client.ConnectToServer(TestConfig.UnderlyingTransport, TestConfig.SutComputerName, TestConfig.SutIPAddress); BaseTestSite.Log.Add(LogEntryKind.TestStep, "Client creates a file by sending the following requests: NEGOTIATE; SESSION_SETUP; TREE_CONNECT; CREATE"); status = client.Negotiate( TestConfig.RequestDialects, TestConfig.IsSMB1NegotiateEnabled, checker: (Packet_Header header, NEGOTIATE_Response response) => { BaseTestSite.Assert.AreEqual( Smb2Status.STATUS_SUCCESS, header.Status, "Negotiation should succeed, actually server returns {0}.", Smb2Status.GetStatusCode(header.Status)); TestConfig.CheckNegotiateDialect(DialectRevision.Smb30, response); }); status = client.SessionSetup( TestConfig.DefaultSecurityPackage, TestConfig.SutComputerName, TestConfig.AccountCredential, TestConfig.UseServerGssToken); uint treeId; string uncSharePath = Smb2Utility.GetUncPath(TestConfig.SutComputerName, TestConfig.FileShareSupportingIntegrityInfo); status = client.TreeConnect(uncSharePath, out treeId); FILEID fileId; Smb2CreateContextResponse[] serverCreateContexts; status = client.Create( treeId, fileName, CreateOptions_Values.FILE_NON_DIRECTORY_FILE, out fileId, out serverCreateContexts); FSCTL_GET_INTEGRITY_INFO_OUTPUT getIntegrityInfo; BaseTestSite.Log.Add(LogEntryKind.TestStep, "Client sends IOCTL request with FSCTL_GET_INTEGRITY_INFORMATION."); status = client.GetIntegrityInfo(treeId, fileId, out getIntegrityInfo); BaseTestSite.Log.Add( LogEntryKind.Debug, "Integrity info returned in FSCTL_GET_INTEGRITY_INFO request: ChecksumAlgorithm {0}, Flags {1}, ChecksumChunkSizeInBytes {2}, ClusterSizeInBytes {3}", getIntegrityInfo.ChecksumAlgorithm, getIntegrityInfo.Flags, getIntegrityInfo.ChecksumChunkSizeInBytes, getIntegrityInfo.ClusterSizeInBytes); FSCTL_SET_INTEGRIY_INFO_INPUT setIntegrityInfo; setIntegrityInfo.ChecksumAlgorithm = FSCTL_SET_INTEGRITY_INFO_INPUT_CHECKSUMALGORITHM.CHECKSUM_TYPE_CRC64; setIntegrityInfo.Flags = FSCTL_SET_INTEGRITY_INFO_INPUT_FLAGS.FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF; setIntegrityInfo.Reserved = FSCTL_SET_INTEGRITY_INFO_INPUT_RESERVED.V1; byte[] buffer = TypeMarshal.ToBytes <FSCTL_SET_INTEGRIY_INFO_INPUT>(setIntegrityInfo); BaseTestSite.Log.Add( LogEntryKind.Debug, "Attempt to set integrity info with ChecksumAlgrithm {0}, Flags {1}", setIntegrityInfo.ChecksumAlgorithm, setIntegrityInfo.Flags); BaseTestSite.Log.Add(LogEntryKind.TestStep, "Client sends IOCTL request with FSCTL_SET_INTEGRITY_INFORMATION after changed the value of the following fields in FSCTL_SET_INTEGRIY_INFO_INPUT: ChecksumAlgorithm, Flags, Reserved."); status = client.SetIntegrityInfo(treeId, fileId, buffer); BaseTestSite.Log.Add(LogEntryKind.TestStep, "Client sends IOCTL request with FSCTL_GET_INTEGRITY_INFORMATION."); status = client.GetIntegrityInfo(treeId, fileId, out getIntegrityInfo); BaseTestSite.Log.Add( LogEntryKind.Debug, "Current ChecksumAlgorithm is " + getIntegrityInfo.ChecksumAlgorithm); BaseTestSite.Assert.AreEqual( (ushort)setIntegrityInfo.ChecksumAlgorithm, (ushort)getIntegrityInfo.ChecksumAlgorithm, "ChecksumAlgorithm field after set should be {0}, actual value is {1}", setIntegrityInfo.ChecksumAlgorithm, getIntegrityInfo.ChecksumAlgorithm); BaseTestSite.Log.Add( LogEntryKind.Debug, "Current Flags is " + getIntegrityInfo.Flags); BaseTestSite.Assert.AreEqual( (uint)setIntegrityInfo.Flags, (uint)getIntegrityInfo.Flags, "Flags field after set should be {0}, actual value is {1}", setIntegrityInfo.Flags, getIntegrityInfo.Flags); BaseTestSite.Log.Add(LogEntryKind.TestStep, "Tear down the client by sending the following requests: CLOSE; TREE_DISCONNECT; LOG_OFF."); status = client.Close(treeId, fileId); status = client.TreeDisconnect(treeId); status = client.LogOff(); }
private void DurableHandleV2_Reconnect_WithLeaseV1(bool sameFileName, bool persistent = false) { #region Check Applicability TestConfig.CheckDialect(DialectRevision.Smb30); TestConfig.CheckCapabilities( persistent ? NEGOTIATE_Response_Capabilities_Values.GLOBAL_CAP_LEASING | NEGOTIATE_Response_Capabilities_Values.GLOBAL_CAP_PERSISTENT_HANDLES : NEGOTIATE_Response_Capabilities_Values.GLOBAL_CAP_LEASING); TestConfig.CheckCreateContext(CreateContextTypeValue.SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2, CreateContextTypeValue.SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2, CreateContextTypeValue.SMB2_CREATE_REQUEST_LEASE); #endregion string content = Smb2Utility.CreateRandomString(testConfig.WriteBufferLengthInKb); Guid clientGuid = Guid.NewGuid(); durableHandleUncSharePath = persistent ? Smb2Utility.GetUncPath(testConfig.CAShareServerName, testConfig.CAShareName) : Smb2Utility.GetUncPath(testConfig.SutComputerName, testConfig.BasicFileShare); string fileName = GetTestFileName(durableHandleUncSharePath); #region client connect to server BaseTestSite.Log.Add( LogEntryKind.Comment, "Client connects to server and opens file with a {0} handle", persistent ? "persistent" : "durable"); uint treeIdBeforeDisconnection; Connect( DialectRevision.Smb30, clientBeforeDisconnection, clientGuid, testConfig.AccountCredential, persistent ? ConnectShareType.CAShare : ConnectShareType.BasicShareWithoutAssert, out treeIdBeforeDisconnection, null); Guid createGuid = Guid.NewGuid(); Guid leaseKey = Guid.NewGuid(); LeaseStateValues leaseState = LeaseStateValues.SMB2_LEASE_READ_CACHING | LeaseStateValues.SMB2_LEASE_HANDLE_CACHING | LeaseStateValues.SMB2_LEASE_WRITE_CACHING; FILEID fileIdBeforeDisconnection; Smb2CreateContextResponse[] serverCreateContexts = null; status = clientBeforeDisconnection.Create( treeIdBeforeDisconnection, fileName, CreateOptions_Values.FILE_NON_DIRECTORY_FILE, out fileIdBeforeDisconnection, out serverCreateContexts, RequestedOplockLevel_Values.OPLOCK_LEVEL_LEASE, new Smb2CreateContextRequest[] { new Smb2CreateDurableHandleRequestV2 { CreateGuid = createGuid, Flags = persistent? CREATE_DURABLE_HANDLE_REQUEST_V2_Flags.DHANDLE_FLAG_PERSISTENT : 0, }, new Smb2CreateRequestLease { LeaseKey = leaseKey, LeaseState = leaseState, } }, shareAccess: ShareAccess_Values.NONE, checker: (header, response) => { BaseTestSite.Assert.AreEqual( Smb2Status.STATUS_SUCCESS, header.Status, "{0} should be successful, actually server returns {1}.", header.Command, Smb2Status.GetStatusCode(header.Status)); CheckCreateContextResponses( serverCreateContexts, new DefaultDurableHandleV2ResponseChecker( BaseTestSite, persistent ? CREATE_DURABLE_HANDLE_RESPONSE_V2_Flags.DHANDLE_FLAG_PERSISTENT : 0, uint.MaxValue)); }); status = clientBeforeDisconnection.Write(treeIdBeforeDisconnection, fileIdBeforeDisconnection, content); #endregion clientBeforeDisconnection.Disconnect(); #region client reconnect to server BaseTestSite.Log.Add( LogEntryKind.Comment, "Client opens the same file and reconnects the {0} handle", persistent ? "durable" : "persistent"); uint treeIdAfterDisconnection; Connect( DialectRevision.Smb30, clientAfterDisconnection, clientGuid, testConfig.AccountCredential, persistent ? ConnectShareType.CAShare : ConnectShareType.BasicShareWithoutAssert, out treeIdAfterDisconnection, clientBeforeDisconnection); FILEID fileIdAfterDisconnection; status = clientAfterDisconnection.Create( treeIdAfterDisconnection, sameFileName ? fileName : GetTestFileName(durableHandleUncSharePath), CreateOptions_Values.FILE_NON_DIRECTORY_FILE, out fileIdAfterDisconnection, out serverCreateContexts, RequestedOplockLevel_Values.OPLOCK_LEVEL_LEASE, new Smb2CreateContextRequest[] { new Smb2CreateDurableHandleReconnectV2 { CreateGuid = createGuid, Flags = persistent ? CREATE_DURABLE_HANDLE_RECONNECT_V2_Flags.DHANDLE_FLAG_PERSISTENT : 0, FileId = new FILEID { Persistent = fileIdBeforeDisconnection.Persistent } }, new Smb2CreateRequestLease { LeaseKey = leaseKey, LeaseState = leaseState, } }, shareAccess: ShareAccess_Values.NONE, checker: (header, response) => { }); if (sameFileName) { BaseTestSite.Assert.AreEqual(Smb2Status.STATUS_SUCCESS, status, "Reconnect a durable handle should be successful"); string readContent; status = clientAfterDisconnection.Read(treeIdAfterDisconnection, fileIdAfterDisconnection, 0, (uint)content.Length, out readContent); BaseTestSite.Assert.IsTrue( readContent.Equals(content), "The written content should equal to read content."); clientAfterDisconnection.Close(treeIdAfterDisconnection, fileIdAfterDisconnection); } else { BaseTestSite.Assert.AreEqual( Smb2Status.STATUS_INVALID_PARAMETER, status, "If Open.Lease is not NULL and Open.FileName does not match the file name specified in the Buffer field of the SMB2 CREATE request, " + "the server MUST fail the request with STATUS_INVALID_PARAMETER."); } #endregion clientAfterDisconnection.TreeDisconnect(treeIdAfterDisconnection); clientAfterDisconnection.LogOff(); clientAfterDisconnection.Disconnect(); }
public void DurableHandleV2_Reconnect_WithoutPersistence() { /// 1. Client requests a durable handle V2 without persistent flag /// 2. Lose connection by disabling NIC /// 3. Client reconnects the durable handle V2 without persistent flag. #region Check Applicability TestConfig.CheckDialect(DialectRevision.Smb30); TestConfig.CheckCapabilities(NEGOTIATE_Response_Capabilities_Values.GLOBAL_CAP_LEASING); TestConfig.CheckCreateContext(CreateContextTypeValue.SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2, CreateContextTypeValue.SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2, CreateContextTypeValue.SMB2_CREATE_REQUEST_LEASE); #endregion string content = Smb2Utility.CreateRandomString(testConfig.WriteBufferLengthInKb); Guid clientGuid = Guid.NewGuid(); durableHandleUncSharePath = Smb2Utility.GetUncPath(testConfig.SutComputerName, testConfig.BasicFileShare); string fileName = GetTestFileName(durableHandleUncSharePath); #region client connect to server BaseTestSite.Log.Add( LogEntryKind.Comment, "Client connects to server and opens file with a durable handle"); uint treeIdBeforeDisconnection; Connect(DialectRevision.Smb30, clientBeforeDisconnection, clientGuid, testConfig.AccountCredential, ConnectShareType.BasicShareWithoutAssert, out treeIdBeforeDisconnection, null); Guid createGuid = Guid.NewGuid(); Guid leaseKey = Guid.NewGuid(); LeaseStateValues leaseState = LeaseStateValues.SMB2_LEASE_READ_CACHING | LeaseStateValues.SMB2_LEASE_HANDLE_CACHING | LeaseStateValues.SMB2_LEASE_WRITE_CACHING; FILEID fileIdBeforeDisconnection; Smb2CreateContextResponse[] serverCreateContexts = null; clientBeforeDisconnection.Create( treeIdBeforeDisconnection, fileName, CreateOptions_Values.FILE_NON_DIRECTORY_FILE, out fileIdBeforeDisconnection, out serverCreateContexts, RequestedOplockLevel_Values.OPLOCK_LEVEL_LEASE, new Smb2CreateContextRequest[] { new Smb2CreateDurableHandleRequestV2 { CreateGuid = createGuid, }, new Smb2CreateRequestLeaseV2 { LeaseKey = leaseKey, LeaseState = leaseState, } }, shareAccess: ShareAccess_Values.NONE, checker: (header, response) => { BaseTestSite.Assert.AreEqual( Smb2Status.STATUS_SUCCESS, header.Status, "{0} should be successful, actually server returns {1}.", header.Command, Smb2Status.GetStatusCode(header.Status)); CheckCreateContextResponses(serverCreateContexts, new DefaultDurableHandleV2ResponseChecker(BaseTestSite, 0, uint.MaxValue)); }); clientBeforeDisconnection.Write(treeIdBeforeDisconnection, fileIdBeforeDisconnection, content); #endregion clientBeforeDisconnection.Disconnect(); #region client reconnect to server BaseTestSite.Log.Add( LogEntryKind.Comment, "Client opens the same file and reconnects the durable handle"); uint treeIdAfterDisconnection; Connect(DialectRevision.Smb30, clientAfterDisconnection, clientGuid, testConfig.AccountCredential, ConnectShareType.BasicShareWithoutAssert, out treeIdAfterDisconnection, clientBeforeDisconnection); FILEID fileIdAfterDisconnection; clientAfterDisconnection.Create( treeIdAfterDisconnection, fileName, CreateOptions_Values.FILE_NON_DIRECTORY_FILE, out fileIdAfterDisconnection, out serverCreateContexts, RequestedOplockLevel_Values.OPLOCK_LEVEL_LEASE, new Smb2CreateContextRequest[] { new Smb2CreateDurableHandleReconnectV2 { CreateGuid = createGuid, FileId = new FILEID { Persistent = fileIdBeforeDisconnection.Persistent } }, new Smb2CreateRequestLeaseV2 { LeaseKey = leaseKey, LeaseState = leaseState, } }, shareAccess: ShareAccess_Values.NONE); string readContent; clientAfterDisconnection.Read(treeIdAfterDisconnection, fileIdAfterDisconnection, 0, (uint)content.Length, out readContent); BaseTestSite.Assert.IsTrue( content.Equals(readContent), "The written content is expected to be equal to read content."); #endregion clientAfterDisconnection.Close(treeIdAfterDisconnection, fileIdAfterDisconnection); clientAfterDisconnection.TreeDisconnect(treeIdAfterDisconnection); clientAfterDisconnection.LogOff(); clientAfterDisconnection.Disconnect(); }
public void PersistentHandle_ReOpenFromDiffClient() { /// 1. A client requests a persistent handle and succeeds /// 2. The client disconnects from the server /// 3. Another client (different client guid) opens the same file /// 4. The expected result of the second OPEN is STATUS_FILE_NOT_AVAILABLE according to section 3.3.5.9: /// If Connection.Dialect belongs to the SMB 3.x dialect family and the request does not contain SMB2_CREATE_DURABLE_HANDLE_RECONNECT /// Create Context or SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 Create Context, the server MUST look up an existing open in the GlobalOpenTable /// where Open.FileName matches the file name in the Buffer field of the request. /// If an Open entry is found, and if all the following conditions are satisfied, the server SHOULD fail the request with STATUS_FILE_NOT_AVAILABLE. /// Open.IsPersistent is TRUE /// Open.Connection is NULL #region Check Applicability TestConfig.CheckDialect(DialectRevision.Smb30); TestConfig.CheckCapabilities(NEGOTIATE_Response_Capabilities_Values.GLOBAL_CAP_PERSISTENT_HANDLES); #endregion Smb2FunctionalClient clientBeforeDisconnection = new Smb2FunctionalClient(testConfig.Timeout, testConfig, this.Site); durableHandleUncSharePath = Smb2Utility.GetUncPath(testConfig.CAShareServerName, testConfig.CAShareName); // It will cost 3 minutes to delete this file, so do not add it to testFiles to skip auto-clean. string fileName = CurrentTestCaseName + "_" + Guid.NewGuid().ToString(); BaseTestSite.Log.Add(LogEntryKind.TestStep, "1. A client requests a persistent handle and succeeds"); uint treeIdBeforeDisconnection; Connect(DialectRevision.Smb30, clientBeforeDisconnection, Guid.NewGuid(), testConfig.AccountCredential, ConnectShareType.CAShare, out treeIdBeforeDisconnection, null); FILEID fileIdBeforeDisconnection; Smb2CreateContextResponse[] serverCreateContexts = null; status = clientBeforeDisconnection.Create( treeIdBeforeDisconnection, fileName, CreateOptions_Values.FILE_NON_DIRECTORY_FILE, out fileIdBeforeDisconnection, out serverCreateContexts, RequestedOplockLevel_Values.OPLOCK_LEVEL_NONE, new Smb2CreateContextRequest[] { new Smb2CreateDurableHandleRequestV2 { CreateGuid = Guid.NewGuid(), Flags = CREATE_DURABLE_HANDLE_REQUEST_V2_Flags.DHANDLE_FLAG_PERSISTENT, } }, shareAccess: ShareAccess_Values.NONE, checker: (header, response) => { BaseTestSite.Assert.AreEqual( Smb2Status.STATUS_SUCCESS, header.Status, "{0} should be successful, actually server returns {1}.", header.Command, Smb2Status.GetStatusCode(header.Status)); CheckCreateContextResponses(serverCreateContexts, new DefaultDurableHandleV2ResponseChecker(BaseTestSite, CREATE_DURABLE_HANDLE_RESPONSE_V2_Flags.DHANDLE_FLAG_PERSISTENT, uint.MaxValue)); }); // Disconnect BaseTestSite.Log.Add( LogEntryKind.TestStep, "2. The client disconnects from the server"); clientBeforeDisconnection.Disconnect(); //If an Open entry is found, and if all the following conditions are satisfied, the server SHOULD<276> fail the request with STATUS_FILE_NOT_AVAILABLE. // Open.IsPersistent is TRUE // Open.Connection is NULL //<276> Section 3.3.5.9: If Open.ClientGuid is not equal to the ClientGuid of the connection that received this request, Open.Lease.LeaseState is equal to RWH, or Open.OplockLevel is equal to SMB2_OPLOCK_LEVEL_BATCH, // Windows-based servers will attempt to break the lease/oplock and return STATUS_PENDING to process the create request asynchronously. Otherwise, if Open.Lease.LeaseState does not include SMB2_LEASE_HANDLE_CACHING and // Open.OplockLevel is not equal to SMB2_OPLOCK_LEVEL_BATCH, Windows-based servers return STATUS_FILE_NOT_AVAILABLE. // Open from another client Smb2FunctionalClient anotherClient = new Smb2FunctionalClient(testConfig.Timeout, testConfig, this.Site); BaseTestSite.Log.Add( LogEntryKind.TestStep, "3. Open the same file from different client (different client guid), the expected result of OPEN is STATUS_FILE_NOT_AVAILABLE"); uint treeIdAfterDisconnection; Connect(DialectRevision.Smb30, anotherClient, Guid.NewGuid(), testConfig.AccountCredential, ConnectShareType.CAShare, out treeIdAfterDisconnection, null); FILEID fileIdAfterDisconnection; status = anotherClient.Create( treeIdAfterDisconnection, fileName, CreateOptions_Values.FILE_NON_DIRECTORY_FILE, out fileIdAfterDisconnection, out serverCreateContexts, RequestedOplockLevel_Values.OPLOCK_LEVEL_NONE, new Smb2CreateContextRequest[] { new Smb2CreateDurableHandleRequestV2 { CreateGuid = Guid.NewGuid(), Flags = CREATE_DURABLE_HANDLE_REQUEST_V2_Flags.DHANDLE_FLAG_PERSISTENT, } }, shareAccess: ShareAccess_Values.NONE, checker: (header, response) => { if (TestConfig.Platform == Platform.NonWindows) { BaseTestSite.Assert.AreNotEqual( Smb2Status.STATUS_SUCCESS, header.Status, "The server SHOULD fail the request with STATUS_FILE_NOT_AVAILABLE."); } else { BaseTestSite.Assert.AreEqual( Smb2Status.STATUS_FILE_NOT_AVAILABLE, header.Status, "The server SHOULD fail the request with STATUS_FILE_NOT_AVAILABLE."); } }); }
public void BVT_PersistentHandle_Reconnect() { /// 1. Client requests a persistent handle /// 2. Client disconnects from the server /// 3. Client reconnects the persistent handle, and expects success. #region Check Applicability TestConfig.CheckDialect(DialectRevision.Smb30); TestConfig.CheckCapabilities(NEGOTIATE_Response_Capabilities_Values.GLOBAL_CAP_LEASING | NEGOTIATE_Response_Capabilities_Values.GLOBAL_CAP_PERSISTENT_HANDLES); TestConfig.CheckCreateContext(CreateContextTypeValue.SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2, CreateContextTypeValue.SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2); #endregion string content = Smb2Utility.CreateRandomString(testConfig.WriteBufferLengthInKb); Guid clientGuid = Guid.NewGuid(); durableHandleUncSharePath = Smb2Utility.GetUncPath(testConfig.CAShareServerName, testConfig.CAShareName); string fileName = GetTestFileName(durableHandleUncSharePath); #region client connect to server BaseTestSite.Log.Add( LogEntryKind.Comment, "Client connects to server and opens file with a persistent handle"); uint treeIdBeforeDisconnection; Connect(DialectRevision.Smb30, clientBeforeDisconnection, clientGuid, testConfig.AccountCredential, ConnectShareType.CAShare, out treeIdBeforeDisconnection, null); Guid createGuid = Guid.NewGuid(); FILEID fileIdBeforeDisconnection; Smb2CreateContextResponse[] serverCreateContexts = null; status = clientBeforeDisconnection.Create( treeIdBeforeDisconnection, fileName, CreateOptions_Values.FILE_NON_DIRECTORY_FILE, out fileIdBeforeDisconnection, out serverCreateContexts, RequestedOplockLevel_Values.OPLOCK_LEVEL_NONE, new Smb2CreateContextRequest[] { new Smb2CreateDurableHandleRequestV2 { CreateGuid = createGuid, Flags = CREATE_DURABLE_HANDLE_REQUEST_V2_Flags.DHANDLE_FLAG_PERSISTENT, } }, shareAccess: ShareAccess_Values.NONE, checker: (header, response) => { BaseTestSite.Assert.AreEqual( Smb2Status.STATUS_SUCCESS, header.Status, "{0} should be successful, actually server returns {1}.", header.Command, Smb2Status.GetStatusCode(header.Status)); CheckCreateContextResponses(serverCreateContexts, new DefaultDurableHandleV2ResponseChecker(BaseTestSite, CREATE_DURABLE_HANDLE_RESPONSE_V2_Flags.DHANDLE_FLAG_PERSISTENT, uint.MaxValue)); }); status = clientBeforeDisconnection.Write(treeIdBeforeDisconnection, fileIdBeforeDisconnection, content); #endregion clientBeforeDisconnection.Disconnect(); #region client reconnect to server BaseTestSite.Log.Add( LogEntryKind.Comment, "Client opens the same file and reconnects the persistent handle"); uint treeIdAfterDisconnection; Connect(DialectRevision.Smb30, clientAfterDisconnection, clientGuid, testConfig.AccountCredential, ConnectShareType.CAShare, out treeIdAfterDisconnection, clientBeforeDisconnection); FILEID fileIdAfterDisconnection; status = clientAfterDisconnection.Create( treeIdAfterDisconnection, fileName, CreateOptions_Values.FILE_NON_DIRECTORY_FILE, out fileIdAfterDisconnection, out serverCreateContexts, RequestedOplockLevel_Values.OPLOCK_LEVEL_NONE, new Smb2CreateContextRequest[] { new Smb2CreateDurableHandleReconnectV2 { CreateGuid = createGuid, Flags = CREATE_DURABLE_HANDLE_RECONNECT_V2_Flags.DHANDLE_FLAG_PERSISTENT, FileId = new FILEID { Persistent = fileIdBeforeDisconnection.Persistent } } }, shareAccess: ShareAccess_Values.NONE); string readContent; status = clientAfterDisconnection.Read(treeIdAfterDisconnection, fileIdAfterDisconnection, 0, (uint)content.Length, out readContent); BaseTestSite.Assert.IsTrue( readContent.Equals(content), "The written content should equal to read content."); #endregion clientAfterDisconnection.Close(treeIdAfterDisconnection, fileIdAfterDisconnection); clientAfterDisconnection.TreeDisconnect(treeIdAfterDisconnection); clientAfterDisconnection.LogOff(); clientAfterDisconnection.Disconnect(); }
public HealthEndpointTests(ITestOutputHelper outputWriter) { _configuration = TestConfig.Create(); _outputWriter = outputWriter; }
/// <summary> /// Initializes a new instance of the <see cref="HttpTriggerOrderTests"/> class. /// </summary> public HttpTriggerOrderTests(ITestOutputHelper outputWriter) { _outputWriter = outputWriter; _config = TestConfig.Create(); }
/// <summary> /// Initializes a new instance of the <see cref="SecretStoreBuilderExtensionsTests"/> class. /// </summary> public SecretStoreBuilderExtensionsTests(ITestOutputHelper outputWriter) : base(outputWriter) { _config = TestConfig.Create(); _logger = new XunitTestLogger(outputWriter); }
public void ResilientWithPersistentHandle_OpenFromDiffClient() { /// 1. Open Persistent Handle with lease /// 2. Send Resiliency request /// 3. Disconnect /// 4. Open the same file from different client (different client guid) /// 5. The expected result of OPEN is STATUS_FILE_NOT_AVAILABLE according to section 3.3.5.9: /// If Connection.Dialect belongs to the SMB 3.x dialect family and the request does not contain SMB2_CREATE_DURABLE_HANDLE_RECONNECT /// Create Context or SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 Create Context, the server MUST look up an existing open in the GlobalOpenTable /// where Open.FileName matches the file name in the Buffer field of the request. /// If an Open entry is found, and if all the following conditions are satisfied, the server MUST fail the request with STATUS_FILE_NOT_AVAILABLE. /// ¡ì Open.IsPersistent is TRUE /// ¡ì Open.Connection is NULL /// ¡ì Open.OplockLevel is not equal to SMB2_OPLOCK_LEVEL_BATCH /// ¡ì Open.OplockLevel is not equal to SMB2_OPLOCK_LEVEL_LEASE or Open.Lease.LeaseState does not include SMB2_LEASE_HANDLE_CACHING #region Check Applicability TestConfig.CheckDialect(DialectRevision.Smb30); TestConfig.CheckCapabilities(NEGOTIATE_Response_Capabilities_Values.GLOBAL_CAP_PERSISTENT_HANDLES); #endregion Smb2FunctionalClient client = new Smb2FunctionalClient(testConfig.Timeout, testConfig, this.Site); Guid clientGuid = Guid.NewGuid(); Guid createGuid = Guid.NewGuid(); Guid leaseKey = Guid.NewGuid(); string fileName = "ResilientWithPersistentHandle_" + Guid.NewGuid() + ".txt"; FILEID fileId; uint treeId; BaseTestSite.Log.Add(LogEntryKind.TestStep, "Open Persistent Handle with lease."); OpenFile( client, clientGuid, fileName, true, out createGuid, out treeId, out fileId); // resiliency request Packet_Header ioCtlHeader; IOCTL_Response ioCtlResponse; byte[] inputInResponse; byte[] outputInResponse; BaseTestSite.Log.Add( LogEntryKind.TestStep, "Send resiliency request with timeout {0} milliseconds", testConfig.MaxResiliencyTimeoutInSecond); client.ResiliencyRequest( treeId, fileId, testConfig.MaxResiliencyTimeoutInSecond, (uint)Marshal.SizeOf(typeof(NETWORK_RESILIENCY_Request)), out ioCtlHeader, out ioCtlResponse, out inputInResponse, out outputInResponse ); // Disconnect BaseTestSite.Log.Add( LogEntryKind.TestStep, "Disconnect the resilient handle"); client.Disconnect(); // open from another client Smb2FunctionalClient anotherClient = new Smb2FunctionalClient(testConfig.Timeout, testConfig, this.Site); BaseTestSite.Log.Add( LogEntryKind.TestStep, "Open the same file from different client (different client guid), the expected result of OPEN is successful"); OpenFile( anotherClient, Guid.NewGuid(), fileName, false, out createGuid, out treeId, out fileId, responseChecker: (Packet_Header header, CREATE_Response response) => { BaseTestSite.Assert.AreEqual(Smb2Status.STATUS_FILE_NOT_AVAILABLE, header.Status, "The server MUST fail the request with STATUS_FILE_NOT_AVAILABLE."); }); }
public RecommendationsManager() : base(TestConfig.GetValueFromConfig("MatchingProWeb")) { }
public void Run(TestConfig config) { int i; Record r = null; int count = config.Count; var res = new TestIndexNumericResult(); config.Result = res; var start = DateTime.Now; IDatabase db = config.GetDatabase(); Tests.Assert(null == db.Root); var idx = db.CreateIndex<short, Record>(IndexType.NonUnique); db.Root = idx; int countOf1999 = 0; i = 0; foreach (long val in Tests.KeySeq(count)) { short idxVal = Clamp(val); if (idxVal == 1999) countOf1999++; Tests.Assert(idxVal != max); r = new Record(idxVal); idx.Put(idxVal, r); i++; if (i % 100 == 0) db.Commit(); } idx.Put(min, new Record(min)); idx.Put(max, new Record(max)); Tests.Assert(idx.Count == count + 2); db.Commit(); res.InsertTime = DateTime.Now - start; Tests.Assert(idx.Count == count + 2); start = System.DateTime.Now; Record[] recs = idx[min, mid]; foreach (var r2 in recs) { Tests.Assert(r2.lval >= min && r2.lval <= mid); } recs = idx[mid, max]; foreach (var r2 in recs) { Tests.Assert(r2.lval >= mid && r2.lval <= max); } recs = idx[min, max]; Tests.Assert(recs.Length == count + 2); recs = idx[min, min]; Tests.Assert(1 == recs.Length); recs = idx[max, max]; Tests.Assert(1 == recs.Length); recs = idx[1999, 1999]; Tests.Assert(countOf1999 == recs.Length); recs = idx[min + 1, min + 1]; Tests.Assert(0 == recs.Length); short prev = min; var e1 = idx.GetEnumerator(); while (e1.MoveNext()) { r = e1.Current; Tests.Assert(r.nval >= prev); prev = r.nval; } Tests.VerifyEnumeratorDone(e1); prev = min; foreach (var r2 in idx) { Tests.Assert(r2.nval >= prev); prev = r2.nval; } prev = min; foreach (var r2 in idx.Range(min, max, IterationOrder.AscentOrder)) { Tests.Assert(r2.nval >= prev); prev = r2.nval; } prev = max; foreach (var r2 in idx.Range(min, max, IterationOrder.DescentOrder)) { Tests.Assert(prev >= r2.nval); prev = r2.nval; } prev = max; foreach (var r2 in idx.Reverse()) { Tests.Assert(prev >= r2.nval); prev = r2.nval; } long usedBeforeDelete = db.UsedSize; recs = idx[min, max]; foreach (var r2 in recs) { Tests.Assert(!r2.IsDeleted()); idx.Remove(r2.nval, r2); r2.Deallocate(); } Tests.Assert(idx.Count == 0); db.Commit(); long usedAfterDelete = db.UsedSize; db.Gc(); db.Commit(); long usedAfterGc = db.UsedSize; db.Close(); }
public async Task ConsumerCanJoinConsumerGroup() { using (var router = await TestConfig.IntegrationOptions.CreateRouterAsync()) { await router.TemporaryTopicAsync(async topicName => { var groupId = TestConfig.GroupId(); using (var consumer = await router.CreateGroupConsumerAsync(groupId, new ConsumerProtocolMetadata(TestConfig.TopicName()), TestConfig.IntegrationOptions.ConsumerConfiguration, TestConfig.IntegrationOptions.Encoders, CancellationToken.None)) { Assert.That(consumer.GroupId, Is.EqualTo(groupId)); Assert.That(consumer.IsLeader, Is.True); } }); } }
private IEnumerable<string> RunParallelUpdates(TestConfig testConfig, IDocumentStore store) { var documentIds = CreateTestDocuments(testConfig.NumberOfDocuments, store); WaitForIndexing(store); Parallel.For(0, testConfig.NumberOfUpdatesPerDocument, i => UpdateAllDocumentsInParallel(documentIds, store)); return documentIds; }
static int Main(string[] args) { Globals.bProgramRunning = true; Stopwatch stopwatch = Stopwatch.StartNew(); TestConfig testConfig = ConfigHandler.ConfigureTestParameters(args); Globals.LoggingHandler = new LoggingHandler(testConfig); Globals.LoggingHandler.StartLogQueueWatcher(); Version currentVersion = Assembly.GetExecutingAssembly().GetName().Version; Globals.LoggingHandler.LogConsole($"\nCosmo {currentVersion.Major}.{currentVersion.Minor}.{currentVersion.Build}\n"); UpdateChecker updateChecker = new UpdateChecker(currentVersion, Environment.CurrentDirectory); bool bUpdateApp = updateChecker.Execute(); ResultsSummary resultsSummary = new ResultsSummary(); if (!bUpdateApp) { Globals.LoggingHandler.LogConsole($"\nInitialising {testConfig.TestName}..."); Test test = new Test(testConfig) .SetUpTargetAPI() .SetUpSwaggerDocuments() .SetUpPayloadDictionaries() .SetUpAuthDictionaries() .SetUpSimulatedUsers() .SetUpTestSchedule(); Globals.LoggingHandler.LogConsole("finished!\n"); Globals.LoggingHandler.LogConsole($"\nRunning {testConfig.TestName}..."); test.Run(); resultsSummary = test.HandleResultSet(); } Globals.LoggingHandler.LogConsole("finished!\n\n"); Globals.LoggingHandler.LogConsole ( Defaults.TestSummaryMessage .Replace("[[Endpoints]]", resultsSummary.EndpointsTested.ToString()) .Replace("[[Successes]]", resultsSummary.EndpointsPassed.ToString()) .Replace("[[Failures]]", resultsSummary.EndpointsFailed.ToString()) ); stopwatch.Stop(); Console.WriteLine(stopwatch.ElapsedMilliseconds); Globals.LoggingHandler.LogConsole("\nWriting logs..."); Globals.LoggingHandler.WaitForLoggingCompletion(); Globals.LoggingHandler.LogConsole("finished!\n"); Globals.bProgramRunning = false; return(0); }
public void Run(TestConfig config) { int i; IDatabase db = config.GetDatabase(); config.Result = new TestResult(); Root root = new Root(); var arr = db.CreateArray<FromRec>(45); root.arr = arr; db.Root = root; db.Commit(); int projectedEls = 45; for (i = 0; i < projectedEls; i++) { arr.Add(new FromRec(db, i)); } arr[0].toEl = null; db.Commit(); var p1 = new Projection<FromRec, ToRec>("list"); Tests.Assert(p1.Count == 0); Tests.Assert(p1.Length == 0); Tests.Assert(!p1.IsReadOnly); Tests.Assert(!p1.IsSynchronized); Tests.Assert(null == p1.SyncRoot); p1.Project(arr); Tests.Assert(p1.Count == projectedEls * 5); var arrTmp = p1.ToArray(); Tests.Assert(arrTmp.Length == p1.Length); p1.Reset(); p1.Project(arr[0]); Tests.Assert(p1.Length == 5); p1.Reset(); var arr3 = arr.ToArray(); p1.Project(arr3); Tests.Assert(p1.Length == projectedEls * 5); p1.Clear(); IEnumerator<FromRec> e1 = arr.GetEnumerator(); p1.Project(e1); Tests.Assert(p1.Length == projectedEls * 5); var p2 = new Projection<FromRec, ToRec>("list2"); p2.Project(arr); Tests.Assert(p2.Length == projectedEls * 5); var p3 = new Projection<FromRec, ToRec>("toEl"); p3.Project(arr); Tests.Assert(p2.Length == projectedEls * 5); p1.Join<FromRec>(p2); Tests.Assert(p1.GetEnumerator() != null); IEnumerator eTmp = ((IEnumerable)p1).GetEnumerator(); Tests.Assert(eTmp != null); ToRec[] res = new ToRec[p3.Count]; p3.CopyTo(res, 0); foreach (var tmp in res) { Tests.Assert(p3.Contains(tmp)); p3.Remove(tmp); Tests.Assert(!p3.Contains(tmp)); } Tests.Assert(0 == p3.Length); db.Commit(); db.Close(); }
public ContentInformationUtility(ITestSite testSite, TestConfig testConfig, ISUTControlAdapter sutControlAdapter) { this.testSite = testSite; this.testConfig = testConfig; this.sutControlAdapter = sutControlAdapter; }
// Update is called once per frame void Update() { accum += Time.deltaTime; frames++; //Debug.Log("Frames : " + frames + " Time : " + accum); if(!isRunning){ isRunning = true; if(m_index >= queuedTests.Count){ if(!hasEnded){ hasEnded = true; handleEnd(); } } else{ TestConfig test = (TestConfig)queuedTests[m_index]; currentTest = test; GameObject testEngine = (GameObject)Instantiate(testEngineClass); testEngine.GetComponent<TestEngine>().shouldAnimate = test.animate; testEngine.GetComponent<TestEngine>().numSprites = test.spriteCount; testEngine.GetComponent<TestEngine>().workload = test.workload; m_index++; } } }
public async Task Submit_DomesticPayment_Accepted() { IOpenBankingRequestBuilder?builder = CreateOpenBankingRequestBuilder(); // Where you see TestConfig.GetValue( .. ) // these are injecting test data values. Here they're from test data, but can be anything else: database queries, Azure Key Vault configuration, etc. // Set up a Software Statement and associated configuration/preferences (a "software statement profile") within our Servicing service. Configuration // includes the transport and signing keys associated with the software statement. // This is performed once in the lifetime of Servicing or in the case of using multiple identities to connect to banks, once per identity. OpenBankingSoftwareStatementResponse?softwareStatementProfileResp = await builder .SoftwareStatementProfile() .Id("0") .SoftwareStatement(TestConfig.GetValue("softwarestatement")) .SigningKeyInfo( keyId: TestConfig.GetValue("signingkeyid"), keySecretName: TestConfig.GetValue("signingcertificatekey"), certificate: TestConfig.GetValue("signingcertificate")) .TransportKeyInfo( keySecretName: TestConfig.GetValue("transportcertificatekey"), certificate: TestConfig.GetValue("transportcertificate")) .DefaultFragmentRedirectUrl(TestConfig.GetValue("defaultfragmentredirecturl")) .SubmitAsync(); softwareStatementProfileResp.Should().NotBeNull(); softwareStatementProfileResp.Messages.Should().BeEmpty(); softwareStatementProfileResp.Data.Should().NotBeNull(); softwareStatementProfileResp.Data.Id.Should().NotBeNullOrWhiteSpace(); // Set up a bank registration (client) and associated configuration/preferences (a "bank client profile"). The bank client profile will only // be created if bank registration is successful. // Bank registration uses a software statement to establish our identity in the eyes of the bank. This and other data are transmitted to the bank. // This is performed once per Bank. BankClientProfileFluentResponse?bankClientProfileResp = await builder.BankClientProfile() .Id("MyBankClientProfileId") .SoftwareStatementProfileId(softwareStatementProfileResp.Data.Id) .IssuerUrl(new Uri(TestConfig.GetValue("clientProfileIssuerUrl"))) .XFapiFinancialId(TestConfig.GetValue("xFapiFinancialId")) .BankClientRegistrationClaimsOverrides(TestConfig.GetOpenBankingClientRegistrationClaimsOverrides()) .SubmitAsync(); // These are test assertions to ensure the bank says "request successfully processed". "Messages" enumerates all warnings & errors, and so is empty for this scenario. bankClientProfileResp.Should().NotBeNull(); bankClientProfileResp.Messages.Should().BeEmpty(); bankClientProfileResp.Data.Should().NotBeNull(); // Set up an Open Banking Read/Write API and associated configuration/preferences (an "API profile"). This should be done separately for Payment Initiation and Account Transaction // APIs and specifies the functional endpoints, spec version and // any preferences related to that API including the bank client to be used. // This is performed once per Bank per Read/Write API type (e.g. Payment Initiation, Account Transaction, etc). PaymentInitiationApiProfileFluentResponse?paymentInitiationApiProfileResp = await builder .PaymentInitiationApiProfile() .Id("NewPaymentInitiationProfile") .BankClientProfileId(bankClientProfileResp.Data.Id) .PaymentInitiationApiInfo( apiVersion: TestConfig.GetEnumValue <ApiVersion>("paymentApiVersion").Value, baseUrl: TestConfig.GetValue("paymentApiUrl")) .SubmitAsync(); paymentInitiationApiProfileResp.Should().NotBeNull(); paymentInitiationApiProfileResp.Messages.Should().BeEmpty(); paymentInitiationApiProfileResp.Data.Should().NotBeNull(); // Create a consent object and transmit to the bank to support user authorisation of an intended domestic payment. // This is performed once per payment. DomesticPaymentConsentFluentResponse?consentResp = await builder .DomesticPaymentConsent(paymentInitiationApiProfileResp.Data.Id) .Merchant( merchantCategory: null, merchantCustomerId: null, paymentContextCode: OBRisk1.PaymentContextCodeEnum.EcommerceGoods) .CreditorAccount( identification: "BE56456394728288", schema: "IBAN", name: "ACME DIY", secondaryId: "secondary-identif") .DeliveryAddress(new OBRisk1DeliveryAddress { BuildingNumber = "42", StreetName = "Oxford Street", TownName = "London", Country = "UK", PostCode = "SW1 1AA" }) .Amount(currency: "GBP", value: 50) .InstructionIdentification("instr-identification") .EndToEndIdentification("e2e-identification") .Remittance(new OBWriteDomestic2DataInitiationRemittanceInformation { Unstructured = "Tools", Reference = "Tools" }) .SubmitAsync(); consentResp.Should().NotBeNull(); consentResp.Messages.Should().BeEmpty(); consentResp.Data.Should().NotBeNull(); // After successful consent creation, a URL is generated which may be called to allow the user to authorise the payment. // After authorisation, the bank will asynchronously call back (redirect) to us with an authorisation code. // We provide the endpoint to receive this auth code, and then can complete the payment process (a flow that is significantly simpler than the above). }
void VerifyFiles(TestConfig config, string[] files) { int rc; byte[] buf = new byte[1024]; IDatabase db = config.GetDatabase(false); IIndex<string, IBlob> root = (IIndex<string, IBlob>)db.Root; Tests.Assert(root != null); foreach (string file in files) { byte[] buf2 = new byte[1024]; IBlob blob = root[file]; Tests.Assert(blob != null); Stream bin = blob.GetStream(); FileStream fin = new FileStream(file, FileMode.Open, FileAccess.Read); while ((rc = fin.Read(buf, 0, buf.Length)) > 0) { int rc2 = bin.Read(buf2, 0, buf2.Length); Tests.Assert(rc == rc2); if (rc != rc2) break; while (--rc >= 0 && buf[rc] == buf2[rc]) ; Tests.Assert(rc < 0); if (rc >= 0) break; } fin.Close(); bin.Close(); } db.Commit(); db.Close(); }
public static void Run(string[] args) { IdentityModelEventSource.ShowPII = true; var testRuns = TestConfig.SetupTestRuns( new List <TestExecutor> { TokenTestExecutors.JsonWebTokenHandler_ValidateToken_InParallel, TokenTestExecutors.JwtSecurityTokenHandler_ValidateToken_InParallel, TokenTestExecutors.Saml2SecurityTokenHandler_ValidateToken_InParallel, TokenTestExecutors.SamlSecurityTokenHandler_ValidateToken_InParallel, TokenTestExecutors.JsonWebTokenHandler_CreateToken_InParallel, TokenTestExecutors.JwtSecurityTokenHandler_CreateToken_InParallel, TokenTestExecutors.Saml2SecurityTokenHandler_CreateToken_InParallel, TokenTestExecutors.SamlSecurityTokenHandler_CreateToken_InParallel, }); var securityTokenDescriptor = TestData.SecurityTokenDescriptor(TestData.RsaSigningCredentials_2048Sha256); var tokenValidationParameters = TestData.TokenValidationParameters(securityTokenDescriptor.SigningCredentials.Key); var jwtTokenHandler = new JwtSecurityTokenHandler(); var jwt = jwtTokenHandler.CreateEncodedJwt(securityTokenDescriptor); var samlTokenHandler = new SamlSecurityTokenHandler(); var samlToken = samlTokenHandler.CreateToken(securityTokenDescriptor); var saml = samlTokenHandler.WriteToken(samlToken); var saml2TokenHandler = new Saml2SecurityTokenHandler(); var saml2Token = saml2TokenHandler.CreateToken(securityTokenDescriptor); var saml2 = saml2TokenHandler.WriteToken(saml2Token); var testConfig = TestConfig.ParseArgs(args); var tokenTestData = new TokenTestRunData { JwtSecurityTokenHandler = new JwtSecurityTokenHandler(), JsonWebTokenHandler = new JsonWebTokenHandler(), JwtToken = jwt, NumIterations = testConfig.NumIterations, Saml2Token = saml2, SamlToken = saml, SamlSecurityTokenHandler = samlTokenHandler, Saml2SecurityTokenHandler = saml2TokenHandler, TokenValidationParameters = tokenValidationParameters, SecurityTokenDescriptor = securityTokenDescriptor }; // run each test to set any static data foreach (var testRun in testRuns) { testRun.TestExecutor(tokenTestData); } var assemblyVersion = typeof(JwtSecurityTokenHandler).Assembly.GetName().Version.ToString(); #if DEBUG var prefix = "DEBUG"; #else var prefix = "RELEASE"; #endif testConfig.Version = $"{prefix}-{assemblyVersion}"; var logName = $"SecurityTokens-{testConfig.Version}_{DateTime.Now.ToString("yyyy.MM.dd.hh.mm.ss")}.txt"; var directory = testConfig.LogDirectory; var logFile = Path.Combine(directory, logName); Directory.CreateDirectory(directory); TestRunner.Run(testConfig, testRuns, tokenTestData); File.WriteAllText(logFile, testConfig.Logger.Logs); }
/// <summary> /// Creates a project from the web API project template without a set project options. /// </summary> /// <param name="outputWriter">The output logger to add telemetry information during the creation and startup process.</param> /// <returns> /// A not yet started web API project with a full set of endpoint services to interact with the API. /// </returns> /// <remarks> /// Before the project can be interacted with, the project must be started by calling the <see cref="StartAsync" /> method. /// </remarks> public static WebApiProject CreateNew(ITestOutputHelper outputWriter) { Guard.NotNull(outputWriter, nameof(outputWriter), "Cannot create web API services without a test output logger"); return(CreateNew(TestConfig.Create(), WebApiProjectOptions.Empty, outputWriter)); }
public void Run(TestConfig config) { int i; Record r = null; int count = config.Count; var res = new TestIndexNumericResult(); config.Result = res; var start = DateTime.Now; IDatabase db = config.GetDatabase(); Tests.Assert(null == db.Root); var idx = db.CreateIndex<byte, Record>(IndexType.NonUnique); db.Root = idx; long val = 1999; for (i = 0; i < count; i++) { byte idxVal = Clamp(val); r = new Record(idxVal); idx.Put(idxVal, r); if (i % 100 == 0) db.Commit(); val = (3141592621L * val + 2718281829L) % 1000000007L; } idx.Put(min, new Record(min)); idx.Put(max, new Record(max)); Tests.Assert(idx.Count == count + 2); db.Commit(); res.InsertTime = DateTime.Now - start; Tests.Assert(idx.Count == count + 2); start = System.DateTime.Now; Record[] recs = idx[min, mid]; foreach (var r2 in recs) { Tests.Assert(r2.lval >= min && r2.lval <= mid); } recs = idx[mid, max]; foreach (var r2 in recs) { Tests.Assert(r2.lval >= mid && r2.lval <= max); } byte prev = min; var e1 = idx.GetEnumerator(); while (e1.MoveNext()) { r = e1.Current; Tests.Assert(r.nval >= prev); prev = r.nval; } Tests.VerifyEnumeratorDone(e1); prev = min; foreach (var r2 in idx) { Tests.Assert(r2.nval >= prev); prev = r2.nval; } prev = min; foreach (var r2 in idx.Range(min, max, IterationOrder.AscentOrder)) { Tests.Assert(r2.nval >= prev); prev = r2.nval; } prev = max; foreach (var r2 in idx.Range(min, max, IterationOrder.DescentOrder)) { Tests.Assert(prev >= r2.nval); prev = r2.nval; } prev = max; foreach (var r2 in idx.Reverse()) { Tests.Assert(prev >= r2.nval); prev = r2.nval; } long usedBeforeDelete = db.UsedSize; recs = idx[min, max]; foreach (var r2 in recs) { Tests.Assert(!r2.IsDeleted()); idx.Remove(r2.nval, r2); r2.Deallocate(); } Tests.Assert(idx.Count == 0); db.Commit(); long usedAfterDelete = db.UsedSize; db.Gc(); db.Commit(); long usedAfterGc = db.UsedSize; db.Close(); }
public void Run(TestConfig config) { int count = config.Count; var res = new TestResult(); config.Result = res; IDatabase db = config.GetDatabase(); Root root = (Root)db.Root; Tests.Assert(null == root); root = new Root(); root.strIndex = db.CreateIndex <string, Record>(IndexType.Unique); db.Root = root; string[] strs = new string[] { "one", "two", "three", "four" }; int no = 0; for (var i = 0; i < count; i++) { foreach (string s in strs) { var s2 = String.Format("{0}-{1}", s, i); Record o = new Record(); o.strKey = s2; o.intKey = no++; root.strIndex[s2] = o; } } db.Commit(); // Test that modyfing an index while traversing it throws an exception // Tests Btree.BtreeEnumerator long n = -1; Tests.AssertException <InvalidOperationException>( () => { foreach (Record r in root.strIndex) { n = r.intKey; var i = n % strs.Length; var j = n / strs.Length; var sBase = strs[i]; var expectedStr = String.Format("{0}-{1}", sBase, j); string s = r.strKey; Tests.Assert(s == expectedStr); if (n == 0) { Record o = new Record(); o.strKey = "five"; o.intKey = 5; root.strIndex[o.strKey] = o; } } }); Tests.Assert(n == 0); // Test that modyfing an index while traversing it throws an exception // Tests Btree.BtreeSelectionIterator Key keyStart = new Key("four", true); Key keyEnd = new Key("three", true); Tests.AssertException <InvalidOperationException>(() => { foreach (Record r in root.strIndex.Range(keyStart, keyEnd, IterationOrder.AscentOrder)) { n = r.intKey; var i = n % strs.Length; var j = n / strs.Length; var sBase = strs[i]; var expectedStr = String.Format("{0}-{1}", sBase, j); string s = r.strKey; Tests.Assert(s == expectedStr); Record o = new Record(); o.strKey = "six"; o.intKey = 6; root.strIndex[o.strKey] = o; } }); db.Close(); }
/// <summary> /// Connect share on file server /// </summary> /// <param name="serverIp">Server IP address used for connection</param> /// <param name="clientIp">Client IP address used for connection</param> /// <param name="client">Client object to initialize the connection</param> /// <param name="treeId">Out param tree id connected</param> /// <param name="enableEncryptionPerShare">True indicates encryption enabled per share, otherwise disabled</param> private void ConnectShare(IPAddress serverIp, IPAddress clientIp, Smb2FunctionalClient client, out uint treeId, bool enableEncryptionPerShare = false) { BaseTestSite.Log.Add( LogEntryKind.Debug, "Connect to share {0} with following steps.", uncSharePath); BaseTestSite.Log.Add( LogEntryKind.Debug, "Connect to server via Nic with Ip {0}", clientIp.ToString()); client.ConnectToServer(TestConfig.UnderlyingTransport, TestConfig.SutComputerName, serverIp, clientIp); #region Negotiate Capabilities_Values clientCapabilities = Capabilities_Values.GLOBAL_CAP_DFS | Capabilities_Values.GLOBAL_CAP_DIRECTORY_LEASING | Capabilities_Values.GLOBAL_CAP_LARGE_MTU | Capabilities_Values.GLOBAL_CAP_LEASING | Capabilities_Values.GLOBAL_CAP_MULTI_CHANNEL | Capabilities_Values.GLOBAL_CAP_PERSISTENT_HANDLES | Capabilities_Values.GLOBAL_CAP_ENCRYPTION; status = client.Negotiate( TestConfig.RequestDialects, TestConfig.IsSMB1NegotiateEnabled, capabilityValue: clientCapabilities, checker: (Packet_Header header, NEGOTIATE_Response response) => { BaseTestSite.Assert.AreEqual( Smb2Status.STATUS_SUCCESS, header.Status, "CREATE should succeed."); TestConfig.CheckNegotiateDialect(DialectRevision.Smb30, response); }); #endregion #region SESSION_SETUP status = client.SessionSetup( TestConfig.DefaultSecurityPackage, TestConfig.SutComputerName, TestConfig.AccountCredential, TestConfig.UseServerGssToken); BaseTestSite.Log.Add( LogEntryKind.Debug, "Global encryption disabled"); #endregion #region TREE_CONNECT to share status = client.TreeConnect( uncSharePath, out treeId, (Packet_Header header, TREE_CONNECT_Response response) => { BaseTestSite.Assert.AreEqual( Smb2Status.STATUS_SUCCESS, header.Status, "TreeConnect should succeed."); if (enableEncryptionPerShare) { BaseTestSite.Assert.AreEqual( ShareFlags_Values.SHAREFLAG_ENCRYPT_DATA, ShareFlags_Values.SHAREFLAG_ENCRYPT_DATA & response.ShareFlags, "Server should set SMB2_SHAREFLAG_ENCRYPT_DATA for ShareFlags field in TREE_CONNECT response"); } }); client.SetTreeEncryption(treeId, enableEncryptionPerShare); BaseTestSite.Log.Add( LogEntryKind.Debug, "Per share encryption for TreeId=0x{0:x} : {1}", treeId, enableEncryptionPerShare); #endregion BaseTestSite.Log.Add( LogEntryKind.Debug, "Finish connecting to share {0}", uncSharePath); }
public async Task CanDoWhatTheFixtureSays() { const string headerKey = "custom-header"; var activator = new BuiltinHandlerActivator(); Using(activator); var nullHeaderSuccessfullyReceived = new ManualResetEvent(false); activator.Handle <string>(async(_, context, __) => { if (context.Headers[headerKey] == null) { nullHeaderSuccessfullyReceived.Set(); } }); var bus = Configure.With(activator) .Transport(t => t.UseRabbitMq(RabbitMqTransportFactory.ConnectionString, TestConfig.GetName("null-header"))) .Start(); await bus.SendLocal("Hej søtte", new Dictionary <string, string> { { headerKey, null } }); nullHeaderSuccessfullyReceived.WaitOrDie(TimeSpan.FromSeconds(3)); }
public void Run(TestConfig config) { int i; Record r = null; int count = config.Count; var res = new TestIndexNumericResult(); config.Result = res; var start = DateTime.Now; IDatabase db = config.GetDatabase(); Tests.Assert(null == db.Root); var idx = db.CreateIndex <uint, Record>(IndexType.NonUnique); db.Root = idx; long val = 1999; for (i = 0; i < count; i++) { byte idxVal = Clamp(val); r = new Record(idxVal); idx.Put(idxVal, r); if (i % 100 == 0) { db.Commit(); } val = (3141592621L * val + 2718281829L) % 1000000007L; } idx.Put(min, new Record(min)); idx.Put(max, new Record(max)); Tests.Assert(idx.Count == count + 2); db.Commit(); res.InsertTime = DateTime.Now - start; Tests.Assert(idx.Count == count + 2); start = System.DateTime.Now; Record[] recs = idx[min, mid]; i = 0; foreach (var r2 in recs) { Tests.Assert(r2.lval >= min && r2.lval <= mid); i++; } recs = idx[mid, max]; i = 0; foreach (var r2 in recs) { Tests.Assert(r2.lval >= mid && r2.lval <= max); i++; } uint prev = min; i = 0; var e1 = idx.GetEnumerator(); while (e1.MoveNext()) { r = e1.Current; Tests.Assert(r.nval >= prev); prev = r.nval; i++; } Tests.VerifyEnumeratorDone(e1); prev = min; i = 0; foreach (var r2 in idx) { Tests.Assert(r2.nval >= prev); prev = r2.nval; i++; } prev = min; i = 0; foreach (var r2 in idx.Range(min, max, IterationOrder.AscentOrder)) { Tests.Assert(r2.nval >= prev); prev = r2.nval; i++; } prev = max; i = 0; foreach (var r2 in idx.Range(min, max, IterationOrder.DescentOrder)) { Tests.Assert(prev >= r2.nval); prev = r2.nval; i++; } prev = max; i = 0; foreach (var r2 in idx.Reverse()) { Tests.Assert(prev >= r2.nval); prev = r2.nval; i++; } long usedBeforeDelete = db.UsedSize; recs = idx[min, max]; i = 0; foreach (var r2 in recs) { Tests.Assert(!r2.IsDeleted()); idx.Remove(r2.nval, r2); r2.Deallocate(); i++; } Tests.Assert(idx.Count == 0); db.Commit(); long usedAfterDelete = db.UsedSize; db.Gc(); db.Commit(); long usedAfterGc = db.UsedSize; db.Close(); }
public RdpedycAdapter(TestConfig testConfig) { this.bcgrAdapter = new RdpbcgrAdapter(testConfig); }
public ValuesController(TestConfig testConfig, IValueProvider valueProvider) { _testConfig = testConfig; _valueProvider = valueProvider; }
public async Task CanFetch() { const int partitionId = 0; using (var router = await TestConfig.IntegrationOptions.CreateRouterAsync()) { await router.TemporaryTopicAsync(async topicName => { using (var producer = new Producer(router)) { var messageValue = Guid.NewGuid().ToString(); var response = await producer.SendAsync(new Message(messageValue), TestConfig.TopicName(), partitionId, CancellationToken.None); var offset = response.base_offset; var fetch = new FetchRequest.Topic(TestConfig.TopicName(), partitionId, offset, 32000); var fetchRequest = new FetchRequest(fetch, minBytes: 10); var r = await router.SendAsync(fetchRequest, TestConfig.TopicName(), partitionId, CancellationToken.None); Assert.IsTrue(r.responses.First().Messages.First().Value.ToUtf8String() == messageValue); } }); } }
public SpringProcessEnginePluginAnonymousInnerClass(TestConfig outerInstance) { this.outerInstance = outerInstance; }