-
Notifications
You must be signed in to change notification settings - Fork 0
/
Salt-minion.Tests.ps1
56 lines (46 loc) · 1.76 KB
/
Salt-minion.Tests.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
$be_computer = hostname
$Remote_computer = 'bc-adsst-102.central.bccr.fi.cr'
Describe "Salt-minion Local Services" {
Context "Check Salt-minion Local Port" {
$Local_ports = @('4510', '4511')
foreach ($port in $Local_ports) {
it "Server is listening on port $port" {
$port_state = Invoke-Command -computer $be_computer `
-ScriptBlock {param($port)(Get-NetTCPConnection -LocalPort $port `
-ErrorAction SilentlyContinue).State} `
-ArgumentList $port
$port_state.Value -contains "Listen" | should be $true
}
}
}
context 'Service Salt-minion Availability' {
$Services = @('salt-minion')
foreach ($ServX in $Services){
it "$ServX is running?" {
$svc = Get-Service -Name $ServX
$svc.Status | Should be running
}
}
}
Context "Check Remote SaltMaster Port" {
$Local_ports = @('4505', '4506')
foreach ($port in $Local_ports) {
$socket = New-Object Net.Sockets.TcpClient
it "Server is listening on port $port" {
Try{
$socket.Connect($Remote_computer, $port)
$Result = 'Success'
}
Catch{
Write-Host $_
$Result = 'Failed'
}
Finally{
$socket.Close()
$socket.Dispose()
}
$Result -contains 'Success' | should be $true
}
}
}
}