Skip to content

Commit

Permalink
Adding integration test for ansible os coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
RachaelSTamakloe committed Dec 17, 2024
1 parent 49db0d3 commit 6b06d0d
Show file tree
Hide file tree
Showing 4 changed files with 252 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---
- name: Check if Ansible is installed
ansible.builtin.shell: |
command -v ansible >/dev/null 2>&1 && echo "Ansible is installed" || echo "Ansible is not installed"
register: ansible_check_result

- name: Assert Ansible is installed
ansible.builtin.assert:
that:
- ansible_check_result.stdout == "Ansible is installed"
162 changes: 162 additions & 0 deletions tools/cloud-build/daily-tests/blueprints/ansible-vm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---

blueprint_name: test-workstation-ansible

vars:
project_id: ## Set GCP Project ID Here ##
deployment_name: test-workstation-ansible
region: us-central1
zone: us-central1-a
machine_type: n2-standard-2
disk_type: pd-ssd
instance_count: 1

deployment_groups:
- group: primary
modules:

- id: network1
source: modules/network/pre-existing-vpc

- id: startup-script
source: modules/scripts/startup-script
settings:
install_ansible: true
runners:
- type: shell
destination: startup.sh
content: |
#!/bin/bash
set -ex
echo \$(ansible --version)
- id: workstation-centos
source: modules/compute/vm-instance
use:
- network1
- startup-script
settings:
name_prefix: centos
add_deployment_name_before_prefix: true
instance_image:
name: centos-7-v20240611
project: centos-cloud
- id: wait-centos
source: community/modules/scripts/wait-for-startup
settings:
instance_name: $(workstation-centos.name[0])
timeout: 7200

- id: workstation-ubuntu-2004
source: modules/compute/vm-instance
use:
- network1
- startup-script
settings:
name_prefix: ubuntu2004
add_deployment_name_before_prefix: true
instance_image:
family: ubuntu-2004-lts
project: ubuntu-os-cloud
- id: wait-ubuntu-2004
source: community/modules/scripts/wait-for-startup
settings:
instance_name: $(workstation-ubuntu-2004.name[0])
timeout: 7200

- id: workstation-ubuntu-2204
source: modules/compute/vm-instance
use:
- network1
- startup-script
settings:
name_prefix: ubuntu2204
add_deployment_name_before_prefix: true
instance_image:
family: ubuntu-2204-lts
project: ubuntu-os-cloud
- id: wait-ubuntu-2204
source: community/modules/scripts/wait-for-startup
settings:
instance_name: $(workstation-ubuntu-2204.name[0])
timeout: 7200

- id: workstation-debian
source: modules/compute/vm-instance
use:
- network1
- startup-script
settings:
name_prefix: debian
instance_image:
family: debian-11
project: debian-cloud
- id: wait-debian
source: community/modules/scripts/wait-for-startup
settings:
instance_name: $(workstation-debian.name[0])
timeout: 7200

- id: workstation-rocky-8
source: modules/compute/vm-instance
use:
- network1
- startup-script
settings:
name_prefix: rocky8
add_deployment_name_before_prefix: true
instance_image:
family: rocky-linux-8-optimized-gcp
project: rocky-linux-cloud
- id: wait-rocky-8
source: community/modules/scripts/wait-for-startup
settings:
instance_name: $(workstation-rocky-8.name[0])
timeout: 7200

# - id: workstation-rocky-9
# source: modules/compute/vm-instance
# use:
# - network1
# - startup-script
# settings:
# name_prefix: rocky9
# add_deployment_name_before_prefix: true
# instance_image:
# family: rocky-linux-9-optimized-gcp
# project: rocky-linux-cloud
# - id: wait-rocky-9
# source: community/modules/scripts/wait-for-startup
# settings:
# instance_name: $(workstation-rocky-9.name[0])
# timeout: 7200

# - id: workstation-ubuntu-2404
# source: modules/compute/vm-instance
# use:
# - network1
# - startup-script
# settings:
# name_prefix: ubuntu2404
# instance_image:
# family: ubuntu-2404-lts-amd64
# project: ubuntu-os-cloud
# - id: wait-ubuntu-2404
# source: community/modules/scripts/wait-for-startup
# settings:
# instance_name: $(workstation-ubuntu-2404.name[0])
# timeout: 7200
41 changes: 41 additions & 0 deletions tools/cloud-build/daily-tests/builds/ansible-vm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---
tags:
- m.pre-existing-vpc
- m.startup-script
- m.vm-instance
- m.wait-for-startup
- vm

timeout: 14400s # 4hr
steps:
- id: anisble-vm
name: us-central1-docker.pkg.dev/$PROJECT_ID/hpc-toolkit-repo/test-runner
entrypoint: /bin/bash
env:
- "ANSIBLE_HOST_KEY_CHECKING=false"
- "ANSIBLE_CONFIG=/workspace/tools/cloud-build/ansible.cfg"
args:
- -c
- |
set -x -e
cd /workspace && make
BUILD_ID_FULL=$BUILD_ID
BUILD_ID_SHORT=$${BUILD_ID_FULL:0:6}
ansible-playbook tools/cloud-build/daily-tests/ansible_playbooks/base-integration-test.yml \
--user=sa_106486320838376751393 --extra-vars="project=${PROJECT_ID} build=$${BUILD_ID_SHORT}" \
--extra-vars="@tools/cloud-build/daily-tests/tests/ansible-vm.yml"
25 changes: 25 additions & 0 deletions tools/cloud-build/daily-tests/tests/ansible-vm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---

test_name: test-workstation-ansible
deployment_name: "ansible-vm-{{ build }}"
zone: us-central1-a
workspace: /workspace
blueprint_yaml: "{{ workspace }}/tools/cloud-build/daily-tests/blueprints/ansible-vm.yaml"
network: "default"
remote_node: "{{ deployment_name }}-centos-0"
post_deploy_tests:
- test-validation/test-ansible-vm.yml

0 comments on commit 6b06d0d

Please sign in to comment.