Skip to content
This repository has been archived by the owner on Jun 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #85 from PowerShell/AutomationTest
Browse files Browse the repository at this point in the history
Update Pester test for PSRP to make pass on all platforms
  • Loading branch information
JumpingYang001 authored Mar 4, 2017
2 parents a3e871c + f791ca3 commit 8f9fe6f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 34 deletions.
17 changes: 10 additions & 7 deletions test/build.psm1
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#Basic variables initial
$DownloadFolder = "https://github.com/PowerShell/PowerShell/releases/download/"
$ReleaseTag = "v6.0.0-alpha.14"
$Endfix = $ReleaseTag.Substring($ReleaseTag.LastIndexOf(".")+1,$ReleaseTag.Length - $ReleaseTag.LastIndexOf(".")-1)
$MSIversion = $ReleaseTag.Substring(1,$ReleaseTag.Length -1 ).Replace("-",".$Endfix-")
$ReleaseTag = "v6.0.0-alpha.16"
#$Endfix = $ReleaseTag.Substring($ReleaseTag.LastIndexOf(".")+1,$ReleaseTag.Length - $ReleaseTag.LastIndexOf(".")-1)
$MSIversion = $ReleaseTag.Substring(1,$ReleaseTag.Length -1 ).Replace("-","-")
$version = $MSIversion.Substring(0,$MSIversion.IndexOf("-"))
$ReleaseFolder = $DownloadFolder + $ReleaseTag
$powershell = "C:\Program Files\PowerShell\$version\powershell.exe"
Expand All @@ -13,7 +13,9 @@ function Start-PSRPInstall {
[ValidateSet("win7-x64",
"win7-x86",
"win81-x64",
"win10-x64")]
"win10-x64",
"WS2012R2-x64",
"WS2016-x64")]
[Parameter(ParameterSetName='CoreCLR')]
[string]$Runtime
)
Expand All @@ -31,12 +33,12 @@ function Start-PSRPInstall {
}
elseif($Runtime -eq "win81-x64" -or ($Runtime -eq "WS2012R2-x64"))
{
$msiFile = "PowerShell_$MSIversion-win81-x64.msi"
$msiFile = "PowerShell_$MSIversion-win81-win2012r2-x64.msi"
$msiURLFile = $ReleaseFolder+"/"+$msiFile
}
elseif($Runtime -eq "win10-x64" -or ($Runtime -eq "WS2016-x64"))
{
$msiFile = "PowerShell_$MSIversion-win10-x64.msi"
$msiFile = "PowerShell_$MSIversion-win10-win2016-x64.msi"
$msiURLFile = $ReleaseFolder+"/"+$msiFile
}
else
Expand All @@ -63,7 +65,8 @@ function Start-PSRPInstall {
"win7-x86",
"win81-x64",
"win10-x64",
"osx.10.11-x64")]
"WS2012R2-x64",
"WS2016-x64")]
[Parameter(ParameterSetName='CoreCLR')]
[string]$Runtime
)
Expand Down
46 changes: 23 additions & 23 deletions test/installPSRP.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ trap '
' INT

if [ $# -ne 3 ]; then
echo -e "Need redmondpassword with omiversion and psrpversion\nUsage:installPSRP.sh redmondpassword \"1.1.0-63\" \"6\""
echo -e "Need redmondpassword with omiversion and psrpversion\nUsage:installPSRP.sh redmondpassword \"1.2.0-35\" \"18\""
exit 2
fi

Expand All @@ -19,8 +19,8 @@ redmondpassword=$1
isMacOS=false
omiversion=$2
psrpversion=$3
powershellDir="/opt/microsoft/powershell/6.0.0-alpha.14"
powershellDirForMac="/usr/local/microsoft/powershell/6.0.0-alpha.14"
powershellDir="/opt/microsoft/powershell/6.0.0-alpha.16"
powershellDirForMac="/usr/local/microsoft/powershell/6.0.0-alpha.16"
realdataDir="//osfiler/ostcdata$"
get_omifolder() {
echo "/download/OSTCData/Builds/omi/develop/$1/$2/$3"
Expand Down Expand Up @@ -72,7 +72,7 @@ case "$OSTYPE" in
platfrom=Linux_ULINUX_1.0_x64_64_Release
;;
*)
echo "Ubuntu $VERSION_ID is not supported!" >&2
echo "Ubuntu $VERSION_ID is not supported!"
exit 2
esac

Expand All @@ -83,7 +83,7 @@ case "$OSTYPE" in
esac
;;
*)
echo "$NAME is not supported!" >&2
echo "$NAME is not supported!"
exit 2
esac
;;
Expand All @@ -95,7 +95,7 @@ case "$OSTYPE" in
powershellDir=$powershellDirForMac
;;
*)
echo "$OSTYPE is not supported!" >&2
echo "$OSTYPE is not supported!"
exit 2
;;
esac
Expand All @@ -117,15 +117,17 @@ if [ "$isMacOS" = "true" ]; then
# Mac OS don't have mount_cifs, so use mount_smbfs
omifolder=$(get_omifolder "$omiversion" "$platfrom" "$opensslversion")
echo "mounting from $realdataDir folder to omi folder: $omifolder"
sudo mount -t smbfs '//redmond.corp.microsoft.com;scxsvc:'"$redmondpassword"'@osfiler/ostcdata$' /download
#sudo mount -t smbfs '//redmond.corp.microsoft.com;scxsvc:'"$redmondpassword"'@osfiler/ostcdata$' /download
sudo mount osfiler.scx.com:/OSTCData /download
sudo cp -f $omifolder"omicli" /opt/omi/bin
sudo cp -f $omifolder"libmi.dylib" /opt/omi/lib
#sudo cp -f $omifolder"libmi.dylib" $powershellDir
sudo cp -f $omifolder"libmi.dylib" $powershellDir
sudo umount /download

psrpfolder=$(get_psrpfolder "$psrpversion" "$platfrom")
echo "mounting from $realdataDir folder to psrp folder: $psrpfolder"
sudo mount -t smbfs '//redmond.corp.microsoft.com;scxsvc:'"$redmondpassword"'@osfiler/ostcdata$' /download
#sudo mount -t smbfs '//redmond.corp.microsoft.com;scxsvc:'"$redmondpassword"'@osfiler/ostcdata$' /download
sudo mount osfiler.scx.com:/OSTCData /download
echo "Copying psrpclient ..."
sudo cp -f $psrpfolder/libpsrpclient.dylib $powershellDir
sudo umount /download
Expand Down Expand Up @@ -154,47 +156,45 @@ case "$OSTYPE" in
# yum automatically resolves dependencies for local packages
omipackage=omi-$omiversion.ulinux.x64.rpm
if [[ ! -r "$omipackage" ]]; then
echo "ERROR: $omipackage failed to download! Aborting..." >&2
echo "ERROR: $omipackage failed to download! Aborting..."
exit 1
fi
sudo rpm -i "./$omipackage"
echo "Done installing omi ..."

psrppackage=psrp-1.0.0-0.universal.x64.rpm
psrppackage=psrp-1.0.0-$psrpversion.universal.x64.rpm
if [[ ! -r "$psrppackage" ]]; then
echo "ERROR: $psrppackage failed to download! Aborting..." >&2
echo "ERROR: $psrppackage failed to download! Aborting..."
exit 1
fi
sudo rpm -i "./$psrppackage"
echo "Done installing psrp ..."

#echo "Copying omicli and psrpclient ..."
#libmi.so and libpsrpclient.so are integrated into powershell package, so needn't to copy them from build share folder
#sudo cp -u libmi.so $powershellDir
#sudo cp -u libpsrpclient.so $powershellDir
sudo cp -u libmi.so $powershellDir
sudo cp -u libpsrpclient.so $powershellDir
;;
ubuntu)
# dpkg does not automatically resolve dependencies, but spouts ugly errors
omipackage=omi-$omiversion.ulinux.x64.deb
if [[ ! -r "$omipackage" ]]; then
echo "ERROR: $omipackage failed to download! Aborting..." >&2
echo "ERROR: $omipackage failed to download! Aborting..."
exit 1
fi
sudo dpkg -i "./$omipackage"
echo "Done installing omi ..."

psrppackage=psrp-1.0.0-0.universal.x64.deb
psrppackage=psrp-1.0.0-$psrpversion.universal.x64.deb
if [[ ! -r "$psrppackage" ]]; then
echo "ERROR: $psrppackage failed to download! Aborting..." >&2
echo "ERROR: $psrppackage failed to download! Aborting..."
exit 1
fi
sudo dpkg -i "./$psrppackage" &> /dev/null
sudo dpkg -i "./$psrppackage"
echo "Done installing psrp ..."

#echo "Copying omicli and psrpclient ..."
#libmi.so and libpsrpclient.so are integrated into powershell package, so needn't to copy them from build share folder
#sudo cp -u libmi.so $powershellDir
#sudo cp -u libpsrpclient.so $powershellDir
sudo cp -u libmi.so $powershellDir
sudo cp -u libpsrpclient.so $powershellDir
# Resolve dependencies
sudo apt-get install -f -y
;;
Expand All @@ -208,7 +208,7 @@ esac
success=$?

if [[ "$success" != 0 ]]; then
echo "OMI and PSRP install failed." >&2
echo "OMI and PSRP install failed."
exit "$success"
else
echo "Congratulations! OMI and PSRP are installed."
Expand Down
8 changes: 4 additions & 4 deletions test/installpowershell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ trap '
kill -s INT "$$"
' INT

releaseversion="6.0.0-alpha.14"
centosreleaseversion="6.0.0_alpha.14"
releaseversion="6.0.0-alpha.16"
centosreleaseversion="6.0.0_alpha.16"
get_url() {
release=v6.0.0-alpha.14
release=v6.0.0-alpha.16
echo "https://github.com/PowerShell/PowerShell/releases/download/$release/$1"
}

Expand Down Expand Up @@ -84,7 +84,7 @@ case "$OSTYPE" in
# dpkg does not automatically resolve dependencies, but spouts ugly errors
sudo dpkg -i "./$package" &> /dev/null
# Resolve dependencies
sudo apt-get install -f
sudo apt-get install -fy
;;
*)
esac
Expand Down

0 comments on commit 8f9fe6f

Please sign in to comment.