Пример #1
0
        public void RequestOplockAndOperateFileRequest(
            RequestedOplockLevel_Values requestedOplockLevel,
            OplockFileOperation fileOperation,
            out OplockLevel_Values grantedOplockLevel,
            out OplockConfig c)
        {
            Smb2CreateContextResponse[] serverCreateContexts;
            string fileName = GetTestFileName(uncSharePath);

            OplockLevel_Values grantedTmp = OplockLevel_Values.OPLOCK_LEVEL_NONE;

            testClient.Create(
                treeId,
                fileName,
                CreateOptions_Values.FILE_NON_DIRECTORY_FILE,
                out fileId,
                out serverCreateContexts,
                requestedOplockLevel_Values: requestedOplockLevel,
                checker: (header, response) =>
            {
                grantedTmp = response.OplockLevel;
            });

            Site.Log.Add(LogEntryKind.Debug, "OplockLevel granted by server: {0}", grantedTmp);
            grantedOplockLevel = grantedTmp;
            c = oplockConfig;

            oplockLevelOnOpen = grantedTmp;

            fileOperationInvoker = new FileOperationDelegate(FileOperation);
            var task = Task.Run(() => fileOperationInvoker.Invoke(fileOperation, fileName));

            task.Wait(500);// Assume that notification will arrive in .5 sec if there's any
        }
        public void ReadConfig(out OplockConfig c)
        {
            c = new OplockConfig
            {
                Platform = testConfig.Platform,
                MaxSmbVersionSupported = ModelUtility.GetModelDialectRevision(testConfig.MaxSmbVersionSupported)
            };

            oplockConfig = c;
            Site.Log.Add(LogEntryKind.Debug, oplockConfig.ToString());
        }
        public void ReadConfig(out OplockConfig c)
        {
            c = new OplockConfig
            {
                Platform = testConfig.Platform,
                MaxSmbVersionSupported = ModelUtility.GetModelDialectRevision(testConfig.MaxSmbVersionSupported)
            };

            oplockConfig = c;
            Site.Log.Add(LogEntryKind.Debug, oplockConfig.ToString());
        }
        public void RequestOplockAndOperateFileRequest(
            RequestedOplockLevel_Values requestedOplockLevel,
            OplockFileOperation fileOperation,
            out OplockLevel_Values grantedOplockLevel,
            out OplockConfig c)
        {
            Smb2CreateContextResponse[] serverCreateContexts;
            string fileName = "OplockMBT_" + Guid.NewGuid().ToString();

            OplockLevel_Values grantedTmp = OplockLevel_Values.OPLOCK_LEVEL_NONE;

            testClient.Create(
                treeId,
                fileName,
                CreateOptions_Values.FILE_NON_DIRECTORY_FILE,
                out fileId,
                out serverCreateContexts,
                requestedOplockLevel_Values: requestedOplockLevel,
                checker: (header, response) =>
            {
                grantedTmp = response.OplockLevel;
            });

            Site.Log.Add(LogEntryKind.Debug, "OplockLevel granted by server: {0}", grantedTmp);
            grantedOplockLevel = grantedTmp;
            c = oplockConfig;

            oplockLevelOnOpen = grantedTmp;

            fileOperationInvoker = new FileOperationDelegate(FileOperation);
            fileOperationInvoker.BeginInvoke(fileOperation, fileName, null, null);

            // Assume that notification will arrive in .5 sec if there's any
            // Without such sleep, OplockBreakNotification would not be expected by SE
            Thread.Sleep(500);
        }
        public void RequestOplockAndOperateFileRequest(
            RequestedOplockLevel_Values requestedOplockLevel,
            OplockFileOperation fileOperation,
            out OplockLevel_Values grantedOplockLevel,
            out OplockConfig c)
        {
            Smb2CreateContextResponse[] serverCreateContexts;
            string fileName = "OplockMBT_"+ Guid.NewGuid().ToString();

            OplockLevel_Values grantedTmp = OplockLevel_Values.OPLOCK_LEVEL_NONE;
            testClient.Create(
                    treeId,
                    fileName,
                    CreateOptions_Values.FILE_NON_DIRECTORY_FILE,
                    out fileId,
                    out serverCreateContexts,
                    requestedOplockLevel_Values: requestedOplockLevel,
                    checker: (header, response) =>
                    {
                        grantedTmp = response.OplockLevel;
                    });

            Site.Log.Add(LogEntryKind.Debug, "OplockLevel granted by server: {0}", grantedTmp);
            grantedOplockLevel = grantedTmp;
            c = oplockConfig;

            oplockLevelOnOpen = grantedTmp;

            fileOperationInvoker = new FileOperationDelegate(FileOperation);
            fileOperationInvoker.BeginInvoke(fileOperation, fileName, null, null);

            // Assume that notification will arrive in .5 sec if there's any
            // Without such sleep, OplockBreakNotification would not be expected by SE
            Thread.Sleep(500);
        }
        public static void RequestOplockAndOperateFileReturn(OplockLevel_Values grantedOplockLevel, OplockConfig c)
        {
            Condition.IsTrue(State == ModelState.Connected);
            Condition.IsNotNull(Request);

            ModelRequestOplockAndTriggerBreakRequest requestOplockAndTriggerBreakRequest = ModelHelper.RetrieveOutstandingRequest<ModelRequestOplockAndTriggerBreakRequest>(ref Request);

            Condition.IsTrue(Config.Platform == c.Platform);

            if (Share_ForceLevel2Oplock
                && (requestOplockAndTriggerBreakRequest.RequestedOplockLevel == RequestedOplockLevel_Values.OPLOCK_LEVEL_BATCH
                     || requestOplockAndTriggerBreakRequest.RequestedOplockLevel == RequestedOplockLevel_Values.OPLOCK_LEVEL_EXCLUSIVE))
            {
                ModelHelper.Log(LogType.Requirement,
                    "3.3.5.9: If TreeConnect.Share.ForceLevel2Oplock is TRUE, " +
                    "and RequestedOplockLevel is SMB2_OPLOCK_LEVEL_BATCH or SMB2_OPLOCK_LEVEL_EXCLUSIVE, " +
                    "the server SHOULD<245> set RequestedOplockLevel to SMB2_OPLOCK_LEVEL_II.");
                if (Config.Platform != Platform.NonWindows)
                {
                    ModelHelper.Log(LogType.TestInfo, "The SUT platform is Windows.");
                    Condition.IsTrue(grantedOplockLevel == OplockLevel_Values.OPLOCK_LEVEL_II);

                    // Skip following WBN which is for pre-Win8
                    // <226> Section 3.3.5.9: Windows Vista and Windows Server 2008 do not support the SMB2_SHAREFLAG_FORCE_LEVELII_OPLOCK flag
                    // and ignore  the TreeConnect.Share.ForceLevel2Oplock value.
                }
            }

            if (ModelUtility.IsSmb3xFamily(Connection_Dialect)
                && Share_Type_Include_STYPE_CLUSTER_SOFS
                && requestOplockAndTriggerBreakRequest.RequestedOplockLevel == RequestedOplockLevel_Values.OPLOCK_LEVEL_BATCH)
            {
                ModelHelper.Log(LogType.Requirement,
                    "3.3.5.9: If Connection.Dialect belongs to the SMB 3.x dialect family TreeConnect.Share.Type includes STYPE_CLUSTER_SOFS " +
                    "and the RequestedOplockLevel is SMB2_OPLOCK_LEVEL_BATCH, the server MUST set RequestedOplockLevel to SMB2_OPLOCK_LEVEL_II.");
                // The Oplock acquisition depends on underlying object store implemention specific
                // we may not garantee level2 would be always granted
                // Only assert it's not batch
                ModelHelper.Log(LogType.TestInfo, "All the above conditions are met.");
                Condition.IsTrue(grantedOplockLevel != OplockLevel_Values.OPLOCK_LEVEL_BATCH);
            }

            Open = new ModelOplockOpen();

            ModelHelper.Log(LogType.TestInfo, "Open.OplockLevel is set to SMB2_OPLOCK_LEVEL_NONE.");
            Open.OplockLevel = OplockLevel_Values.OPLOCK_LEVEL_NONE;

            ModelHelper.Log(LogType.TestInfo, "Open.OplockState is set to None.");
            Open.OplockState = OplockState.None;

            // Acquire Oplock from underlying object

            // If the underlying object store grants the oplock,
            // then Open.OplockState is set to Held and Open.OplockLevel is set to the level of the oplock acquired.
            if (grantedOplockLevel != OplockLevel_Values.OPLOCK_LEVEL_NONE)
            {
                ModelHelper.Log(LogType.TestInfo, "Open.OplockState is set to Held.");
                Open.OplockState = OplockState.Held;
                Open.OplockLevel = grantedOplockLevel;
            }
        }
        public static void ReadConfigReturn(OplockConfig c)
        {
            Condition.IsTrue(State == ModelState.Uninitialized);
            Condition.IsNotNull(c);
            Condition.IsTrue(c.MaxSmbVersionSupported == ModelDialectRevision.Smb2002
                || c.MaxSmbVersionSupported == ModelDialectRevision.Smb21
                || c.MaxSmbVersionSupported == ModelDialectRevision.Smb30
                || c.MaxSmbVersionSupported == ModelDialectRevision.Smb302);
            Config = c;

            State = ModelState.Initialized;
        }