Skip to content

Commit d52f211

Browse files
authored
Create a script for checking test system images (#155)
* AL-5809: create a job to check test-system images Created a script for checking for test images Resolves: https://cloudlinux.atlassian.net/browse/AL-5809 * AL-5809: fetch all build_plaforms in terraform at once * Fix tests' values * Adding test_config for required values * Dockerfile for Jenkins job for checking images * Fixing regex bugs * Check templates with minor versions for platforms with major versions
1 parent f7b5dc3 commit d52f211

File tree

7 files changed

+475
-11
lines changed

7 files changed

+475
-11
lines changed

Dockerfile.test-images

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM python:3.10
2+
3+
# Download Terraform
4+
RUN apt-get update && \
5+
apt-get install -y wget unzip gnupg software-properties-common && \
6+
wget -O terraform.zip https://releases.hashicorp.com/terraform/1.12.1/terraform_1.12.1_linux_amd64.zip && \
7+
unzip terraform.zip && mv terraform /usr/local/bin/ && \
8+
rm terraform.zip && terraform -version
9+
10+
COPY ../requirements/base.txt /tmp/requirements.txt
11+
RUN pip install -r /tmp/requirements.txt

alts/shared/terraform.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ def get_opennebula_template_regex(
148148
else:
149149
arches_to_try = dist_arch
150150
if test_flavor_name and test_flavor_version:
151-
flavor = f'{test_flavor_name}-{test_flavor_version}'
151+
flavor = f'{test_flavor_name}-?{test_flavor_version}'
152152
regex_str = (
153-
rf'{dist_name}-{dist_version}-({arches_to_try})\.{flavor}\.'
153+
rf'^{dist_name}-{dist_version}-({arches_to_try})\.{flavor}\.'
154154
rf'test_system\.({channels})\.b\d{{8}}-\d+'
155155
)
156156
# Escape backslashes for Terraform HCL string

resources/opennebula/opennebula.tf.tmpl

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ variable "one_username" {}
33
variable "one_password" {
44
sensitive = true
55
}
6+
variable "load_all_templates" {
7+
type = bool
8+
default = false
9+
description = "If true, output all matching templates; otherwise, only one"
10+
}
611

712
provider "opennebula" {
813
endpoint = var.one_endpoint
@@ -31,11 +36,16 @@ locals {
3136

3237
has_templates_with_channels = length(local.templates_with_channels) > 0
3338

34-
selected_template = (
35-
local.has_templates_with_channels ? local.templates_with_channels[0] :
36-
local.all_templates[0]
39+
candidate_templates = (
40+
local.has_templates_with_channels ? local.templates_with_channels : local.all_templates
41+
)
42+
43+
selected_templates = (
44+
var.load_all_templates ? local.candidate_templates : [local.candidate_templates[0]]
3745
)
3846

47+
selected_template = local.selected_templates[0]
48+
3949
disk_0 = local.selected_template.disk[0]
4050
disk_size = max(
4151
local.disk_0.size, # Original disk size from template
@@ -79,6 +89,7 @@ output "vm_id" {
7989
value = opennebula_virtual_machine.${vm_name}.id
8090
}
8191

82-
output "template_name" {
83-
value = local.selected_template.name
92+
output "template_names" {
93+
value = [for t in local.selected_templates : t.name]
94+
description = "Array of selected template names (1 or many depending on flag)"
8495
}

scripts/__init__.py

Whitespace-only changes.

scripts/test_config.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
3+
broker_config:
4+
rabbitmq_host: localhost
5+
rabbitmq_port: 5671
6+
rabbitmq_user: albs
7+
rabbitmq_password: some-another-secret-password
8+
rabbitmq_vhost: test_system
9+
10+
results_backend_config:
11+
path: file:///srv/celery_results

0 commit comments

Comments
 (0)