Skip to content

Commit 4976649

Browse files
committed
[Test] Mock cookbook virtualenv for Docker tests on AL 2023.
This is required to execute system tests on Docker for AL 2023 that depend on the cookbook virtualenv, siuch as the CloudWatch Agent tests.
1 parent 48044c2 commit 4976649

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

cookbooks/aws-parallelcluster-tests/recipes/docker_mock.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,28 @@
7474
end
7575
end
7676

77+
if alinux2023_on_docker?
78+
# Mock python environment for AL2023 Docker tests
79+
# The pyenv/virtualenv setup doesn't work in Docker because it requires S3 access
80+
# Create a symlink to system python at the expected cookbook_virtualenv_path
81+
python_version = node['cluster']['python-version']
82+
virtualenv_path = "#{node['cluster']['system_pyenv_root']}/versions/#{python_version}/envs/cookbook_virtualenv"
83+
84+
directory "#{virtualenv_path}/bin" do
85+
recursive true
86+
end
87+
88+
# Use system python3 as the mock python
89+
link "#{virtualenv_path}/bin/python" do
90+
to '/usr/bin/python3'
91+
end
92+
93+
bash 'Install cookbook requirements for AL2023' do
94+
cwd Chef::Config[:file_cache_path]
95+
code "/usr/bin/python3 -m pip install -r cookbooks/aws-parallelcluster-platform/files/cookbook_virtualenv/requirements.txt"
96+
end
97+
end
98+
7799
file '/usr/bin/ssh-keyscan' do
78100
content %(
79101
#!/bin/bash

0 commit comments

Comments
 (0)