public void TwoClientsReadSameSharedVHD() { BaseTestSite.Log.Add(LogEntryKind.TestStep, "1. The first client opens a shared virtual disk file and expects success."); OpenSharedVHD(TestConfig.NameOfSharedVHDX, RSVD_PROTOCOL_VERSION.RSVD_PROTOCOL_VERSION_1, 0); BaseTestSite.Log.Add(LogEntryKind.TestStep, "2. The first client reads file content and expects success."); byte[] payload; uint status = client.Read(0, 512, out payload); BaseTestSite.Assert.AreEqual( (uint)Smb2Status.STATUS_SUCCESS, status, "Read content of shared virtual disk file from the first client should succeed, actual status: {0}", GetStatus(status)); BaseTestSite.Log.Add(LogEntryKind.TestStep, "3. The second client opens a shared virtual disk file and expects success."); this.secondClient = new RsvdClient(TestConfig.Timeout); OpenSharedVHD(TestConfig.NameOfSharedVHDX, RSVD_PROTOCOL_VERSION.RSVD_PROTOCOL_VERSION_1, 0, rsvdClient: secondClient); BaseTestSite.Log.Add(LogEntryKind.TestStep, "4. The second client reads file content and expects success."); status = secondClient.Read(0, 512, out payload); BaseTestSite.Assert.AreEqual( (uint)Smb2Status.STATUS_SUCCESS, status, "Read content of shared virtual disk file from the second client should succeed, actual status: {0}", GetStatus(status)); BaseTestSite.Log.Add(LogEntryKind.TestStep, "5. The first client closes the file."); client.CloseSharedVirtualDisk(); BaseTestSite.Log.Add(LogEntryKind.TestStep, "6. The second client closes the file."); secondClient.CloseSharedVirtualDisk(); }
public void TwoClientsReadSameSharedVHD() { ulong requestIdforFirstClient = 0; BaseTestSite.Log.Add(LogEntryKind.TestStep, "1. The first client opens a shared virtual disk file and expects success."); OpenSharedVHD(TestConfig.NameOfSharedVHDX, requestIdforFirstClient++); BaseTestSite.Log.Add(LogEntryKind.TestStep, "2. The first client reads file content and expects success."); byte[] payload; uint status = client.Read(0, 512, out payload); BaseTestSite.Assert.AreEqual( (uint)Smb2Status.STATUS_SUCCESS, status, "Read content of shared virtual disk file from the first client should succeed, actual status: {0}", GetStatus(status)); ulong requestIdforSecondClient = 0; BaseTestSite.Log.Add(LogEntryKind.TestStep, "3. The second client opens a shared virtual disk file and expects success."); this.secondClient = new RsvdClient(TestConfig.Timeout); OpenSharedVHD(TestConfig.NameOfSharedVHDX, requestIdforSecondClient, rsvdClient: secondClient); requestIdforSecondClient++; BaseTestSite.Log.Add(LogEntryKind.TestStep, "4. The second client reads file content and expects success."); status = secondClient.Read(0, 512, out payload); BaseTestSite.Assert.AreEqual( (uint)Smb2Status.STATUS_SUCCESS, status, "Read content of shared virtual disk file from the second client should succeed, actual status: {0}", GetStatus(status)); BaseTestSite.Log.Add(LogEntryKind.TestStep, "5. The first client closes the file."); client.CloseSharedVirtualDisk(); BaseTestSite.Log.Add(LogEntryKind.TestStep, "6. The second client closes the file."); secondClient.CloseSharedVirtualDisk(); }
public void TwoClientsWriteSameSharedVHD() { ulong requestIdforFirstClient = 0; BaseTestSite.Log.Add(LogEntryKind.TestStep, "1. The first client opens a shared virtual disk file and expects success."); OpenSharedVHD(TestConfig.NameOfSharedVHDX, requestIdforFirstClient++); BaseTestSite.Log.Add(LogEntryKind.TestStep, "2. The first client writes file content and expects success."); byte[] payload = new byte[512]; uint status = client.Write(0, payload); BaseTestSite.Assert.AreEqual( (uint)Smb2Status.STATUS_SUCCESS, status, "Write content of shared virtual disk file from the first client should succeed, actual status: {0}", GetStatus(status)); BaseTestSite.Log.Add(LogEntryKind.TestStep, "3. The second client opens a shared virtual disk file and expects success."); ulong requestIdforSecondClient = 0; this.secondClient = new RsvdClient(TestConfig.Timeout); OpenSharedVHD(TestConfig.NameOfSharedVHDX, requestIdforSecondClient, rsvdClient: secondClient); BaseTestSite.Log.Add(LogEntryKind.TestStep, "4. The second client writes file content and expects success."); status = secondClient.Write(0, payload); BaseTestSite.Assert.AreEqual( (uint)Smb2Status.STATUS_SUCCESS, status, "Write content of shared virtual disk file from the second client should succeed, actual status: {0}", GetStatus(status)); BaseTestSite.Log.Add(LogEntryKind.TestStep, "5. The first client closes the file."); client.CloseSharedVirtualDisk(); BaseTestSite.Log.Add(LogEntryKind.TestStep, "6. The second client closes the file."); secondClient.CloseSharedVirtualDisk(); }
/// <summary> /// Connect to the share VHD file. /// </summary> private bool TestRsvdVersion( string vhdxName, string share, RSVD_PROTOCOL_VERSION version) { using (RsvdClient client = new RsvdClient(new TimeSpan(0, 0, defaultTimeoutInSeconds))) { CREATE_Response response; Smb2CreateContextResponse[] serverContexts; client.Connect(SUTName, SUTIpAddress, Credential.DomainName, Credential.AccountName, Credential.Password, SecurityPackageType, true, share); Smb2CreateContextRequest[] contexts; if (version == RSVD_PROTOCOL_VERSION.RSVD_PROTOCOL_VERSION_2) { contexts = new Smb2CreateContextRequest[] { new Smb2CreateSvhdxOpenDeviceContextV2 { Version = (uint)RSVD_PROTOCOL_VERSION.RSVD_PROTOCOL_VERSION_2, OriginatorFlags = (uint)OriginatorFlag.SVHDX_ORIGINATOR_PVHDPARSER, InitiatorHostName = initiatorHostName, InitiatorHostNameLength = (ushort)(initiatorHostName.Length * 2), // InitiatorHostName is a null-terminated Unicode UTF-16 string VirtualDiskPropertiesInitialized = 0, ServerServiceVersion = 0, VirtualSectorSize = 0, PhysicalSectorSize = 0, VirtualSize = 0 } }; } else { contexts = new Smb2CreateContextRequest[] { new Smb2CreateSvhdxOpenDeviceContext { Version = (uint)RSVD_PROTOCOL_VERSION.RSVD_PROTOCOL_VERSION_1, OriginatorFlags = (uint)OriginatorFlag.SVHDX_ORIGINATOR_PVHDPARSER, InitiatorHostName = initiatorHostName, InitiatorHostNameLength = (ushort)(initiatorHostName.Length * 2) // InitiatorHostName is a null-terminated Unicode UTF-16 string } }; } uint status; status = client.OpenSharedVirtualDisk( vhdxName, TestTools.StackSdk.FileAccessService.FsCreateOption.FILE_NO_INTERMEDIATE_BUFFERING, contexts, out serverContexts, out response); bool result = false; if (status != Smb2Status.STATUS_SUCCESS) { result = false; logWriter.AddLog(LogLevel.Information, string.Format("{0} is found not supported.", version)); return(result); } result = CheckOpenDeviceContext(serverContexts, version); client.CloseSharedVirtualDisk(); return(result); } }
public void BVT_TunnelSCSIPersistentReserve_ReserveConflict() { BaseTestSite.Log.Add(LogEntryKind.TestStep, "1. The first client opens a shared virtual disk file and expects success."); OpenSharedVHD(TestConfig.NameOfSharedVHDX, RSVD_PROTOCOL_VERSION.RSVD_PROTOCOL_VERSION_1); BaseTestSite.Log.Add(LogEntryKind.TestStep, "2. The second client opens a shared virtual disk file and expects success."); OpenSharedVHD(TestConfig.NameOfSharedVHDX, RSVD_PROTOCOL_VERSION.RSVD_PROTOCOL_VERSION_1, 0, true, secondClient, "client02"); System.Random random = new System.Random(); byte[] firstReservationkey = new byte[8]; random.NextBytes(firstReservationkey); byte[] secondReservationKey = new byte[8]; random.NextBytes(secondReservationKey); BaseTestSite.Log.Add(LogEntryKind.TestStep, "3. The first client sends Register service action of SCSI Persistent Reserve Out command by tunnel operation RSVD_TUNNEL_SCSI_OPERATION to server and expects success."); byte scsiStatus; SendAndReceiveSCSICommand( this.client, 10, CreateCDBBuffer_PersistentReserveOut(PERSISTENT_RESERVE_OUT_SERVICE_ACTION.REGISTER_AND_IGNORE_EXISTING_KEY, 0), CreateDataBuffer_PersistentReserveOut(0, System.BitConverter.ToUInt64(firstReservationkey, 0)), out scsiStatus); VerifyFieldInResponse("SCSIStatus", 0, scsiStatus); BaseTestSite.Log.Add(LogEntryKind.TestStep, "4. The first client sends Reserve service action of SCSI Persistent Reserve Out command by tunnel operation RSVD_TUNNEL_SCSI_OPERATION to server and expects success."); SendAndReceiveSCSICommand( this.client, 10, CreateCDBBuffer_PersistentReserveOut(PERSISTENT_RESERVE_OUT_SERVICE_ACTION.RESERVE, PERSISTENT_RESERVATION_SCOPE_AND_TYPE_CODE.WriteExclusiveRegistrantsOnly), CreateDataBuffer_PersistentReserveOut(System.BitConverter.ToUInt64(firstReservationkey, 0), 0), out scsiStatus); VerifyFieldInResponse("SCSIStatus", 0, scsiStatus); BaseTestSite.Log.Add(LogEntryKind.TestStep, "5. The second client sends Register service action of SCSI Persistent Reserve Out command by tunnel operation RSVD_TUNNEL_SCSI_OPERATION to server and expects success."); SendAndReceiveSCSICommand( secondClient, 10, CreateCDBBuffer_PersistentReserveOut(PERSISTENT_RESERVE_OUT_SERVICE_ACTION.REGISTER_AND_IGNORE_EXISTING_KEY, 0), CreateDataBuffer_PersistentReserveOut(0, System.BitConverter.ToUInt64(secondReservationKey, 0)), out scsiStatus); VerifyFieldInResponse("SCSIStatus", 0, scsiStatus); BaseTestSite.Log.Add(LogEntryKind.TestStep, "6. The second client sends Reserve service action of SCSI Persistent Reserve Out command by tunnel operation RSVD_TUNNEL_SCSI_OPERATION to server and "+ "expects server returns Reservation Conflict."); SendAndReceiveSCSICommand( secondClient, 10, CreateCDBBuffer_PersistentReserveOut(PERSISTENT_RESERVE_OUT_SERVICE_ACTION.RESERVE, PERSISTENT_RESERVATION_SCOPE_AND_TYPE_CODE.WriteExclusiveRegistrantsOnly), CreateDataBuffer_PersistentReserveOut(System.BitConverter.ToUInt64(secondReservationKey, 0), 0), out scsiStatus); VerifyFieldInResponse("SCSIStatus", 24, scsiStatus); // Status code 24 indicates Reservation Conflict BaseTestSite.Log.Add(LogEntryKind.TestStep, "7. The first client closes the file."); client.CloseSharedVirtualDisk(); BaseTestSite.Log.Add(LogEntryKind.TestStep, "8. The second client closes the file."); secondClient.CloseSharedVirtualDisk(); }
public void TwoClientsWriteSameSharedVHD() { BaseTestSite.Log.Add(LogEntryKind.TestStep, "1. The first client opens a shared virtual disk file and expects success."); OpenSharedVHD(TestConfig.NameOfSharedVHDX, RSVD_PROTOCOL_VERSION.RSVD_PROTOCOL_VERSION_1, 0); BaseTestSite.Log.Add(LogEntryKind.TestStep, "2. The first client writes file content and expects success."); byte[] payload = new byte[512]; uint status = client.Write(0, payload); BaseTestSite.Assert.AreEqual( (uint)Smb2Status.STATUS_SUCCESS, status, "Write content of shared virtual disk file from the first client should succeed, actual status: {0}", GetStatus(status)); BaseTestSite.Log.Add(LogEntryKind.TestStep, "3. The second client opens a shared virtual disk file and expects success."); this.secondClient = new RsvdClient(TestConfig.Timeout); OpenSharedVHD(TestConfig.NameOfSharedVHDX, RSVD_PROTOCOL_VERSION.RSVD_PROTOCOL_VERSION_1, 0, rsvdClient: secondClient); BaseTestSite.Log.Add(LogEntryKind.TestStep, "4. The second client writes file content and expects success."); status = secondClient.Write(0, payload); BaseTestSite.Assert.AreEqual( (uint)Smb2Status.STATUS_SUCCESS, status, "Write content of shared virtual disk file from the second client should succeed, actual status: {0}", GetStatus(status)); BaseTestSite.Log.Add(LogEntryKind.TestStep, "5. The first client closes the file."); client.CloseSharedVirtualDisk(); BaseTestSite.Log.Add(LogEntryKind.TestStep, "6. The second client closes the file."); secondClient.CloseSharedVirtualDisk(); }
/// <summary> /// Connect to the share VHD file. /// </summary> private bool TestRsvdVersion( string vhdxName, string share, RSVD_PROTOCOL_VERSION version) { using (RsvdClient client = new RsvdClient(new TimeSpan(0, 0, defaultTimeoutInSeconds))) { CREATE_Response response; Smb2CreateContextResponse[] serverContexts; client.Connect(SUTName, SUTIpAddress, Credential.DomainName, Credential.AccountName, Credential.Password, SecurityPackageType, true, share); Smb2CreateContextRequest[] contexts; if (version == RSVD_PROTOCOL_VERSION.RSVD_PROTOCOL_VERSION_2) { contexts = new Smb2CreateContextRequest[] { new Smb2CreateSvhdxOpenDeviceContextV2 { Version = (uint)RSVD_PROTOCOL_VERSION.RSVD_PROTOCOL_VERSION_2, OriginatorFlags = (uint)OriginatorFlag.SVHDX_ORIGINATOR_PVHDPARSER, InitiatorHostName = initiatorHostName, InitiatorHostNameLength = (ushort)(initiatorHostName.Length * 2), // InitiatorHostName is a null-terminated Unicode UTF-16 string VirtualDiskPropertiesInitialized = 0, ServerServiceVersion = 0, VirtualSectorSize = 0, PhysicalSectorSize = 0, VirtualSize = 0 } }; foreach (Smb2CreateSvhdxOpenDeviceContextV2 context in contexts) { logWriter.AddLog(DetectLogLevel.Information, @"OpenSharedVirtualDisk request was sent with context: "); logWriter.AddLog(DetectLogLevel.Information, @"Version: " + context.Version.ToString()); logWriter.AddLog(DetectLogLevel.Information, @"OriginatorFlags: " + context.OriginatorFlags.ToString()); logWriter.AddLog(DetectLogLevel.Information, @"InitiatorHostName: " + context.InitiatorHostName.ToString()); logWriter.AddLog(DetectLogLevel.Information, @"InitiatorHostNameLength: " + context.InitiatorHostNameLength.ToString()); } } else { contexts = new Smb2CreateContextRequest[] { new Smb2CreateSvhdxOpenDeviceContext { Version = (uint)RSVD_PROTOCOL_VERSION.RSVD_PROTOCOL_VERSION_1, OriginatorFlags = (uint)OriginatorFlag.SVHDX_ORIGINATOR_PVHDPARSER, InitiatorHostName = initiatorHostName, InitiatorHostNameLength = (ushort)(initiatorHostName.Length * 2) // InitiatorHostName is a null-terminated Unicode UTF-16 string } }; foreach (Smb2CreateSvhdxOpenDeviceContext context in contexts) { logWriter.AddLog(DetectLogLevel.Information, @"OpenSharedVirtualDisk request was sent with context: "); logWriter.AddLog(DetectLogLevel.Information, @"Version: " + context.Version.ToString()); logWriter.AddLog(DetectLogLevel.Information, @"OriginatorFlags: " + context.OriginatorFlags.ToString()); logWriter.AddLog(DetectLogLevel.Information, @"InitiatorHostName: " + context.InitiatorHostName.ToString()); logWriter.AddLog(DetectLogLevel.Information, @"InitiatorHostNameLength: " + context.InitiatorHostNameLength.ToString()); } } uint status; status = client.OpenSharedVirtualDisk( vhdxName, TestTools.StackSdk.FileAccessService.FsCreateOption.FILE_NO_INTERMEDIATE_BUFFERING, contexts, out serverContexts, out response); logWriter.AddLog(DetectLogLevel.Information, @"Get OpenSharedVirtualDisk response with status: " + status); if (serverContexts == null) { logWriter.AddLog(DetectLogLevel.Information, @"The response does not contain any server contexts."); } else { foreach (Smb2CreateContextResponse ctx in serverContexts) { Type type = ctx.GetType(); if (type.Name == "Smb2CreateSvhdxOpenDeviceContextResponse") { logWriter.AddLog(DetectLogLevel.Information, @"Server response context is Smb2CreateSvhdxOpenDeviceContextResponse. "); Smb2CreateSvhdxOpenDeviceContextResponse openDeviceContext = ctx as Smb2CreateSvhdxOpenDeviceContextResponse; logWriter.AddLog(DetectLogLevel.Information, @"Version is: " + openDeviceContext.Version.ToString()); logWriter.AddLog(DetectLogLevel.Information, @"InitiatorHostName is: " + openDeviceContext.InitiatorHostName.ToString()); logWriter.AddLog(DetectLogLevel.Information, @"InitiatorHostNameLength is: " + openDeviceContext.InitiatorHostNameLength.ToString()); } if (type.Name == "Smb2CreateSvhdxOpenDeviceContextResponseV2") { logWriter.AddLog(DetectLogLevel.Information, @"Server response context is Smb2CreateSvhdxOpenDeviceContextResponseV2. "); Smb2CreateSvhdxOpenDeviceContextResponseV2 openDeviceContext = ctx as Smb2CreateSvhdxOpenDeviceContextResponseV2; logWriter.AddLog(DetectLogLevel.Information, @"Version is: " + openDeviceContext.Version.ToString()); logWriter.AddLog(DetectLogLevel.Information, @"InitiatorHostName is: " + openDeviceContext.InitiatorHostName.ToString()); logWriter.AddLog(DetectLogLevel.Information, @"InitiatorHostNameLength is: " + openDeviceContext.InitiatorHostNameLength.ToString()); } } } bool result = false; if (status != Smb2Status.STATUS_SUCCESS) { result = false; logWriter.AddLog(DetectLogLevel.Information, @"Get status " + status + @" from server response."); logWriter.AddLog(DetectLogLevel.Information, @"The RSVD version " + version + @" is found not supported by server."); return(result); } result = CheckOpenDeviceContext(serverContexts, version); client.CloseSharedVirtualDisk(); return(result); } }
/// <summary> /// Connect to the share VHD file. /// </summary> private bool TestRsvdVersion( string vhdxName, string share, RSVD_PROTOCOL_VERSION version) { using (RsvdClient client = new RsvdClient(new TimeSpan(0, 0, defaultTimeoutInSeconds))) { CREATE_Response response; Smb2CreateContextResponse[] serverContexts; client.Connect(SUTName, SUTIpAddress, Credential.DomainName, Credential.AccountName, Credential.Password, SecurityPackageType, true, share); Smb2CreateContextRequest[] contexts; if (version == RSVD_PROTOCOL_VERSION.RSVD_PROTOCOL_VERSION_2) { contexts = new Smb2CreateContextRequest[] { new Smb2CreateSvhdxOpenDeviceContextV2 { Version = (uint)RSVD_PROTOCOL_VERSION.RSVD_PROTOCOL_VERSION_2, OriginatorFlags = (uint)OriginatorFlag.SVHDX_ORIGINATOR_PVHDPARSER, InitiatorHostName = initiatorHostName, InitiatorHostNameLength = (ushort)(initiatorHostName.Length * 2), // InitiatorHostName is a null-terminated Unicode UTF-16 string VirtualDiskPropertiesInitialized = 0, ServerServiceVersion = 0, VirtualSectorSize = 0, PhysicalSectorSize = 0, VirtualSize = 0 } }; } else { contexts = new Smb2CreateContextRequest[] { new Smb2CreateSvhdxOpenDeviceContext { Version = (uint)RSVD_PROTOCOL_VERSION.RSVD_PROTOCOL_VERSION_1, OriginatorFlags = (uint)OriginatorFlag.SVHDX_ORIGINATOR_PVHDPARSER, InitiatorHostName = initiatorHostName, InitiatorHostNameLength = (ushort)(initiatorHostName.Length * 2) // InitiatorHostName is a null-terminated Unicode UTF-16 string } }; } uint status; status = client.OpenSharedVirtualDisk( vhdxName, TestTools.StackSdk.FileAccessService.FsCreateOption.FILE_NO_INTERMEDIATE_BUFFERING, contexts, out serverContexts, out response); bool result = false; if (status != Smb2Status.STATUS_SUCCESS) { result = false; logWriter.AddLog(LogLevel.Information, string.Format("{0} is found not supported.", version)); return result; } result = CheckOpenDeviceContext(serverContexts, version); client.CloseSharedVirtualDisk(); return result; } }