Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/k8s-extension/HISTORY_private.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
Release History
===============

0.4.0-beta.1
++++++++++++++++++

* Release customization for microsoft.openservicemesh

0.3.1-beta.1
++++++++++++++++++

Expand Down
2 changes: 1 addition & 1 deletion src/k8s-extension/setup_private.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# TODO: Add any additional SDK dependencies here
DEPENDENCIES = []

VERSION = "0.3.1-beta.1"
VERSION = "0.4.0-beta.1"

with open('README.rst', 'r', encoding='utf-8') as f:
README = f.read()
Expand Down
243 changes: 124 additions & 119 deletions testing/Test.ps1
Original file line number Diff line number Diff line change
@@ -1,119 +1,124 @@
param (
[string] $Path,
[switch] $SkipInstall,
[switch] $CI,
[switch] $OnlyPublicTests,

[Parameter(Mandatory=$True)]
[ValidateSet('k8s-extension','k8s-configuration', 'k8s-extension-private')]
[string]$Type
)

# Disable confirm prompt for script
# Only show errors, don't show warnings
az config set core.disable_confirm_prompt=true
az config set core.only_show_errors=true

$ENVCONFIG = Get-Content -Path $PSScriptRoot/settings.json | ConvertFrom-Json

az account set --subscription $ENVCONFIG.subscriptionId

$Env:KUBECONFIG="$PSScriptRoot/tmp/KUBECONFIG"
$TestFileDirectory="$PSScriptRoot/results"

if (-not (Test-Path -Path $TestFileDirectory)) {
New-Item -ItemType Directory -Path $TestFileDirectory
}

if ($Type -eq 'k8s-extension') {
$k8sExtensionVersion = $ENVCONFIG.extensionVersion.'k8s-extension'
$Env:K8sExtensionName = "k8s-extension"

if (!$SkipInstall) {
Write-Host "Removing the old k8s-extension extension..."
az extension remove -n k8s-extension
Write-Host "Installing k8s-extension version $k8sExtensionVersion..."
az extension add --source ./bin/k8s_extension-$k8sExtensionVersion-py3-none-any.whl
if (!$?) {
Write-Host "Unable to find k8s-extension version $k8sExtensionVersion, exiting..."
exit 1
}
}
if ($OnlyPublicTests) {
$testFilePath = "$PSScriptRoot/test/extensions/public"
} else {
$testFilePath = "$PSScriptRoot/test/extensions"
}
} elseif ($Type -eq 'k8s-extension-private') {
$k8sExtensionPrivateVersion = $ENVCONFIG.extensionVersion.'k8s-extension-private'
$Env:K8sExtensionName = "k8s-extension-private"

if (!$SkipInstall) {
Write-Host "Removing the old k8s-extension-private extension..."
az extension remove -n k8s-extension-private
Write-Host "Installing k8s-extension-private version $k8sExtensionPrivateVersion..."
az extension add --source ./bin/k8s_extension_private-$k8sExtensionPrivateVersion-py3-none-any.whl
if (!$?) {
Write-Host "Unable to find k8s-extension-private version $k8sExtensionPrivateVersion, exiting..."
exit 1
}
}
if ($OnlyPublicTests) {
$testFilePath = "$PSScriptRoot/test/extensions/public"
} else {
$testFilePath = "$PSScriptRoot/test/extensions"
}
} elseif ($Type -eq 'k8s-configuration') {
$k8sConfigurationVersion = $ENVCONFIG.extensionVersion.'k8s-configuration'
if (!$SkipInstall) {
Write-Host "Removing the old k8s-configuration extension..."
az extension remove -n k8s-configuration
Write-Host "Installing k8s-configuration version $k8sConfigurationVersion..."
az extension add --source ./bin/k8s_configuration-$k8sConfigurationVersion-py3-none-any.whl
}
$testFilePath = "$PSScriptRoot/test/configurations"
}

if ($CI) {
# This runs the tests in parallel during the CI pipline to speed up testing

Write-Host "Invoking Pester to run tests from '$testFilePath'..."
$testFiles = Get-ChildItem $testFilePath
$resultFileNumber = 0
foreach ($testFile in $testFiles)
{
$resultFileNumber++
$testName = Split-Path $testFile –leaf
Start-Job -ArgumentList $testName, $testFile, $resultFileNumber, $TestFileDirectory -Name $testName -ScriptBlock {
param($name, $testFile, $resultFileNumber, $testFileDirectory)

Write-Host "$testFile to result file #$resultFileNumber"
$testResult = Invoke-Pester $testFile -Passthru -Output Detailed
$testResult | Export-JUnitReport -Path "$testFileDirectory/$name.xml"
}
}

do {
Write-Host ">> Still running tests @ $(Get-Date –Format "HH:mm:ss")" –ForegroundColor Blue
Get-Job | Where-Object { $_.State -eq "Running" } | Format-Table –AutoSize
Start-Sleep –Seconds 30
} while((Get-Job | Where-Object { $_.State -eq "Running" } | Measure-Object).Count -ge 1)

Get-Job | Wait-Job
$failedJobs = Get-Job | Where-Object { -not ($_.State -eq "Completed")}
Get-Job | Receive-Job –AutoRemoveJob –Wait –ErrorAction 'Continue'

if ($failedJobs.Count -gt 0) {
Write-Host "Failed Jobs" –ForegroundColor Red
$failedJobs
throw "One or more tests failed"
}
} else {
if ($Path) {
Write-Host "Invoking Pester to run tests from '$PSScriptRoot/$Path'"
Invoke-Pester -Output Detailed $PSScriptRoot/$Path
} else {
Write-Host "Invoking Pester to run tests from '$testFilePath'..."
Invoke-Pester -Output Detailed $testFilePath
}
}
param (
[string] $Path,
[switch] $SkipInstall,
[switch] $CI,
[switch] $OnlyPublicTests,

[Parameter(Mandatory=$True)]
[ValidateSet('k8s-extension','k8s-configuration', 'k8s-extension-private')]
[string]$Type
)

# Disable confirm prompt for script
# Only show errors, don't show warnings
az config set core.disable_confirm_prompt=true
az config set core.only_show_errors=true

$ENVCONFIG = Get-Content -Path $PSScriptRoot/settings.json | ConvertFrom-Json

az account set --subscription $ENVCONFIG.subscriptionId

$Env:KUBECONFIG="$PSScriptRoot/tmp/KUBECONFIG"
$TestFileDirectory="$PSScriptRoot/results"

if (-not (Test-Path -Path $TestFileDirectory)) {
New-Item -ItemType Directory -Path $TestFileDirectory
}

if ($Type -eq 'k8s-extension') {
$k8sExtensionVersion = $ENVCONFIG.extensionVersion.'k8s-extension'
$Env:K8sExtensionName = "k8s-extension"

if (!$SkipInstall) {
Write-Host "Removing the old k8s-extension extension..."
az extension remove -n k8s-extension
Write-Host "Installing k8s-extension version $k8sExtensionVersion..."
az extension add --source ./bin/k8s_extension-$k8sExtensionVersion-py3-none-any.whl
if (!$?) {
Write-Host "Unable to find k8s-extension version $k8sExtensionVersion, exiting..."
exit 1
}
}
if ($OnlyPublicTests) {
$testFilePaths = "$PSScriptRoot/test/extensions/public"
} else {
$testFilePaths = "$PSScriptRoot/test/extensions/public", "$PSScriptRoot/test/extensions/private-preview"
}
} elseif ($Type -eq 'k8s-extension-private') {
$k8sExtensionPrivateVersion = $ENVCONFIG.extensionVersion.'k8s-extension-private'
$Env:K8sExtensionName = "k8s-extension-private"

if (!$SkipInstall) {
Write-Host "Removing the old k8s-extension-private extension..."
az extension remove -n k8s-extension-private
Write-Host "Installing k8s-extension-private version $k8sExtensionPrivateVersion..."
az extension add --source ./bin/k8s_extension_private-$k8sExtensionPrivateVersion-py3-none-any.whl
if (!$?) {
Write-Host "Unable to find k8s-extension-private version $k8sExtensionPrivateVersion, exiting..."
exit 1
}
}
if ($OnlyPublicTests) {
$testFilePath = "$PSScriptRoot/test/extensions/public"
} else {
$testFilePath = "$PSScriptRoot/test/extensions"
}
} elseif ($Type -eq 'k8s-configuration') {
$k8sConfigurationVersion = $ENVCONFIG.extensionVersion.'k8s-configuration'
if (!$SkipInstall) {
Write-Host "Removing the old k8s-configuration extension..."
az extension remove -n k8s-configuration
Write-Host "Installing k8s-configuration version $k8sConfigurationVersion..."
az extension add --source ./bin/k8s_configuration-$k8sConfigurationVersion-py3-none-any.whl
}
$testFilePaths = "$PSScriptRoot/test/configurations"
}

if ($CI) {
# This runs the tests in parallel during the CI pipline to speed up testing

Write-Host "Invoking Pester to run tests from '$testFilePath'..."
$testFiles = @()
foreach ($paths in $testFilePaths)
{
$temp = Get-ChildItem $paths
$testFiles += $temp
}
$resultFileNumber = 0
foreach ($testFile in $testFiles)
{
$resultFileNumber++
$testName = Split-Path $testFile –leaf
Start-Job -ArgumentList $testName, $testFile, $resultFileNumber, $TestFileDirectory -Name $testName -ScriptBlock {
param($name, $testFile, $resultFileNumber, $testFileDirectory)

Write-Host "$testFile to result file #$resultFileNumber"
$testResult = Invoke-Pester $testFile -Passthru -Output Detailed
$testResult | Export-JUnitReport -Path "$testFileDirectory/$name.xml"
}
}

do {
Write-Host ">> Still running tests @ $(Get-Date –Format "HH:mm:ss")" –ForegroundColor Blue
Get-Job | Where-Object { $_.State -eq "Running" } | Format-Table –AutoSize
Start-Sleep –Seconds 30
} while((Get-Job | Where-Object { $_.State -eq "Running" } | Measure-Object).Count -ge 1)

Get-Job | Wait-Job
$failedJobs = Get-Job | Where-Object { -not ($_.State -eq "Completed")}
Get-Job | Receive-Job –AutoRemoveJob –Wait –ErrorAction 'Continue'

if ($failedJobs.Count -gt 0) {
Write-Host "Failed Jobs" –ForegroundColor Red
$failedJobs
throw "One or more tests failed"
}
} else {
if ($Path) {
Write-Host "Invoking Pester to run tests from '$PSScriptRoot/$Path'"
Invoke-Pester -Output Detailed $PSScriptRoot/$Path
} else {
Write-Host "Invoking Pester to run tests from '$testFilePath'..."
Invoke-Pester -Output Detailed $testFilePath
}
}