Skip to content

Commit dbdb997

Browse files
committed
Test autoscaler plugin via molecule
1 parent c38c0de commit dbdb997

File tree

3 files changed

+37
-23
lines changed

3 files changed

+37
-23
lines changed

molecule/gitlab_runner/molecule.yml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,19 @@ provisioner:
7575
gitlab_runner_registry_mirror: "https://registry-mirror.example"
7676
gitlab_runner_listen_address: "127.0.0.1:9252"
7777
gitlab_runner_set_default_network_opts: true
78+
gitlab_runner_autoscaler_openstack_auth_url: "https://openstack.helmholtz.de:5000"
79+
gitlab_runner_autoscaler_openstack_username: "openstackuser"
80+
gitlab_runner_autoscaler_openstack_password: "123456"
81+
gitlab_runner_autoscaler_openstack_project_id: "e5cc8263-be6c-45a7-a6ce-e852dac95395"
82+
gitlab_runner_autoscaler_openstack_project_name: "openstack-project"
83+
gitlab_runner_autoscaler_openstack_user_domain_name: "Default"
84+
gitlab_runner_autoscaler_openstack_region_name: "Default"
7885
gitlab_runner_list:
7986
- name: "test01"
8087
url: "https://gitlab.com"
8188
description: "Molecule test runner"
8289
authentication_token: "${AUTHENTICATION_TOKEN}"
83-
executor: "docker+machine"
90+
executor: "docker-autoscaler"
8491
environment: ["CI_CPUS=8", "DOCKER_TLS_CERTDIR=/certs"]
8592
docker_volumes: ["/cache", "/certs/client", "/opt/docker/daemon.json:/etc/docker/daemon.json:ro"]
8693
docker_image: "python:3.8"
@@ -89,28 +96,21 @@ provisioner:
8996
tags: ["docker", "hifis"]
9097
locked: true
9198
limit: 10
99+
autoscaler_max_builds: 1
100+
autoscaler_idle_count: 5
101+
autoscaler_max_instances: 10
92102
machine_idle_count: 5
93-
machine_idle_time: 7200
94-
machine_max_builds: 4
95-
machine_max_growth_rate: 2
96-
machine_driver: "openstack"
97-
machine_name: "auto-scale-%s"
98-
machine_options:
99-
- "openstack-auth-url=https://openstack.example:5000/v3"
100-
- "openstack-image-id=73f07dd3-fa8b-468f-b6bc-b0cd4510f5d0"
101-
- "openstack-flavor-name=m1.small"
102-
- "openstack-net-id=7834deeb-8bd5-4fc7-b35b-24035d8f47a7"
103-
- "openstack-username=gitlab-runner"
104-
- "openstack-password=secret"
105-
- "openstack-tenant-id=123456"
106-
- "openstack-domain-name=default"
107-
- "openstack-ssh-user=core"
108-
- "openstack-sec-groups=Internal"
109-
- "openstack-keypair-name=runners-internal"
110-
- "openstack-private-key-file=/etc/gitlab-runner/gitlab_runner_key"
111-
- "openstack-user-data-file=/etc/gitlab-runner/ignition.json"
112-
- "openstack-active-timeout=300"
113-
- "engine-registry-mirror=https://registry-mirror.example"
103+
autoscaler_group_name: "hifis"
104+
autoscaler_cloud_name: "openstack"
105+
autoscaler_clouds_config: "/etc/gitlab-runner/clouds.yaml"
106+
autoscaler_use_ignition: true
107+
autoscaler_flavor_ref: "a7779e0c-899a-4c73-b75d-757e7722dc9b"
108+
autoscaler_image_ref: "67c1e69a-921d-4a5c-85cf-cf2a7d94a14d"
109+
autoscaler_network_id: "183bd5c6-e720-4601-b471-f4135a32263d"
110+
autoscaler_security_group: "8f291fca-006c-4576-a18e-f343d06af2c4"
111+
autoscaler_scheduler_hint: "8357bc97-580a-429f-a71d-895a3ab4b645"
112+
autoscaler_username: "core"
113+
autoscaler_keyname: "runner-internal"
114114
cache_type: "s3"
115115
cache_server_address: "https://cache.example"
116116
cache_access_key: "key"

molecule/gitlab_runner/verify.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@
4040
when: "gitlab_runner_list | selectattr('executor', 'equalto', 'docker+machine') | list | length > 0"
4141
failed_when: "'0.16.2-gitlab.25' not in machine_version.stdout"
4242

43+
- name: "Identify installed fleeting plugins"
44+
ansible.builtin.command: "gitlab-runner fleeting list"
45+
register: "fleeting_cmd"
46+
changed_when: false
47+
48+
- name: "Assert that fleeting-plugin-openstack is installed"
49+
when: "gitlab_runner_list | selectattr('executor', 'equalto', 'docker-autoscaler') | list | length > 0"
50+
ansible.builtin.assert:
51+
that:
52+
- "'fleeting-plugin-openstack' in fleeting_cmd.stdout"
53+
4354
- name: "Assert that Gitlab-Runner is installed"
4455
ansible.builtin.assert:
4556
that:

roles/gitlab_runner/tasks/main.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@
5151
ansible.builtin.slurp:
5252
src: "/etc/gitlab-runner/ignition.json"
5353
register: "ignition_json"
54-
when: "gitlab_runner_install_autoscaler"
54+
when:
55+
- "gitlab_runner_install_autoscaler"
56+
- "not gitlab_runner_is_initial_dryrun"
5557

5658
- name: "Template config file"
5759
ansible.builtin.template:
@@ -64,6 +66,7 @@
6466
no_log: true
6567
vars:
6668
ignition_content: "{{ ignition_json['content'] | b64decode }}"
69+
when: "not gitlab_runner_is_initial_dryrun"
6770

6871
- name: "Start GitLab-Runner"
6972
ansible.builtin.service:

0 commit comments

Comments
 (0)