Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test bootstrap script #1281

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions bats/fb-test-bootstrap.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bats
# vim: ft=sh:sw=2:et

set -o pipefail

load os_helper
load foreman_helper
load fixtures/content

setup() {
tSetOSVersion
HOSTNAME=$(hostname -f)
}

@test "download bootstrap script from /pub and register to Satellite" {
source /root/.bash_profile
curl -o /root/bootstrap.py "http://${SERVERNAME}/pub/bootstrap.py"
python /root/bootstrap.py -s ${SERVERNAME} -o 'Default_Organization' -L 'Default Location' -a My_Activation_Key --hostgroup=My_Hostgroup --skip puppet --skip foreman --force
echo "rc=${status}"
echo "${output}"
yum -y install tracer-common
echo "rc=${status}"
echo "${output}"
}

@test "Move client to get content from Capsule" {
source /root/.bash_profile
python /root/bootstrap.py -s ${CAPSULENAME} -o 'Default_Organization' -L 'Default Location' -a My_Activation_Key --hostgroup=My_Hostgroup --skip puppet --skip foreman --force
echo "rc=${status}"
echo "${output}"
}
10 changes: 6 additions & 4 deletions bats/fixtures/content.bash
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
# vim: ft=sh:sw=2:et

ORGANIZATION="Test Organization"
ORGANIZATION="Default Organization"
PRODUCT="Test Product"
CONTAINER_REPOSITORY="fedorassh"
FILE_REPOSITORY="file repo"
PUPPET_REPOSITORY="Puppet Modules"
YUM_REPOSITORY="Zoo"
YUM_REPOSITORY_2="modules-rpms"
YUM_REPOSITORY_3="rpm-deps"
LIFECYCLE_ENVIRONMENT="Test"
CONTENT_VIEW="Test CV"
LIFECYCLE_ENVIRONMENT="Library"
CONTENT_VIEW="Default Organization View"
CONTENT_VIEW_2="Component 1"
CONTENT_VIEW_3="Composite"
ACTIVATION_KEY="Test AK"
ACTIVATION_KEY="My_Activation_Key"
FILTER1="errata excluder"
FILTER2="rpm excluder"
FILTER3="modulemd includer"
HOSTGROUP="My_Hostgroup"

ORGANIZATION_LABEL="${ORGANIZATION/ /_}"
PRODUCT_LABEL="${PRODUCT/ /_}"
Expand All @@ -26,3 +27,4 @@ YUM_REPOSITORY_LABEL="${YUM_REPOSITORY/ /_}"
LIFECYCLE_ENVIRONMENT_LABEL="${LIFECYCLE_ENVIRONMENT/ /_}"
CONTENT_VIEW_LABEL="${CONTENT_VIEW/ /_}"
ACTIVATION_KEY_LABEL="${ACTIVATION_KEY/ /_}"
HOSTGROUP_LABEL="${HOSTGROUP/ /_}"
17 changes: 6 additions & 11 deletions roles/bats/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
---
bats_fetch_results: true
bats_environment: {}
bats_git_dir: "/root/bats"
bats_forklift_dir: "/root/forklift"
bats_forklift_repo: "https://github.com/theforeman/forklift.git"
bats_forklift_version: HEAD
bats_output_dir: "/root/bats_results"
bats_git_dir: "/tmp/bats"
bats_forklift_dir: "/tmp/forklift"
bats_forklift_repo: "https://github.com/swadeley/forklift.git"
bats_forklift_version: test-bootstrap-script
bats_output_dir: "/tmp/bats_results"
bats_remote_dir: "/tmp/debug-{{ pipeline_type | default('foreman') }}-{{ pipeline_version | default('nightly') }}-{{ pipeline_os | default('el7') }}"
bats_update_forklift: "yes"
bats_run: true
bats_setup: []
bats_tests:
- "fb-verify-packages.bats"
- "fb-test-foreman.bats"
- "fb-test-puppet.bats"
- "fb-test-katello.bats"
- "fb-content-katello.bats"
- "fb-test-bootstrap.bats"
bats_tests_additional: []
bats_teardown:
- "fb-destroy-organization.bats"
- "fb-finish.bats"
13 changes: 11 additions & 2 deletions roles/bats/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
args:
creates: "/usr/bin/bats"

- name: "Forklift directory"
file:
state: "directory"
path: "{{ bats_forklift_dir }}"

- name: "Clone forklift"
git:
repo: "{{ bats_forklift_repo }}"
Expand All @@ -46,22 +51,26 @@
shell: "bats --tap {{ item }} > {{ bats_output_dir }}/{{ item }}.tap"
args:
chdir: "{{ bats_forklift_dir }}/bats"
vars:
bats_environment:
SERVERNAME: "{{ satdeploy_server_name }}.{{ ansible_domain }}"
with_items:
- "{{ bats_setup }}"
- "{{ bats_tests }}"
- "{{ bats_tests_additional }}"
- "{{ bats_teardown }}"
register: "test_output"
ignore_errors: true
environment: "{{ bats_environment }}"
become: true
async: 220
poll: 60

- name: "Read results"
shell: "cat {{ bats_output_dir }}/{{ item }}.tap"
register: "test_results"
with_items:
- "{{ bats_setup }}"
- "{{ bats_tests }}"
- "{{ bats_tests_additional }}"
- "{{ bats_teardown }}"

- name: "Output test results"
Expand Down
2 changes: 0 additions & 2 deletions roles/bats/vars/RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@ bats_packages:
- ruby
- git
- yum-utils
- podman
- sos
29 changes: 27 additions & 2 deletions roles/katello_client/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
---
- name: 'Cleanup previous registrations'
include_tasks: cleanup.yml
- block:
- name: 'Cleanup previous registrations'
include_tasks: cleanup.yml
when: katello_client_cleanup

- name: 'Install bootstrap rpm'
yum:
name: "http://{{ katello_client_server }}/pub/katello-ca-consumer-latest.noarch.rpm"
disable_gpg_check: True
state: "present"
become: true
register: install_result

- debug: var=install_result

- name: 'Register client with subscription-manager as user {{ katello_client_username }}'
redhat_subscription:
Expand All @@ -20,6 +25,7 @@
ignore_errors: "{{ katello_client_ignore_registration_errors }}"
when:
- katello_client_activationkey == ""
become: true

- name: 'Register client with subscription-manager using AK {{ katello_client_activationkey }}'
redhat_subscription:
Expand All @@ -30,25 +36,44 @@
ignore_errors: "{{ katello_client_ignore_registration_errors }}"
when:
- katello_client_activationkey != ""
become: yes
register: output
async: 220
poll: 30

- name: 'Enable extra repositories'
command: subscription-manager repos --enable {{ item }}
with_items: "{{ katello_client_extra_repos }}"
become: true
register: output
async: 220
poll: 30

- name: 'Install katello-host-tools'
yum:
name: "katello-host-tools"
state: "present"
ignore_errors: yes
become: true
register: output
async: 220
poll: 30

- name: 'Install katello-agent'
yum:
name: "katello-agent"
state: "present"
when: katello_client_install_agent
register: output
async: 220
poll: 30

- name: 'Install katello-host-tools-tracer'
yum:
name: "katello-host-tools-tracer"
state: "present"
when: katello_client_install_tracer
become: yes
register: output
async: 220
poll: 60