CreateRandomFileName() public static method

Create file name
public static CreateRandomFileName ( ) : string
return string
示例#1
0
        protected string CreateRandomFileName()
        {
            string fileName = SmbdUtilities.CreateRandomFileName();

            fileNameList.Add(fileName);
            return(fileName);
        }
示例#2
0
 protected override void TestInitialize()
 {
     base.TestInitialize();
     fileName = SmbdUtilities.CreateRandomFileName();
     sutProtocolControlAdapter = BaseTestSite.GetAdapter <ISutProtocolControlAdapter>();
     SmbdUtilities.LogTestCaseDescription(BaseTestSite);
 }
        /// <summary>
        /// Write file content over RDMA. The file content will be writen with specific number of operations.
        /// The total size of the write content is SMB2 negotiated MaxWriteize, so content size
        /// in each SMB2 WRITE request is ( MaxWriteSize / operationCount )
        /// </summary>
        /// <param name="operationCount">count of SMB2 WRITE operation</param>
        public void WriteOverRdma(uint operationCount = 1)
        {
            string fileName = SmbdUtilities.CreateRandomFileName();

            InitSmbdConnectionForTestCases(fileName);

            uint writeSize = smbdAdapter.Smb2MaxWriteSize / operationCount;
            uint totalSize = writeSize * operationCount;

            // SMB2 Write file
            byte[] fileContent = Encoding.ASCII.GetBytes(Smb2Utility.CreateRandomStringInByte((int)writeSize));

            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Send each write request according SMB2 write file limit.");
            for (int i = 0; i < operationCount; ++i)
            {
                // register memory and get buffer descriptor
                SmbdBufferDescriptorV1 descp;
                smbdAdapter.SmbdRegisterBuffer(
                    writeSize,
                    SmbdBufferReadWrite.RDMA_READ_PERMISSION_FOR_WRITE_FILE,
                    out descp
                    );
                smbdAdapter.SmbdWriteRegisteredBuffer(fileContent, descp);
                byte[] channelInfo = TypeMarshal.ToBytes <SmbdBufferDescriptorV1>(descp);

                BaseTestSite.Log.Add(LogEntryKind.TestStep, "Write content to file over RDMA.");
                WRITE_Response writeResponse;
                NtStatus       status = (NtStatus)smbdAdapter.Smb2WriteOverRdmaChannel(
                    (UInt64)i * writeSize,
                    channelInfo,
                    writeSize,
                    out writeResponse
                    );
                BaseTestSite.Assert.AreEqual <NtStatus>(
                    NtStatus.STATUS_SUCCESS,
                    status,
                    "Status of SMB2 Write File offset {0} is {1}", i * writeSize, status);
                BaseTestSite.Assert.AreEqual <uint>(
                    (uint)writeSize,
                    writeResponse.Count,
                    "DataLength in WRITE response is {0}", writeResponse.Count);
            }

            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Validate file content.");
            ValidateFileContent(fileContent, totalSize);

            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Close file.");
            smbdAdapter.Smb2CloseFile();
        }
        public void OperationWithSpecifiedCredits(ushort credits)
        {
            // define test data for this test case
            ushort receiveCreditMax = credits;
            ushort sendCreditTarget = credits;

            uint size = smbdAdapter.TestConfig.ModerateFileSizeInByte;

            string fileName = SmbdUtilities.CreateRandomFileName();

            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Connect to server over RDMA.");
            NtStatus status = smbdAdapter.ConnectToServerOverRDMA();

            BaseTestSite.Assert.AreEqual <NtStatus>(NtStatus.STATUS_SUCCESS, status, "Status of SMBD connection is {0}", status);

            BaseTestSite.Log.Add(LogEntryKind.TestStep, "SMBD Negotiate with server.");
            SmbdNegotiateResponse response;

            status = smbdAdapter.SmbdNegotiate(sendCreditTarget, receiveCreditMax, out response);
            BaseTestSite.Assert.AreEqual <NtStatus>(NtStatus.STATUS_SUCCESS, status, "Status of SMBD negotiate is {0}", status);
            BaseTestSite.Assert.IsTrue(response.MaxFragmentedSize >= SmbdConnection.FLOOR_MAX_FRAGMENTED_SIZE
                                       , "MaxFragmentedSize in negotiate response is {0}", response.MaxFragmentedSize); // check the MaxFragementSize

            // SMB2 Negotiate, Session Setup, Tree Connect and Open File
            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Establish SMB2 connection and open file " + fileName);
            status = smbdAdapter.Smb2EstablishSessionAndOpenFile(fileName);
            BaseTestSite.Assert.AreEqual <NtStatus>(NtStatus.STATUS_SUCCESS, status, "Status of SMB2 establish session and open file is {0}", status);

            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Write a moderate size of data to the file.");
            byte[]         data = new byte[size];
            WRITE_Response writeResponse;

            status = (NtStatus)smbdAdapter.Smb2Write(0, data, out writeResponse);
            BaseTestSite.Assert.AreEqual <NtStatus>(NtStatus.STATUS_SUCCESS, status, "Status of SMB2 write File is {0}", status);
            BaseTestSite.Assert.AreEqual <uint>(size, writeResponse.Count, "Size of written file is {0}", writeResponse.Count);

            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Close file and disconnect from server.");
            smbdAdapter.Smb2CloseFile();
            // disconnect
            smbdAdapter.DisconnectRdma();
        }
        public void Smb2Multichannel_2Channels_DiffTransport()
        {
            uint   treeId;
            FILEID fileId;

            byte[] fileContent;
            string fileName = SmbdUtilities.CreateRandomFileName();

            WriteFromMainChannel(
                IPAddress.Parse(testConfig.ServerRNicIp),
                IPAddress.Parse(testConfig.ClientRNicIp),
                fileName,
                testConfig.LargeFileSizeInByte,
                out fileContent,
                out treeId,
                out fileId
                );
            ReadFromAlternativeChannel(
                fileContent,
                testConfig.LargeFileSizeInByte,
                treeId,
                fileId
                );
        }
示例#6
0
        public void Negotiate_Version(
            SmbdVersion minVer,
            SmbdVersion maxVer)
        {
            const ushort CREDIT_REQUESTED   = 10;
            const ushort RECEIVE_CREDIT_MAX = 10;
            const uint   MAX_SEND_SIZE      = 1024;
            const uint   MAX_RECEIVE_SIZE   = 1024;
            const uint   MAX_FRAGMENT_SIZE  = 131072;

            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Connect to server over RDMA");
            NtStatus status = smbdAdapter.ConnectToServerOverRDMA();

            BaseTestSite.Assert.AreEqual <NtStatus>(NtStatus.STATUS_SUCCESS, status, "Status of SMBD connection is {0}", status);

            BaseTestSite.Log.Add(LogEntryKind.TestStep, string.Format("SMBD Negotiate, MinVersion: {0}; MaxVersion: {1}", minVer.ToString(), maxVer.ToString()));
            SmbdNegotiateResponse response;

            status = smbdAdapter.SmbdNegotiate(
                CREDIT_REQUESTED,
                RECEIVE_CREDIT_MAX,
                MAX_SEND_SIZE,
                MAX_RECEIVE_SIZE,
                MAX_FRAGMENT_SIZE,
                out response,
                minVer,
                maxVer
                );

            // try to negotiate on SMB2
            string fileName = SmbdUtilities.CreateRandomFileName();

            // "<3> Section 3.1.5.6:  Windows Server 2012 fails the Negotiate Request Message with STATUS_NOT_SUPPORTED if MinVersion or MaxVersion is not 0x0100"
            if (smbdAdapter.TestConfig.Platform == Platform.WindowsServer2012)
            {
                if (minVer == SmbdVersion.V1 &&
                    maxVer == SmbdVersion.V1)
                {
                    BaseTestSite.Assert.AreEqual <NtStatus>(
                        NtStatus.STATUS_SUCCESS,
                        status,
                        "SMBD Negotiate should succeed");

                    BaseTestSite.Log.Add(LogEntryKind.TestStep, "Establish SMB2 connection and open file " + fileName);
                    status = smbdAdapter.Smb2EstablishSessionAndOpenFile(fileName);
                    BaseTestSite.Assert.AreEqual <NtStatus>(
                        NtStatus.STATUS_SUCCESS,
                        status,
                        "Smb2EstablishSessionAndOpenFile should success");
                }
                else
                {
                    BaseTestSite.Assert.AreEqual <NtStatus>(
                        NtStatus.STATUS_NOT_SUPPORTED,
                        status,
                        "Status of SMBD negotiate {0}", status);

                    try
                    {
                        BaseTestSite.Log.Add(LogEntryKind.TestStep, "Try to establish SMB2 connection and open file " + fileName);
                        status = smbdAdapter.Smb2EstablishSessionAndOpenFile(fileName);
                        BaseTestSite.Assert.AreNotEqual <NtStatus>(
                            NtStatus.STATUS_SUCCESS,
                            status,
                            "Status of Smb2EstablishSessionAndOpenFile is {0}", status);
                    }
                    catch (TimeoutException e)
                    {
                        BaseTestSite.Assert.Pass("Cannot send or receive packets from peer. \nException: {0}\n{1}", e.Message, e.StackTrace);
                    }
                }
            }
            else
            {
                if (minVer <= SmbdVersion.V1 &&
                    maxVer >= SmbdVersion.V1)
                {
                    BaseTestSite.Assert.AreEqual <NtStatus>(
                        NtStatus.STATUS_SUCCESS,
                        status,
                        "SMBD Negotiate should succeed");

                    BaseTestSite.Log.Add(LogEntryKind.TestStep, "Establish SMB2 connection and open file " + fileName);
                    status = smbdAdapter.Smb2EstablishSessionAndOpenFile(fileName);
                    BaseTestSite.Assert.AreEqual <NtStatus>(
                        NtStatus.STATUS_SUCCESS,
                        status,
                        "Smb2EstablishSessionAndOpenFile should success");
                }
                else
                {
                    BaseTestSite.Assert.AreEqual <NtStatus>(
                        NtStatus.STATUS_NOT_SUPPORTED,
                        status,
                        "Status of SMBD negotiate {0}", status);

                    try
                    {
                        BaseTestSite.Log.Add(LogEntryKind.TestStep, "Try to establish SMB2 connection and open file " + fileName);
                        status = smbdAdapter.Smb2EstablishSessionAndOpenFile(fileName);
                        BaseTestSite.Assert.AreNotEqual <NtStatus>(
                            NtStatus.STATUS_SUCCESS,
                            status,
                            "Status of Smb2EstablishSessionAndOpenFile is {0}", status);
                    }
                    catch (TimeoutException e)
                    {
                        BaseTestSite.Assert.Pass("Cannot send or receive packets from peer. \nException: {0}\n{1}", e.Message, e.StackTrace);
                    }
                }
            }
        }