mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-11-25 06:16:37 +01:00
Merge pull request #1611 from MihaelaStoica/master
CA-255458: Fix the HealthCheck tests - RequestUploadTaskTests
This commit is contained in:
commit
681d4ab47b
@ -50,11 +50,22 @@ namespace XenAdminTests.HealthCheckTests
|
|||||||
{
|
{
|
||||||
private const char SEPARATOR = '\x202f'; // narrow non-breaking space.
|
private const char SEPARATOR = '\x202f'; // narrow non-breaking space.
|
||||||
|
|
||||||
[Test]
|
[TestFixtureSetUp]
|
||||||
public void CredentialOp()
|
public void FixtureSetup()
|
||||||
{
|
{
|
||||||
CredentialReceiver.instance.Init();
|
CredentialReceiver.instance.Init();
|
||||||
ServerListHelper.instance.Init();
|
ServerListHelper.instance.Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestFixtureTearDown]
|
||||||
|
public void FixtureTearDown()
|
||||||
|
{
|
||||||
|
CredentialReceiver.instance.UnInit();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void CredentialOp()
|
||||||
|
{
|
||||||
string HostName = "Host1";
|
string HostName = "Host1";
|
||||||
string UserName = "User1";
|
string UserName = "User1";
|
||||||
string Password = "password1";
|
string Password = "password1";
|
||||||
@ -156,8 +167,6 @@ namespace XenAdminTests.HealthCheckTests
|
|||||||
System.Threading.Thread.Sleep(1000);
|
System.Threading.Thread.Sleep(1000);
|
||||||
con = ServerListHelper.instance.GetServerList();
|
con = ServerListHelper.instance.GetServerList();
|
||||||
Assert.IsTrue(con.Count == conSize);
|
Assert.IsTrue(con.Count == conSize);
|
||||||
|
|
||||||
CredentialReceiver.instance.UnInit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,8 @@ namespace XenAdminTests.HealthCheckTests
|
|||||||
{
|
{
|
||||||
private const char SEPARATOR = '\x202f'; // narrow non-breaking space.
|
private const char SEPARATOR = '\x202f'; // narrow non-breaking space.
|
||||||
private const string dbName = "TampaTwoHostPoolSelectioniSCSI.xml";
|
private const string dbName = "TampaTwoHostPoolSelectioniSCSI.xml";
|
||||||
|
private const string nonEmptyPassword = "nonemptypassword"; // needed when the credentials are sent to the HealthCheck, as the credential receiver will othrwise ignore them
|
||||||
|
|
||||||
public RequestUploadTaskTests() : base(dbName) { }
|
public RequestUploadTaskTests() : base(dbName) { }
|
||||||
private static string UUID = "test-test";
|
private static string UUID = "test-test";
|
||||||
|
|
||||||
@ -64,24 +66,32 @@ namespace XenAdminTests.HealthCheckTests
|
|||||||
config[HealthCheckSettings.LAST_FAILED_UPLOAD] = "";
|
config[HealthCheckSettings.LAST_FAILED_UPLOAD] = "";
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
[TestFixtureSetUp]
|
||||||
|
public void FixtureSetup()
|
||||||
|
{
|
||||||
|
CredentialReceiver.instance.Init();
|
||||||
|
ServerListHelper.instance.Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestFixtureTearDown]
|
||||||
|
public void FixtureTearDown()
|
||||||
|
{
|
||||||
|
CredentialReceiver.instance.UnInit();
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void CheckUnenrolledHostShouldRemoved()
|
public void CheckUnenrolledHostShouldRemoved()
|
||||||
{
|
{
|
||||||
CredentialReceiver.instance.Init();
|
|
||||||
ServerListHelper.instance.Init();
|
|
||||||
DatabaseManager.CreateNewConnection(dbName);
|
|
||||||
IXenConnection connection = DatabaseManager.ConnectionFor(dbName);
|
IXenConnection connection = DatabaseManager.ConnectionFor(dbName);
|
||||||
Session _session = DatabaseManager.ConnectionFor(dbName).Session;
|
Session _session = DatabaseManager.ConnectionFor(dbName).Session;
|
||||||
DatabaseManager.ConnectionFor(dbName).LoadCache(_session);
|
|
||||||
Dictionary<string, string> config = cleanStack();
|
Dictionary<string, string> config = cleanStack();
|
||||||
connection.LoadCache(_session);
|
|
||||||
|
|
||||||
|
ServerListHelper.instance.ClearServerList();
|
||||||
int conSize = ServerListHelper.instance.GetServerList().Count;
|
int conSize = ServerListHelper.instance.GetServerList().Count;
|
||||||
|
|
||||||
NamedPipeClientStream pipeClient = new NamedPipeClientStream(".", HealthCheckSettings.HEALTH_CHECK_PIPE, PipeDirection.Out);
|
NamedPipeClientStream pipeClient = new NamedPipeClientStream(".", HealthCheckSettings.HEALTH_CHECK_PIPE, PipeDirection.Out);
|
||||||
pipeClient.Connect();
|
pipeClient.Connect();
|
||||||
string credential = EncryptionUtils.ProtectForLocalMachine(String.Join(SEPARATOR.ToString(), new[] { connection.Hostname, connection.Username, connection.Password }));
|
string credential = EncryptionUtils.ProtectForLocalMachine(String.Join(SEPARATOR.ToString(), new[] { connection.Hostname, connection.Username, nonEmptyPassword }));
|
||||||
pipeClient.Write(Encoding.UTF8.GetBytes(credential), 0, credential.Length);
|
pipeClient.Write(Encoding.UTF8.GetBytes(credential), 0, credential.Length);
|
||||||
pipeClient.Close();
|
pipeClient.Close();
|
||||||
System.Threading.Thread.Sleep(1000);
|
System.Threading.Thread.Sleep(1000);
|
||||||
@ -96,20 +106,17 @@ namespace XenAdminTests.HealthCheckTests
|
|||||||
Assert.IsFalse(RequestUploadTask.Request(connection, _session));
|
Assert.IsFalse(RequestUploadTask.Request(connection, _session));
|
||||||
con = ServerListHelper.instance.GetServerList();
|
con = ServerListHelper.instance.GetServerList();
|
||||||
Assert.IsTrue(con.Count == conSize);
|
Assert.IsTrue(con.Count == conSize);
|
||||||
CredentialReceiver.instance.UnInit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test, Timeout( 100 * 1000 )]
|
[Test, Timeout( 100 * 1000 )]
|
||||||
public void checkUploadLock()
|
public void checkUploadLock()
|
||||||
{
|
{
|
||||||
DatabaseManager.CreateNewConnection(dbName);
|
|
||||||
IXenConnection connection = DatabaseManager.ConnectionFor(dbName);
|
IXenConnection connection = DatabaseManager.ConnectionFor(dbName);
|
||||||
Session _session = DatabaseManager.ConnectionFor(dbName).Session;
|
Session _session = DatabaseManager.ConnectionFor(dbName).Session;
|
||||||
DatabaseManager.ConnectionFor(dbName).LoadCache(_session);
|
|
||||||
|
|
||||||
Dictionary<string, string> config = cleanStack();
|
Dictionary<string, string> config = cleanStack();
|
||||||
connection.LoadCache(_session);
|
|
||||||
|
|
||||||
//1. If XenServer has not enroll, lock will not been set.
|
//1. If XenServer has not enroll, lock will not been set.
|
||||||
config = cleanStack();
|
config = cleanStack();
|
||||||
config[HealthCheckSettings.STATUS] = "false";
|
config[HealthCheckSettings.STATUS] = "false";
|
||||||
@ -217,12 +224,10 @@ namespace XenAdminTests.HealthCheckTests
|
|||||||
[Test]
|
[Test]
|
||||||
public void checkDemandLock()
|
public void checkDemandLock()
|
||||||
{
|
{
|
||||||
DatabaseManager.CreateNewConnection(dbName);
|
|
||||||
IXenConnection connection = DatabaseManager.ConnectionFor(dbName);
|
IXenConnection connection = DatabaseManager.ConnectionFor(dbName);
|
||||||
Session _session = DatabaseManager.ConnectionFor(dbName).Session;
|
Session _session = DatabaseManager.ConnectionFor(dbName).Session;
|
||||||
DatabaseManager.ConnectionFor(dbName).LoadCache(_session);
|
|
||||||
Dictionary<string, string> config = cleanStack();
|
Dictionary<string, string> config = cleanStack();
|
||||||
connection.LoadCache(_session);
|
|
||||||
//1 Uploading is inprocess by current service, demand will be ignore
|
//1 Uploading is inprocess by current service, demand will be ignore
|
||||||
config = cleanStack();
|
config = cleanStack();
|
||||||
config[HealthCheckSettings.UPLOAD_LOCK] = UUID + "|" + HealthCheckSettings.DateTimeToString(DateTime.UtcNow);
|
config[HealthCheckSettings.UPLOAD_LOCK] = UUID + "|" + HealthCheckSettings.DateTimeToString(DateTime.UtcNow);
|
||||||
|
Loading…
Reference in New Issue
Block a user