Skip to content

Commit bffcbb0

Browse files
authored
[kitchen] Add Ubuntu 22.04 tests (#12164)
Adds Ubuntu 22.04 x64 tests to kitchen. Modifies the test suites generation to automatically detect whether an rsa, ed25519, or the default key created by kitchen, should be used, depending on the target platforms. Renames some EC2 driver variables for consistency. Note: Ubuntu 22.04 arm64 tests can be added once test-kitchen/kitchen-ec2#583 is merged and released (to support ed25519 key creation).
1 parent 91b4245 commit bffcbb0

File tree

7 files changed

+42
-20
lines changed

7 files changed

+42
-20
lines changed

.gitlab/functional_test/security_agent.yml

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ kitchen_test_security_agent_x64:
4141
KITCHEN_OSVERS: "ubuntu-20-04,ubuntu-20-04-2"
4242
- KITCHEN_PLATFORM: "ubuntu"
4343
KITCHEN_OSVERS: "ubuntu-21-10,ubuntu-22-04"
44-
KITCHEN_SKIP_MANUAL_SSH_KEY: "true"
4544
- KITCHEN_PLATFORM: "suse"
4645
KITCHEN_OSVERS: "sles-12,sles-15"
4746
- KITCHEN_PLATFORM: "suse"

.gitlab/kitchen_testing/ubuntu.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020

2121
.kitchen_scenario_ubuntu_a6_x64:
2222
variables:
23-
KITCHEN_OSVERS: "ubuntu-14-04,ubuntu-16-04,ubuntu-18-04,ubuntu-20-04"
24-
DEFAULT_KITCHEN_OSVERS: "ubuntu-20-04"
23+
KITCHEN_OSVERS: "ubuntu-14-04,ubuntu-16-04,ubuntu-18-04,ubuntu-20-04,ubuntu-22-04"
24+
DEFAULT_KITCHEN_OSVERS: "ubuntu-22-04"
2525
extends:
2626
- .kitchen_agent_a6
2727
- .kitchen_os_ubuntu
@@ -30,8 +30,8 @@
3030

3131
.kitchen_scenario_ubuntu_a7_x64:
3232
variables:
33-
KITCHEN_OSVERS: "ubuntu-14-04,ubuntu-16-04,ubuntu-18-04,ubuntu-20-04"
34-
DEFAULT_KITCHEN_OSVERS: "ubuntu-20-04"
33+
KITCHEN_OSVERS: "ubuntu-14-04,ubuntu-16-04,ubuntu-18-04,ubuntu-20-04,ubuntu-22-04"
34+
DEFAULT_KITCHEN_OSVERS: "ubuntu-22-04"
3535
extends:
3636
- .kitchen_agent_a7
3737
- .kitchen_os_ubuntu

test/kitchen/drivers/azure-driver.yml

+15-2
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,15 @@ platforms:
111111
size = sizes[idx % sizes.length]
112112
end
113113
114+
# Check if we should use an ed25519 key, an rsa key or the default key
115+
# Some newer platforms don't support rsa, while some older platforms don't support ed25519
116+
# In Azure, ed25519 is not supported, but the default key created by the driver works
117+
default_key_platforms = ["ubuntu-22-04"]
118+
use_default_key = default_key_platforms.any? { |p| platform_name.include?(p) }
119+
120+
ed25519_platforms = []
121+
use_ed25519 = ed25519_platforms.any? { |p| platform_name.include?(p) }
122+
114123
vm_username = ENV['VM_USERNAME'] ? ENV['VM_USERNAME'] : "datadog"
115124
vm_password = ENV['SERVER_PASSWORD']
116125
@@ -154,8 +163,12 @@ platforms:
154163
<% else %>
155164
connection_retries: 30
156165
connection_retry_sleep: 2
157-
<% unless ENV['KITCHEN_SKIP_MANUAL_SSH_KEY'] %>
158-
ssh_key: <%= ENV['KITCHEN_SSH_KEY_PATH'] %>
166+
<% if use_default_key %>
167+
ssh_key:
168+
<% elsif use_ed25519 %>
169+
ssh_key: <%= ENV['KITCHEN_ED25519_SSH_KEY_PATH'] %>
170+
<% else %>
171+
ssh_key: <%= ENV['KITCHEN_RSA_SSH_KEY_PATH'] %>
159172
<% end %>
160173
<% end %>
161174

test/kitchen/drivers/ec2-driver.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ provisioner:
1818

1919
driver:
2020
name: ec2
21-
aws_ssh_key_id: <%= ENV['KITCHEN_EC2_SSH_ID'] %>
21+
aws_ssh_key_id: <%= ENV['KITCHEN_EC2_SSH_KEY_ID'] %>
2222
security_group_ids: <%= [ENV['KITCHEN_EC2_SG_IDS']] || ["sg-7fedd80a","sg-46506837"] %>
2323
region: <%= ENV['KITCHEN_EC2_REGION'] ||= "us-east-1" %>
2424
instance_type: <%= ENV['KITCHEN_EC2_INSTANCE_TYPE'] ||= 't3.xlarge' %>
@@ -98,6 +98,6 @@ platforms:
9898
<% if sles15 %>
9999
username: ec2-user
100100
<% end %>
101-
ssh_key: <%= ENV['KITCHEN_EC2_SSH_KEY'] %>
101+
ssh_key: <%= ENV['KITCHEN_EC2_SSH_KEY_PATH'] %>
102102

103103
<% end %>

test/kitchen/platforms.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@
7373
"ubuntu-20-04": "ami-0b75998a97c952252",
7474
"ubuntu-20-04-2": "ami-0a82127206c2824a1",
7575
"ubuntu-21-04": "ami-044f0ceee8e885e87",
76-
"ubuntu-21-10": "ami-0419d418f41aa4a0f"
76+
"ubuntu-21-10": "ami-0419d418f41aa4a0f",
77+
"ubuntu-22-04": "ami-02ddaf75821f25213"
7778
}
7879
},
7980
"vagrant": {

test/kitchen/tasks/run-test-kitchen.sh

+17-8
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,26 @@ if [ -f "$(pwd)/ssh-key.pub" ]; then
1414
rm ssh-key.pub
1515
fi
1616

17-
ssh-keygen -f "$(pwd)/ssh-key" -P "" -t rsa -b 2048
18-
KITCHEN_SSH_KEY_PATH="$(pwd)/ssh-key"
19-
export KITCHEN_SSH_KEY_PATH
17+
ssh-keygen -f "$(pwd)/ed25519-key" -P "" -a 100 -t ed25519
18+
KITCHEN_ED25519_SSH_KEY_PATH="$(pwd)/ed25519-key"
19+
export KITCHEN_ED25519_SSH_KEY_PATH
2020

21-
# show that the ssh key is there
22-
echo "$(pwd)/ssh-key"
23-
echo "$KITCHEN_SSH_KEY_PATH"
21+
# show that the ed25519 ssh key is there
22+
echo "$(pwd)/ed25519-key"
23+
echo "$KITCHEN_ED25519_SSH_KEY_PATH"
2424

25-
# start the ssh-agent and add the key
25+
ssh-keygen -f "$(pwd)/rsa-key" -P "" -t rsa -b 2048
26+
KITCHEN_RSA_SSH_KEY_PATH="$(pwd)/rsa-key"
27+
export KITCHEN_RSA_SSH_KEY_PATH
28+
29+
# show that the rsa ssh key is there
30+
echo "$(pwd)/rsa-key"
31+
echo "$KITCHEN_RSA_SSH_KEY_PATH"
32+
33+
# start the ssh-agent and add the keys
2634
eval "$(ssh-agent -s)"
27-
ssh-add "$KITCHEN_SSH_KEY_PATH"
35+
ssh-add "$KITCHEN_RSA_SSH_KEY_PATH"
36+
ssh-add "$KITCHEN_ED25519_SSH_KEY_PATH"
2837

2938
# in docker we cannot interact to do this so we must disable it
3039
mkdir -p ~/.ssh

test/kitchen/uservars-example.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
"ec2" : {
1919
"comment-ec2-vars": "Variables specific to the hyper-v driver",
2020
"comment_SSH_KEY": "path to ssh key used to create instances",
21-
"KITCHEN_EC2_SSH_KEY" : "<filename>",
21+
"KITCHEN_EC2_SSH_KEY_PATH" : "<filename>",
2222
"comment_SSH_ID": "friendly name in EC2 associated with above ssh key",
23-
"KITCHEN_EC2_SSH_ID" : "derek-sandbox-2",
23+
"KITCHEN_EC2_SSH_KEY_ID" : "derek-sandbox-2",
2424
"KITCHEN_EC2_TAG_CREATOR" : "db"
2525
},
2626
"azure" : {

0 commit comments

Comments
 (0)