Skip to content

Commit e2242c4

Browse files
Merge pull request #10319 from habitat-sh/dg/e2e-tests-macos
Add e2e tests for macOS(aarch64-darwin)
2 parents d2029ec + 20bebfc commit e2242c4

20 files changed

Lines changed: 623 additions & 43 deletions

File tree

.expeditor/end_to_end.pipeline.yml

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,6 +1164,190 @@ steps:
11641164
- BUILDKITE_AGENT_ACCESS_TOKEN
11651165
- HAB_AUTH_TOKEN
11661166

1167+
#######################################################################
1168+
# macOS (aarch64-darwin) E2E Tests
1169+
#######################################################################
1170+
1171+
- label: "[:mac: test_studio_auto_installs]"
1172+
command:
1173+
- bash .expeditor/scripts/end_to_end/run_e2e_test_darwin.sh dev test_studio_auto_installs
1174+
artifact_paths:
1175+
- "*.log"
1176+
agents:
1177+
queue: 'default-macos-arm64-privileged'
1178+
plugins:
1179+
- chef/anka#v0.7.2:
1180+
vm-name: buildkite-core-14-arm64
1181+
always-pull: true
1182+
wait-network: true
1183+
inherit-environment-vars: true
1184+
env:
1185+
BUILD_PKG_TARGET: aarch64-darwin
1186+
HOMEBREW_NO_AUTO_UPDATE: 1
1187+
HOMEBREW_NO_INSTALL_CLEANUP: 1
1188+
1189+
- label: "[:mac: test_studio_version]"
1190+
command:
1191+
- bash .expeditor/scripts/end_to_end/run_e2e_test_darwin.sh dev test_studio_version
1192+
artifact_paths:
1193+
- "*.log"
1194+
agents:
1195+
queue: 'default-macos-arm64-privileged'
1196+
plugins:
1197+
- chef/anka#v0.7.2:
1198+
vm-name: buildkite-core-14-arm64
1199+
always-pull: true
1200+
wait-network: true
1201+
inherit-environment-vars: true
1202+
env:
1203+
BUILD_PKG_TARGET: aarch64-darwin
1204+
HOMEBREW_NO_AUTO_UPDATE: 1
1205+
HOMEBREW_NO_INSTALL_CLEANUP: 1
1206+
1207+
- label: "[:mac: test_studio_can_build_packages]"
1208+
command:
1209+
- bash .expeditor/scripts/end_to_end/run_e2e_test_darwin.sh dev test_studio_can_build_packages
1210+
artifact_paths:
1211+
- "*.log"
1212+
agents:
1213+
queue: 'default-macos-arm64-privileged'
1214+
plugins:
1215+
- chef/anka#v0.7.2:
1216+
vm-name: buildkite-core-14-arm64
1217+
always-pull: true
1218+
wait-network: true
1219+
inherit-environment-vars: true
1220+
env:
1221+
BUILD_PKG_TARGET: aarch64-darwin
1222+
HOMEBREW_NO_AUTO_UPDATE: 1
1223+
HOMEBREW_NO_INSTALL_CLEANUP: 1
1224+
1225+
- label: "[:mac: test_pkg_download]"
1226+
command:
1227+
- bash .expeditor/scripts/end_to_end/run_e2e_test_darwin.sh dev test_pkg_download
1228+
artifact_paths:
1229+
- "*.log"
1230+
agents:
1231+
queue: 'default-macos-arm64-privileged'
1232+
plugins:
1233+
- chef/anka#v0.7.2:
1234+
vm-name: buildkite-core-14-arm64
1235+
always-pull: true
1236+
wait-network: true
1237+
inherit-environment-vars: true
1238+
env:
1239+
BUILD_PKG_TARGET: aarch64-darwin
1240+
HOMEBREW_NO_AUTO_UPDATE: 1
1241+
HOMEBREW_NO_INSTALL_CLEANUP: 1
1242+
1243+
- label: "[:mac: test_fresh_install_can_communicate_with_builder]"
1244+
command:
1245+
- bash .expeditor/scripts/end_to_end/run_e2e_test_darwin.sh dev test_fresh_install_can_communicate_with_builder
1246+
artifact_paths:
1247+
- "*.log"
1248+
agents:
1249+
queue: 'default-macos-arm64-privileged'
1250+
plugins:
1251+
- chef/anka#v0.7.2:
1252+
vm-name: buildkite-core-14-arm64
1253+
always-pull: true
1254+
wait-network: true
1255+
inherit-environment-vars: true
1256+
env:
1257+
BUILD_PKG_TARGET: aarch64-darwin
1258+
HOMEBREW_NO_AUTO_UPDATE: 1
1259+
HOMEBREW_NO_INSTALL_CLEANUP: 1
1260+
1261+
- label: "[:mac: test_self_signed_cert_is_loaded_by_hab]"
1262+
command:
1263+
- bash .expeditor/scripts/end_to_end/run_e2e_test_darwin.sh dev test_self_signed_cert_is_loaded_by_hab
1264+
artifact_paths:
1265+
- "*.log"
1266+
agents:
1267+
queue: 'default-macos-arm64-privileged'
1268+
plugins:
1269+
- chef/anka#v0.7.2:
1270+
vm-name: buildkite-core-14-arm64
1271+
always-pull: true
1272+
wait-network: true
1273+
inherit-environment-vars: true
1274+
env:
1275+
BUILD_PKG_TARGET: aarch64-darwin
1276+
HOMEBREW_NO_AUTO_UPDATE: 1
1277+
HOMEBREW_NO_INSTALL_CLEANUP: 1
1278+
1279+
- label: "[:mac: test_hab_plan_cli]"
1280+
command:
1281+
- bash .expeditor/scripts/end_to_end/run_e2e_test_darwin.sh dev test_hab_plan_cli
1282+
artifact_paths:
1283+
- "*.log"
1284+
agents:
1285+
queue: 'default-macos-arm64-privileged'
1286+
plugins:
1287+
- chef/anka#v0.7.2:
1288+
vm-name: buildkite-core-14-arm64
1289+
always-pull: true
1290+
wait-network: true
1291+
inherit-environment-vars: true
1292+
env:
1293+
BUILD_PKG_TARGET: aarch64-darwin
1294+
HOMEBREW_NO_AUTO_UPDATE: 1
1295+
HOMEBREW_NO_INSTALL_CLEANUP: 1
1296+
1297+
- label: "[:mac: test_pkg_uninstall_darwin]"
1298+
command:
1299+
- bash .expeditor/scripts/end_to_end/run_e2e_test_darwin.sh dev test_pkg_uninstall_darwin
1300+
artifact_paths:
1301+
- "*.log"
1302+
agents:
1303+
queue: 'default-macos-arm64-privileged'
1304+
plugins:
1305+
- chef/anka#v0.7.2:
1306+
vm-name: buildkite-core-14-arm64
1307+
always-pull: true
1308+
wait-network: true
1309+
inherit-environment-vars: true
1310+
env:
1311+
BUILD_PKG_TARGET: aarch64-darwin
1312+
HOMEBREW_NO_AUTO_UPDATE: 1
1313+
HOMEBREW_NO_INSTALL_CLEANUP: 1
1314+
1315+
- label: "[:mac: test_simple_hooks_darwin]"
1316+
command:
1317+
- bash .expeditor/scripts/end_to_end/run_e2e_test_darwin.sh dev test_simple_hooks_darwin
1318+
artifact_paths:
1319+
- "*.log"
1320+
agents:
1321+
queue: 'default-macos-arm64-privileged'
1322+
plugins:
1323+
- chef/anka#v0.7.2:
1324+
vm-name: buildkite-core-14-arm64
1325+
always-pull: true
1326+
wait-network: true
1327+
inherit-environment-vars: true
1328+
env:
1329+
BUILD_PKG_TARGET: aarch64-darwin
1330+
HOMEBREW_NO_AUTO_UPDATE: 1
1331+
HOMEBREW_NO_INSTALL_CLEANUP: 1
1332+
1333+
- label: "[:mac: test_external_binaries_darwin]"
1334+
command:
1335+
- bash .expeditor/scripts/end_to_end/run_e2e_test_darwin.sh dev test_external_binaries_darwin
1336+
artifact_paths:
1337+
- "*.log"
1338+
agents:
1339+
queue: 'default-macos-arm64-privileged'
1340+
plugins:
1341+
- chef/anka#v0.7.2:
1342+
vm-name: buildkite-core-14-arm64
1343+
always-pull: true
1344+
wait-network: true
1345+
inherit-environment-vars: true
1346+
env:
1347+
BUILD_PKG_TARGET: aarch64-darwin
1348+
HOMEBREW_NO_AUTO_UPDATE: 1
1349+
HOMEBREW_NO_INSTALL_CLEANUP: 1
1350+
11671351
- wait
11681352

11691353
- label: "[:habicat: Promote to Acceptance]"

.expeditor/scripts/end_to_end/run_e2e_test_core.ps1

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ param (
99
$ErrorActionPreference = "stop"
1010

1111
if (!$IsCoreCLR) {
12-
Write-Error "End-to-end tests are only compatiable with Powershell Core"
12+
Write-Error "End-to-end tests are only compatible with PowerShell Core"
1313
}
1414

1515
###################################################################################################
@@ -42,7 +42,7 @@ function Wait-PathUpdatedAfter($Path, $Time, $Timeout) {
4242
$testScript = {
4343
(Test-Path -Path $Path) -And ((Get-Item -Path $Path).LastWriteTime -gt $Time)
4444
}
45-
$timeoutScript = { Write-Error "Timed out waiting $Timeout seconds for '$Path' to be updated after '$($Time.ToString("yyyy-MM-ddTHH:MM:ssZ"))'" }
45+
$timeoutScript = { Write-Error "Timed out waiting $Timeout seconds for '$Path' to be updated after '$($Time.ToString("yyyy-MM-ddTHH:mm:ssZ"))'"}
4646
Wait-True -TestScript $testScript -TimeoutScript $timeoutScript -Timeout $Timeout
4747
}
4848

@@ -65,7 +65,7 @@ function Wait-PathHasContent($Path, $Time, $Timeout) {
6565
$testScript = {
6666
(Test-Path -Path $Path) -And ((Get-Content -Path $Path).Length -gt 0)
6767
}
68-
$timeoutScript = { Write-Error "Timed out waiting $Timeout seconds for '$Path' to have content after '$($Time.ToString("yyyy-MM-ddTHH:MM:ssZ"))'" }
68+
$timeoutScript = { Write-Error "Timed out waiting $Timeout seconds for '$Path' to have content after '$($Time.ToString("yyyy-MM-ddTHH:mm:ssZ"))'"}
6969
Wait-True -TestScript $testScript -TimeoutScript $timeoutScript -Timeout $Timeout
7070
}
7171

@@ -134,7 +134,7 @@ function Wait-SupervisorService($ServiceName, $Timeout = ($DefaultServiceTimeout
134134
}
135135
$status = (Invoke-WebRequest "$url" | ConvertFrom-Json).process.state
136136
$status -eq "up"
137-
} catch { $false } # We ignore 404s and other unsuccesful codes
137+
} catch { $false } # We ignore 404s and other unsuccessful codes
138138
}
139139
$timeoutScript = { Write-Error "Timed out waiting $Timeout seconds for Supervisor to start $ServiceName" }
140140
Wait-True -TestScript $testScript -TimeoutScript $timeoutScript -Timeout $Timeout
@@ -210,8 +210,9 @@ function New-TemporaryDirectory {
210210
}
211211

212212
function Restart-Supervisor {
213-
if ($IsLinux) {
214-
pkill --signal=HUP hab-launch
213+
if ($IsLinux -Or $IsMacOS) {
214+
# macOS pkill does not support GNU --signal= syntax
215+
pkill -HUP hab-launch
215216
Start-Sleep 3 # wait for the signal to be processed
216217
} else {
217218
Stop-Process | Get-Process hab-sup
@@ -247,7 +248,7 @@ function Wait-Release($Ident, $Remote, $Timeout = ($DefaultServiceTimeout)) {
247248
$currentIdent = (Invoke-WebRequest "http://${Remote}:9631/services/$serviceName/default" | ConvertFrom-Json).pkg.ident
248249
$currentIdent -eq $Ident
249250
}
250-
$timeoutScript = { Write-Error "Timed out waiting $Timeout seconds for $Remote to Update to $Release" }
251+
$timeoutScript = { Write-Error "Timed out waiting $Timeout seconds for $Remote to update to $Ident" }
251252
Wait-True -TestScript $testScript -TimeoutScript $timeoutScript -Timeout $Timeout
252253
}
253254

@@ -268,12 +269,16 @@ function Get-Leader($Remote, $ServiceGroup) {
268269
}
269270

270271
function Invoke-Build($PackageName, $RefreshChannel) {
271-
$commandArgs = @("--reuse")
272+
$commandArgs = @()
273+
if (!$IsMacOS) {
274+
# --reuse is not compiled for macOS
275+
$commandArgs += @("--reuse")
276+
}
272277
if($RefreshChannel) {
273278
$commandArgs += @("--refresh-channel", $RefreshChannel)
274279
}
275280
hab pkg build test/fixtures/$PackageName $commandArgs
276-
if ($IsLinux) {
281+
if ($IsLinux -Or $IsMacOS) {
277282
# This changes the format of last_build from `var=value` to `$var='value'`
278283
# so that powershell can parse and source the script
279284
Set-Content -Path "results/last_build.ps1" -Value ""
@@ -284,8 +289,15 @@ function Invoke-Build($PackageName, $RefreshChannel) {
284289
Function Invoke-BuildAndInstall($PackageName, $RefreshChannel) {
285290
Invoke-Build @PSBoundParameters
286291
. ./results/last_build.ps1
287-
hab pkg install ./results/$pkg_artifact
288-
hab studio run "rm /hab/pkgs/$pkg_ident/hooks"
292+
if ($IsMacOS) {
293+
# Use --ignore-install-hook because the install hook interpreter
294+
# (core/busybox-static) is not available for aarch64-darwin.
295+
hab pkg install --ignore-install-hook ./results/$pkg_artifact
296+
# On macOS native studio there is no chroot, so no hook cleanup is needed.
297+
} else {
298+
hab pkg install ./results/$pkg_artifact
299+
hab studio run "rm /hab/pkgs/$pkg_ident/hooks"
300+
}
289301
}
290302

291303
function Stop-ComposeSupervisor($Remote) {
@@ -316,7 +328,14 @@ function Get-HabServicePID($PackageName) {
316328

317329
###################################################################################################
318330

319-
Import-Module (Join-Path -Path $(hab pkg path core/pester) module Pester.psd1)
331+
# Import Pester: prefer the hab-installed package, fall back to system-installed module
332+
$pesterPkgPath = $null
333+
try { $pesterPkgPath = hab pkg path core/pester 2>$null } catch { $pesterPkgPath = $null }
334+
if ($pesterPkgPath -and (Test-Path $pesterPkgPath)) {
335+
Import-Module (Join-Path -Path $pesterPkgPath module Pester.psd1)
336+
} else {
337+
Import-Module Pester
338+
}
320339

321340
if(Test-Path $TestName) {
322341
$testPath = $TestName
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
# macOS (aarch64-darwin) entry point for end-to-end tests.
4+
# This is the Darwin-specific counterpart of run_e2e_test.sh.
5+
6+
set -euo pipefail
7+
8+
channel=${1:?You must specify a channel value}
9+
test_name=${2:-}
10+
11+
source .expeditor/scripts/end_to_end/setup_environment_darwin.sh "$channel"
12+
13+
pwsh_path="$(command -v pwsh)"
14+
15+
if [ -n "$test_name" ]; then
16+
sudo -E "$pwsh_path" .expeditor/scripts/end_to_end/run_e2e_test_core.ps1 "$test_name"
17+
else
18+
bash
19+
fi

0 commit comments

Comments
 (0)