Skip to content

Commit 30a4bfe

Browse files
authored
Add debian test-dep image (#211)
Add debian test-dep image - Also, add more tests to verify test dependencies are there - Also, add more tests to verify that base image utilities are there
1 parent 01550e6 commit 30a4bfe

8 files changed

Lines changed: 178 additions & 13 deletions

File tree

release/preview/debian9/meta.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
"tagTemplates": [
88
"#psversion#-debian-#tag#",
99
"preview-debian-#shorttag#"
10-
]
10+
],
11+
"SubImage": "test-deps"
1112
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Docker image file that describes an Debian 9image with PowerShell and test dependencies
2+
ARG BaseImage=mcr.microsoft.com/powershell:debian-9
3+
4+
FROM ${BaseImage}
5+
6+
# Install dependencies and clean up
7+
RUN apt-get update \
8+
&& apt-get install -y \
9+
sudo \
10+
&& apt-get clean \
11+
&& rm -rf /var/lib/apt/lists/*
12+
13+
# Define args needed only for the labels
14+
ARG VCS_REF="none"
15+
ARG IMAGE_NAME=mcr.microsoft.com/powershell/test-deps:debian-9
16+
ARG PS_VERSION=6.2.0
17+
18+
LABEL maintainer="PowerShell Team <powershellteam@hotmail.com>" \
19+
readme.md="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" \
20+
description="This Dockerfile will install the latest release of PowerShell and tools needed for runing CI/CD container jobs." \
21+
org.label-schema.usage="https://github.com/PowerShell/PowerShell/tree/master/docker#run-the-docker-image-you-built" \
22+
org.label-schema.url="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" \
23+
org.label-schema.vcs-url="https://github.com/PowerShell/PowerShell-Docker" \
24+
org.label-schema.name="powershell" \
25+
org.label-schema.vendor="PowerShell" \
26+
org.label-schema.version=${PS_VERSION} \
27+
org.label-schema.schema-version="1.0" \
28+
org.label-schema.vcs-ref=${VCS_REF} \
29+
org.label-schema.docker.cmd="docker run ${IMAGE_NAME} pwsh -c '$psversiontable'" \
30+
org.label-schema.docker.cmd.devel="docker run ${IMAGE_NAME}" \
31+
org.label-schema.docker.cmd.test="docker run ${IMAGE_NAME} pwsh -c Invoke-Pester" \
32+
org.label-schema.docker.cmd.help="docker run ${IMAGE_NAME} pwsh -c Get-Help"
33+
34+
# Use PowerShell as the default shell
35+
# Use array to avoid Docker prepending /bin/sh -c
36+
CMD [ "pwsh" ]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"IsLinux" : true,
3+
"UseLinuxVersion": false,
4+
"osVersion": "Debian 9",
5+
"tagTemplates": [
6+
"preview-debian-#shorttag#"
7+
],
8+
"SubRepository": "test-deps",
9+
"OptionalTests": [
10+
"test-deps",
11+
"test-deps-debian"
12+
]
13+
}

release/stable/debian9/meta.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
"tagTemplates": [
88
"#psversion#-debian-#tag#",
99
"debian-#shorttag#"
10-
]
10+
],
11+
"SubImage": "test-deps"
1112
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Docker image file that describes an Debian 9image with PowerShell and test dependencies
2+
ARG BaseImage=mcr.microsoft.com/powershell:debian-9
3+
4+
FROM ${BaseImage}
5+
6+
# Install dependencies and clean up
7+
RUN apt-get update \
8+
&& apt-get install -y \
9+
sudo \
10+
&& apt-get clean \
11+
&& rm -rf /var/lib/apt/lists/*
12+
13+
# Define args needed only for the labels
14+
ARG VCS_REF="none"
15+
ARG IMAGE_NAME=mcr.microsoft.com/powershell/test-deps:debian-9
16+
ARG PS_VERSION=6.2.0
17+
18+
LABEL maintainer="PowerShell Team <powershellteam@hotmail.com>" \
19+
readme.md="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" \
20+
description="This Dockerfile will install the latest release of PowerShell and tools needed for runing CI/CD container jobs." \
21+
org.label-schema.usage="https://github.com/PowerShell/PowerShell/tree/master/docker#run-the-docker-image-you-built" \
22+
org.label-schema.url="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" \
23+
org.label-schema.vcs-url="https://github.com/PowerShell/PowerShell-Docker" \
24+
org.label-schema.name="powershell" \
25+
org.label-schema.vendor="PowerShell" \
26+
org.label-schema.version=${PS_VERSION} \
27+
org.label-schema.schema-version="1.0" \
28+
org.label-schema.vcs-ref=${VCS_REF} \
29+
org.label-schema.docker.cmd="docker run ${IMAGE_NAME} pwsh -c '$psversiontable'" \
30+
org.label-schema.docker.cmd.devel="docker run ${IMAGE_NAME}" \
31+
org.label-schema.docker.cmd.test="docker run ${IMAGE_NAME} pwsh -c Invoke-Pester" \
32+
org.label-schema.docker.cmd.help="docker run ${IMAGE_NAME} pwsh -c Get-Help"
33+
34+
# Use PowerShell as the default shell
35+
# Use array to avoid Docker prepending /bin/sh -c
36+
CMD [ "pwsh" ]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"IsLinux" : true,
3+
"UseLinuxVersion": false,
4+
"osVersion": "Debian 9",
5+
"tagTemplates": [
6+
"debian-#shorttag#"
7+
],
8+
"SubRepository": "test-deps",
9+
"OptionalTests": [
10+
"test-deps",
11+
"test-deps-debian"
12+
]
13+
}

tests/container.tests.ps1

Lines changed: 75 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -303,21 +303,86 @@ Describe "Linux Containers" -Tags 'Behavior', 'Linux' {
303303
}
304304
}
305305

306+
Context "default executables" {
307+
BeforeAll{
308+
#apt-utils ca-certificates curl wget apt-transport-https locales gnupg2 inetutils-ping git sudo less procps
309+
$commands = @(
310+
'locale-gen'
311+
'update-ca-certificates'
312+
'openssl'
313+
'less'
314+
)
315+
316+
$testdepsTestCases = @()
317+
$script:linuxContainerRunTests | ForEach-Object {
318+
$name = $_.Name
319+
foreach($command in $commands)
320+
{
321+
$testdepsTestCases += @{
322+
Name = $name
323+
Command = $command
324+
}
325+
}
326+
}
327+
328+
}
329+
330+
it "<Name> should have <command>" -TestCases $testdepsTestCases -Skip:$script:skipLinuxRun {
331+
param(
332+
[Parameter(Mandatory=$true)]
333+
[string]
334+
$name,
335+
[Parameter(Mandatory=$true)]
336+
[string]
337+
$Command
338+
)
339+
340+
$source = Get-DockerCommandSource -Name $name -command $Command
341+
$source | Should -Not -BeNullOrEmpty
342+
}
343+
}
344+
306345
Context "test-deps" {
307346
BeforeAll{
347+
#apt-utils ca-certificates curl wget apt-transport-https locales gnupg2 inetutils-ping git sudo less procps
348+
$commands = @(
349+
'adduser'
350+
'curl'
351+
'ping'
352+
'ps'
353+
'su'
354+
'sudo'
355+
'tar'
356+
'wget'
357+
'hostname'
358+
'find'
359+
)
360+
361+
$debianCommands = @(
362+
'apt'
363+
'apt-get'
364+
)
365+
308366
$testdepsTestCases = @()
309367
$script:linuxContainerRunTests | Where-Object { $_.OptionalTests -contains 'test-deps' } | ForEach-Object {
310-
$testdepsTestCases += @{
311-
Name = $_.Name
312-
Command = 'su'
368+
$name = $_.Name
369+
foreach($command in $commands)
370+
{
371+
$testdepsTestCases += @{
372+
Name = $name
373+
Command = $command
374+
}
313375
}
314-
$testdepsTestCases += @{
315-
Name = $_.Name
316-
Command = 'sudo'
317-
}
318-
$testdepsTestCases += @{
319-
Name = $_.Name
320-
Command = 'adduser'
376+
}
377+
378+
$script:linuxContainerRunTests | Where-Object { $_.OptionalTests -contains 'test-deps-debian' } | ForEach-Object {
379+
$name = $_.Name
380+
foreach($command in $debianCommands)
381+
{
382+
$testdepsTestCases += @{
383+
Name = $name
384+
Command = $command
385+
}
321386
}
322387
}
323388

tests/containerTestCommon.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function Invoke-Docker
6868
$dockerExitCode = $LASTEXITCODE
6969
if($PassThru.IsPresent)
7070
{
71-
Write-Verbose "passing through Docker results of length: $($result.length)..." -Verbose
71+
Write-Verbose "passing through Docker results of length: $($result.length)..."
7272
return $result
7373
}
7474
elseif($dockerExitCode -ne 0 -and $FailureAction -eq 'error')

0 commit comments

Comments
 (0)