Skip to content

Commit 879fdc7

Browse files
committed
Install-OSServer: Fixed a bug when trying to update lifetime installer. Get-OSServerInfo: Added Lifetime version output
1 parent 9d4a872 commit 879fdc7

8 files changed

Lines changed: 50 additions & 28 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Outsystems.SetupTools Release History
22

3+
## 3.9.0.0
4+
5+
- Install-OSServer: Fixed a bug when trying to update lifetime installer
6+
- Get-OSServerInfo: Added Lifetime version output
7+
38
## 3.8.0.0
49

510
- Updated the OutSystems repo for downloading sources

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: 3.8.0.{build}
1+
version: 3.9.0.{build}
22

33
only_commits:
44
files:

src/Outsystems.SetupTools/Functions/Get-OSServerInfo.ps1

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ function Get-OSServerInfo
2323

2424
# Initialize the results object
2525
$serverInfo = [pscustomobject]@{
26-
PSTypeName = 'Outsystems.SetupTools.ServerInfo'
27-
InstallDir = ''
28-
Version = ''
29-
MachineName = ''
30-
SerialNumber = ''
31-
PrivateKey = ''
26+
PSTypeName = 'Outsystems.SetupTools.ServerInfo'
27+
InstallDir = ''
28+
Version = ''
29+
MachineName = ''
30+
SerialNumber = ''
31+
PrivateKey = ''
32+
LifetimeVersion = ''
3233
}
3334
}
3435

@@ -48,11 +49,13 @@ function Get-OSServerInfo
4849
$serverInfo.Version = [System.Version]$serverInfo.Version
4950
$serverInfo.MachineName = GetServerMachineName
5051
$serverInfo.SerialNumber = GetServerSerialNumber
52+
$serverInfo.LifetimeVersion = [System.Version]$(GetLifetimeVersion)
5153

5254
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 0 -Message "Server InstallDir is: $($serverInfo.InstallDir)"
5355
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 0 -Message "Server version is: $($serverInfo.Version)"
5456
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 0 -Message "Server machine name is: $($serverInfo.MachineName)"
5557
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 0 -Message "Server serial number is: $($serverInfo.SerialNumber)"
58+
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 0 -Message "Lifetime version is: $($serverInfo.LifetimeVersion)"
5659

5760
#region private key
5861
$privateKeyFile = "$($serverInfo.InstallDir)\private.key"

src/Outsystems.SetupTools/Functions/Install-OSServer.ps1

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,16 @@ function Install-OSServer
119119

120120
$osVersion = GetServerVersion
121121
$osInstallDir = GetServerInstallDir
122-
123-
# Installer name
124122
$osInstaller = "PlatformServer-$Version.exe"
123+
124+
# Lifetime with platform server
125125
if ($WithLifetime.IsPresent)
126126
{
127-
# Lifetime installer instead
127+
# Replace the installer name
128128
$osInstaller = "LifeTimeWithPlatformServer-$Version.exe"
129+
130+
# Get lifetime version instead of platform server
131+
$osVersion = GetLifetimeVersion
129132
}
130133
}
131134

src/Outsystems.SetupTools/Lib/PlatformSetup.ps1

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,16 @@ function GetServerVersion()
706706
return $output
707707
}
708708

709+
function GetLifetimeVersion()
710+
{
711+
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 2 -Message "Getting the contents of the registry key HKLM:SOFTWARE\OutSystems\Installer\Server\LifeTime"
712+
$output = RegRead -Path "HKLM:SOFTWARE\OutSystems\Installer\Server" -Name "LifeTime"
713+
714+
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 2 -Message "Returning: $output"
715+
716+
return $output
717+
}
718+
709719
function GetServiceStudioVersion([string]$MajorVersion)
710720
{
711721
LogMessage -Function $($MyInvocation.Mycommand) -Phase 1 -Stream 2 -Message "Getting the contents of the registry key HKLM:SOFTWARE\OutSystems\Installer\Service Studio $MajorVersion\Service Studio $MajorVersion"

src/Outsystems.SetupTools/OutSystems.SetupTools.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'OutSystems.SetupTools.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '3.8.0.0'
15+
ModuleVersion = '3.9.0.0'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()

test/unit/Get-OSServerInfo.Tests.ps1

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,20 @@ InModuleScope -ModuleName OutSystems.SetupTools {
2020
Mock GetServerSerialNumber { return 'XBI-NMO-IL5-OYI-9SO-LCU-4SQ-QUT' }
2121
Mock Test-Path { return $true }
2222
Mock Get-Content { return $filecontent }
23+
Mock GetLifetimeVersion { return $null }
2324

2425
$assGetServerInstallDir = @{ 'CommandName' = 'GetServerInstallDir'; 'Times' = 1; 'Exactly' = $true ; 'Scope' = 'Context' }
2526
$assGetServerVersion = @{ 'CommandName' = 'GetServerVersion'; 'Times' = 1; 'Exactly' = $true ; 'Scope' = 'Context' }
2627
$assGetServerMachineName = @{ 'CommandName' = 'GetServerMachineName'; 'Times' = 1; 'Exactly' = $true ; 'Scope' = 'Context' }
2728
$assGetServerSerialNumber = @{ 'CommandName' = 'GetServerSerialNumber'; 'Times' = 1; 'Exactly' = $true ; 'Scope' = 'Context' }
29+
$assGetLifetimeVersion = @{ 'CommandName' = 'GetLifetimeVersion'; 'Times' = 1; 'Exactly' = $true ; 'Scope' = 'Context' }
30+
2831

2932
$assNotGetServerInstallDir = @{ 'CommandName' = 'GetServerInstallDir'; 'Times' = 0; 'Exactly' = $true ; 'Scope' = 'Context' }
3033
$assNotGetServerVersion = @{ 'CommandName' = 'GetServerVersion'; 'Times' = 0; 'Exactly' = $true ; 'Scope' = 'Context' }
3134
$assNotGetServerMachineName = @{ 'CommandName' = 'GetServerMachineName'; 'Times' = 0; 'Exactly' = $true ; 'Scope' = 'Context' }
3235
$assNotGetServerSerialNumber = @{ 'CommandName' = 'GetServerSerialNumber'; 'Times' = 0; 'Exactly' = $true ; 'Scope' = 'Context' }
36+
$assNotGetLifetimeVersion = @{ 'CommandName' = 'GetLifetimeVersion'; 'Times' = 0; 'Exactly' = $true ; 'Scope' = 'Context' }
3337

3438
Context 'When platform is not installed' {
3539

@@ -41,6 +45,7 @@ InModuleScope -ModuleName OutSystems.SetupTools {
4145
It 'Should call the GetServerVersion' { Assert-MockCalled @assGetServerVersion }
4246
It 'Should not call the GetServerMachineName' { Assert-MockCalled @assNotGetServerMachineName }
4347
It 'Should not call the GetServerSerialNumber' { Assert-MockCalled @assNotGetServerSerialNumber }
48+
It 'Should not call the GetLifetimeVersion' { Assert-MockCalled @assNotGetLifetimeVersion }
4449
It 'Should output an error' { $err[-1] | Should Be 'Outsystems platform is not installed' }
4550
It 'Should not throw' { { Get-OSServerInfo -ErrorAction SilentlyContinue } | Should Not throw }
4651
}
@@ -54,33 +59,25 @@ InModuleScope -ModuleName OutSystems.SetupTools {
5459
It 'Should return the correct machine name' { $output.MachineName | Should Be 'MYMACHINE' }
5560
It 'Should return the correct serial number' { $output.SerialNumber | Should Be 'XBI-NMO-IL5-OYI-9SO-LCU-4SQ-QUT' }
5661
It 'Should return the correct private key' { $output.PrivateKey | Should Be 'v4iwANAsGDRpjiEpO8Kt3Q==' }
62+
It 'Should return the correct lifetime version' { $output.LifetimeVersion| Should Be $null }
5763
It 'Should output a version type property' { ($output.Version).GetType().Name | Should Be 'Version' }
5864
It 'Should call the GetServerInstallDir' { Assert-MockCalled @assGetServerInstallDir }
5965
It 'Should call the GetServerVersion' { Assert-MockCalled @assGetServerVersion }
6066
It 'Should call the GetServerMachineName' { Assert-MockCalled @assGetServerMachineName }
6167
It 'Should call the GetServerSerialNumber' { Assert-MockCalled @assGetServerSerialNumber }
68+
It 'Should call the GetLifetimeVersion' { Assert-MockCalled @assGetLifetimeVersion }
6269
It 'Should not output an error' { $err.Count | Should Be 0 }
6370
It 'Should not throw' { { Get-OSServerInfo -ErrorAction SilentlyContinue } | Should Not throw }
6471
}
6572

66-
Context 'When the platform server is installed but NOT configured' {
73+
Context 'When lifetime is installed' {
6774

68-
Mock GetServerMachineName { return $null }
69-
Mock GetServerSerialNumber { return $null }
70-
Mock Test-Path { return $false }
75+
Mock GetLifetimeVersion { return '11.0.0.1' }
7176

7277
$output = Get-OSServerInfo -ErrorAction SilentlyContinue -ErrorVariable err
7378

74-
It 'Should return the correct install directory' { $output.InstallDir | Should Be 'C:\Program Files\OutSystems\Platform Server' }
75-
It 'Should return the correct server version' { $output.Version| Should Be '11.0.0.0' }
76-
It 'Should return an empty machine name' { $output.MachineName | Should Be $null }
77-
It 'Should return an empty serial number' { $output.SerialNumber | Should Be $null }
78-
It 'Should return an empty private key' { $output.PrivateKey | Should Be '' }
79-
It 'Should output a version type property' { ($output.Version).GetType().Name | Should Be 'Version' }
80-
It 'Should call the GetServerInstallDir' { Assert-MockCalled @assGetServerInstallDir }
81-
It 'Should call the GetServerVersion' { Assert-MockCalled @assGetServerVersion }
82-
It 'Should call the GetServerMachineName' { Assert-MockCalled @assGetServerMachineName }
83-
It 'Should call the GetServerSerialNumber' { Assert-MockCalled @assGetServerSerialNumber }
79+
It 'Should return the correct server version' { $output.LifetimeVersion| Should Be '11.0.0.1' }
80+
It 'Should output a version type property for lifetime' { ($output.LifetimeVersion).GetType().Name | Should Be 'Version' }
8481
It 'Should not output an error' { $err.Count | Should Be 0 }
8582
It 'Should not throw' { { Get-OSServerInfo -ErrorAction SilentlyContinue } | Should Not throw }
8683
}

test/unit/Install-OSServer.Tests.ps1

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ InModuleScope -ModuleName OutSystems.SetupTools {
88
Mock IsAdmin { return $true }
99
Mock GetServerVersion { return '10.0.0.1' }
1010
Mock GetServerInstallDir { return 'C:\Program Files\OutSystems\Platform Server' }
11+
Mock GetLifetimeVersion { return $null }
1112
Mock DownloadOSSources {}
1213
Mock Start-Process { return @{ 'Output' = 'All good'; 'ExitCode' = 0} }
1314

@@ -236,11 +237,14 @@ InModuleScope -ModuleName OutSystems.SetupTools {
236237
Context 'When lifetime switch is specified' {
237238

238239
Mock GetServerVersion { return $null }
239-
Mock GetServerInstallDir { return $null }
240+
241+
# Here we are testing also that the version used to compare is the lifetime version and not the platform server version
242+
Mock GetServerInstallDir { return '11.1.0.0' }
243+
Mock GetLifetimeVersion { return '11.0.0.0' }
240244

241245
$assRunParams = @{ 'CommandName' = 'Start-Process'; 'Times' = 1; 'Exactly' = $true; 'Scope' = 'Context'; 'ParameterFilter' = { $FilePath -eq "$ENV:TEMP\LifeTimeWithPlatformServer-11.0.0.1.exe" } }
242246

243-
$result = Install-OSServer -Version '11.0.0.1' -WithLifeTime -ErrorVariable err -ErrorAction SilentlyContinue
247+
$null = Install-OSServer -Version '11.0.0.1' -WithLifeTime -ErrorVariable err -ErrorAction SilentlyContinue
244248

245249
It 'Should run the installation using the lifetime installer' { Assert-MockCalled @assRunParams }
246250
}
@@ -252,7 +256,7 @@ InModuleScope -ModuleName OutSystems.SetupTools {
252256

253257
$assRunParams = @{ 'CommandName' = 'Start-Process'; 'Times' = 1; 'Exactly' = $true; 'Scope' = 'Context'; 'ParameterFilter' = { $FilePath -eq "$ENV:TEMP\PlatformServer-11.0.0.1.exe" } }
254258

255-
$result = Install-OSServer -Version '11.0.0.1' -ErrorVariable err -ErrorAction SilentlyContinue
259+
$null = Install-OSServer -Version '11.0.0.1' -ErrorVariable err -ErrorAction SilentlyContinue
256260

257261
It 'Should run the installation using the normal installer' { Assert-MockCalled @assRunParams }
258262
}

0 commit comments

Comments
 (0)