This commit is contained in:
Zihao Chen 2018-07-16 21:27:04 +08:00
Родитель 6d00b8413e
Коммит ef4212f62c
4 изменённых файлов: 184 добавлений и 0 удалений

163
test/Integration.Tests.ps1 Normal file
Просмотреть файл

@ -0,0 +1,163 @@
Add-PSSnapin Microsoft.Hpc
$scriptRoot = $PSScriptRoot
Describe "HPC Mesos Integration Test" {
Context "Basic 1 node Grow Shrink" {
It "checks no nodes online at the begining" {
$retries = 60
while ($retries -gt 0) {
$nodes = Get-HpcNode -State Online
$ans = $nodes.Count
if ($ans -eq 0) {
break
}
$retries--
Start-Sleep 10
}
$ans | Should -Be 0
}
It "submits a new 1 core job and waits for it to success" {
$1CoreJobXml = Join-Path $scriptRoot "JobXml\1Core.Xml"
$job = New-HpcJob -JobFile $1CoreJobXml
Submit-HpcJob -Job $job
$retries = 60
while ($retries -gt 0) {
$job.Refresh()
$ans = $job.State -eq "Finished"
if ($ans) {
break
}
$retries--
Start-Sleep 10
}
$ans | Should -BeTrue
}
It "checks if over grown" {
$nodes = Get-HpcNode -State Online
$nodes.Count | Should -Be 1
}
It "checks nodes get shrunk in the end" {
$retries = 60
while ($retries -gt 0) {
$nodes = Get-HpcNode -State Online
$ans = $nodes.Count
if ($ans -eq 0) {
break
}
$retries--
Start-Sleep 10
}
$ans | Should -Be 0
}
}
Context "Basic 9 node Grow Shrink" {
It "checks no nodes online at the begining" {
$retries = 60
while ($retries -gt 0) {
$nodes = Get-HpcNode -State Online
$ans = $nodes.Count
if ($ans -eq 0) {
break
}
$retries--
Start-Sleep 10
}
$ans | Should -Be 0
}
It "submits a new 9 cores job and waits for that to success" {
$1CoreJobXml = Join-Path $scriptRoot "JobXml\9Cores.Xml"
$job = New-HpcJob -JobFile $1CoreJobXml
Submit-HpcJob -Job $job
$retries = 60
while ($retries -gt 0) {
$job.Refresh()
$ans = $job.State -eq "Finished"
if ($ans) {
break
}
$retries--
Start-Sleep 10
}
$ans | Should -BeTrue
}
It "checks if over grown" {
$nodes = Get-HpcNode -State Online
$nodes.Count | Should -Be 2
}
It "checks nodes get shrunk in the end" {
$retries = 60
while ($retries -gt 0) {
$nodes = Get-HpcNode -State Online
$ans = $nodes.Count
if ($ans -eq 0) {
break
}
$retries--
Start-Sleep 10
}
$ans | Should -Be 0
}
}
Context "1 node required node group Grow Shrink" {
It "checks no nodes online at the begining" {
$retries =60
while ($retries -gt 0) {
$nodes = Get-HpcNode -State Online
$ans = $nodes.Count
if ($ans -eq 0) {
break
}
$retries--
Start-Sleep 10
}
$ans | Should -Be 0
}
It "submits a new 1 core job and waits for it to success" {
$1CoreJobXml = Join-Path $scriptRoot "JobXml\NeedNg1.Xml"
$job = New-HpcJob -JobFile $1CoreJobXml
Submit-HpcJob -Job $job
$retries = 60
while ($retries -gt 0) {
$job.Refresh()
$ans = $job.State -eq "Finished"
if ($ans) {
break
}
$retries--
Start-Sleep 10
}
$ans | Should -BeTrue
}
It "checks if over grown" {
$nodes = Get-HpcNode -State Online
$nodes.Count | Should -Be 1
}
It "checks nodes get shrunk in the end" {
$retries = 60
while ($retries -gt 0) {
$nodes = Get-HpcNode -State Online
$ans = $nodes.Count
if ($ans -eq 0) {
break
}
$retries--
Start-Sleep 10
}
$ans | Should -Be 0
}
}
}

7
test/JobXml/1Core.xml Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Job Version="3.000" Id="31" State="Finished" SubmitTime="7/16/2018 6:32:42 AM" CreateTime="7/16/2018 6:32:40 AM" StartTime="7/16/2018 6:32:42 AM" Name="1Core" IsExclusive="false" RunUntilCanceled="false" UnitType="Core" Owner="HPC\hpcadmin" UserName="HPC\hpcadmin" Project="" JobType="Batch" JobTemplate="Default" Priority="Normal" OrderBy="" RequeueCount="0" AutoRequeueCount="0" PendingReason="None" AutoCalculateMax="true" AutoCalculateMin="true" FailOnTaskFailure="false" Progress="100" ProgressMessage="" MinCores="1" MaxCores="1" NotifyOnStart="false" NotifyOnCompletion="false" ParentJobIds="" EstimatedProcessMemory="0" TaskExecutionFailureRetryLimit="0" xmlns="http://schemas.microsoft.com/HPCS2008R2/scheduler/">
<Dependencies />
<Tasks>
<Task Version="3.000" Id="29" ParentJobId="31" State="Finished" UnitType="Core" NiceId="1" CommandLine="ping localhost -n 11 &amp; hostname" RequeueCount="0" PendingReason="None" StartValue="0" EndValue="0" IncrementValue="1" GroupId="31" SubmitTime="7/16/2018 6:32:42 AM" StartTime="7/16/2018 6:32:42 AM" CreateTime="7/16/2018 6:32:40 AM" Name="My Task" MinCores="1" MaxCores="1" AutoRequeueCount="0" Type="Basic" FailJobOnFailure="false" />
</Tasks>
</Job>

7
test/JobXml/9Cores.xml Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Job Version="3.000" Id="49" State="Finished" SubmitTime="7/16/2018 1:24:11 PM" CreateTime="7/16/2018 1:23:30 PM" StartTime="7/16/2018 1:24:12 PM" Name="9Cores" IsExclusive="false" RunUntilCanceled="false" UnitType="Core" Owner="HPC\hpcadmin" UserName="HPC\hpcadmin" Project="" JobType="Batch" JobTemplate="Default" Priority="Normal" OrderBy="" RequeueCount="0" AutoRequeueCount="0" PendingReason="None" AutoCalculateMax="true" AutoCalculateMin="false" FailOnTaskFailure="false" Progress="100" ProgressMessage="" MinCores="9" MaxCores="1" NotifyOnStart="false" NotifyOnCompletion="false" JobValidExitCodes="0" ParentJobIds="" EstimatedProcessMemory="0" TaskExecutionFailureRetryLimit="0" xmlns="http://schemas.microsoft.com/HPCS2008R2/scheduler/">
<Dependencies />
<Tasks>
<Task Version="3.000" Id="46" ParentJobId="49" State="Finished" UnitType="Core" NiceId="1" CommandLine="ping localhost -n 11 &amp; hostname" RequeueCount="0" PendingReason="None" StartValue="0" EndValue="0" IncrementValue="1" GroupId="49" SubmitTime="7/16/2018 1:24:11 PM" StartTime="7/16/2018 1:24:12 PM" CreateTime="7/16/2018 1:23:30 PM" Name="My Task" MinCores="9" MaxCores="9" AutoRequeueCount="0" Type="Basic" FailJobOnFailure="false" />
</Tasks>
</Job>

7
test/JobXml/NeedNg1.xml Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Job Version="3.000" Id="30" State="Finished" SubmitTime="7/16/2018 6:31:32 AM" CreateTime="7/16/2018 6:31:30 AM" StartTime="7/16/2018 6:32:23 AM" Name="NeedNg1" IsExclusive="false" RunUntilCanceled="false" UnitType="Core" Owner="HPC\hpcadmin" UserName="HPC\hpcadmin" Project="" JobType="Batch" JobTemplate="Default" Priority="Normal" NodeGroups="NodeGroup1" OrderBy="" RequeueCount="0" AutoRequeueCount="0" PendingReason="None" AutoCalculateMax="true" AutoCalculateMin="true" FailOnTaskFailure="false" Progress="100" ProgressMessage="" MinCores="1" MaxCores="1" NotifyOnStart="false" NotifyOnCompletion="false" NodeGroupOp="Intersect" JobValidExitCodes="0" ParentJobIds="" EstimatedProcessMemory="0" TaskExecutionFailureRetryLimit="0" xmlns="http://schemas.microsoft.com/HPCS2008R2/scheduler/">
<Dependencies />
<Tasks>
<Task Version="3.000" Id="28" ParentJobId="30" State="Finished" UnitType="Core" NiceId="1" CommandLine="ping localhost -n 11 &amp; hostname" RequeueCount="0" PendingReason="None" StartValue="0" EndValue="0" IncrementValue="1" GroupId="30" SubmitTime="7/16/2018 6:31:32 AM" StartTime="7/16/2018 6:32:23 AM" CreateTime="7/16/2018 6:31:30 AM" Name="My Task" MinCores="1" MaxCores="1" AutoRequeueCount="0" Type="Basic" FailJobOnFailure="false" />
</Tasks>
</Job>