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

Add component tests for collection #41

Merged
merged 60 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
a30a814
Adapt old integration scripts to work with GitHub actions
WStechura May 28, 2024
7072b71
Add test runner
WStechura Jul 2, 2024
5f540ae
Add running tests in pipeline
WStechura Jul 3, 2024
bc2af40
Remove technology classes
WStechura Jul 4, 2024
41eceb1
Add local connection option
WStechura Jul 5, 2024
26b5355
Add verify signature key to collection
WStechura Jul 10, 2024
7c9d1cf
Add skipping localInstaller test for localhost. Improve mocked instal…
WStechura Jul 11, 2024
b2987ef
Fix tests
WStechura Jul 12, 2024
9db31ba
Fix installation test
WStechura Jul 23, 2024
70256eb
Update test logic
WStechura Jul 26, 2024
7516c29
Adapt tests to work with with regular installer
WStechura Jul 26, 2024
ca4d79c
Apply review remarks
WStechura Aug 1, 2024
b89a670
Review remarks - rename component tests, apply type hints
WStechura Sep 4, 2024
65639ef
Remove Union type
WStechura Sep 4, 2024
0a9ddfe
Remove Ansible from technology
WStechura Sep 6, 2024
8978ba4
Bump pywinrm version, change README, fix code
WStechura Sep 10, 2024
b376f31
Add missing types
WStechura Sep 11, 2024
150421e
Fix ansible-lint errors
WStechura Sep 17, 2024
0613ba2
Add installer signing
WStechura Sep 20, 2024
92c8b39
Add certificate replacement
WStechura Sep 27, 2024
d247615
Remove hardcoded values
jakubrak Oct 3, 2024
88fc7ce
Add tear down to all test
jakubrak Oct 10, 2024
1aa9d03
Add uninstall step and cleanup in tear down
jakubrak Oct 10, 2024
0260642
Refactor test_installAndConfig.py
jakubrak Oct 10, 2024
bbce897
Refactor test_upgrade.py
jakubrak Oct 10, 2024
6090ec3
Refactor test_resilience.py
jakubrak Oct 10, 2024
5dbaf5f
Refactor certificates handling
jakubrak Oct 10, 2024
5dcb3d8
Adapt .gitignore
jakubrak Oct 14, 2024
328e254
Continue if tests fail to upload logs
jakubrak Oct 15, 2024
ba928bc
Fix issue with running tests as a root
jakubrak Oct 15, 2024
b4efa60
Fix issue with doubled build on PRs
jakubrak Oct 15, 2024
146365f
Install collection for component tests with sudo
jakubrak Oct 15, 2024
a60eff5
Fix names
jakubrak Oct 15, 2024
965f532
Fix triggers
jakubrak Oct 15, 2024
51418f6
Remove unused ssh connection handling
jakubrak Oct 15, 2024
2f479d4
Use pytest directly
jakubrak Oct 16, 2024
ae4d623
Join _set_up and _tear_down fixtures and add autouse option
jakubrak Oct 17, 2024
885cf2b
Split prepare_environment fixture
jakubrak Oct 17, 2024
8ed80f3
Extend .gitignore
jakubrak Oct 17, 2024
3619661
Add explicit return type
jakubrak Oct 17, 2024
783efa7
Use venv instead of virtualenv
jakubrak Oct 17, 2024
3fc4b33
Add set -e to shell scripts
jakubrak Oct 17, 2024
eced5f1
Remove redundant comments
jakubrak Oct 17, 2024
56717c4
Enable test_localInstaller.py for localhost
jakubrak Oct 17, 2024
fd806f9
Remove DeploymentRunner abstraction
jakubrak Oct 17, 2024
148167d
Remove DeploymentConfig abstraction
jakubrak Oct 17, 2024
a1b6bad
Rename technology to ansible
jakubrak Oct 17, 2024
d71d4c7
Update tests README.md
jakubrak Oct 17, 2024
5371123
Fix quotes consistency
jakubrak Oct 17, 2024
2271b8b
Use NotImplementedError
jakubrak Oct 17, 2024
9440851
Provide return type hints
jakubrak Oct 17, 2024
69f82dd
Refactor SSLCertificateGenerator
jakubrak Oct 18, 2024
74a34fd
Remove AnsibleUtil and AnsibleConstants
jakubrak Oct 22, 2024
f7ed583
Remove .idea/misc.xml
jakubrak Oct 23, 2024
f72b475
Parametrize server
jakubrak Oct 24, 2024
d7df64d
Refactor installer server naming conventions
jakubrak Oct 24, 2024
6baa417
Add machine IP address to SAN field in certificate generation
WStechura Oct 25, 2024
77f64bf
Adapt tests to run on Windows machines
WStechura Oct 29, 2024
a8b1516
Remove oneagent_validate_certs parameter
WStechura Oct 29, 2024
02c5496
Update tests' README
WStechura Oct 30, 2024
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
8 changes: 4 additions & 4 deletions .github/actions/build-collection/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

name: build-collection
description: Builds the collection
name: "Build collection"
description: "Builds collection"

runs:
using: composite
steps:
- name: Download certificate
- name: "Download certificate"
shell: bash
run: mkdir -p $FILES_DIR && wget https://ca.dynatrace.com/dt-root.cert.pem -P $FILES_DIR
- name: Build the collection
- name: "Build the collection"
shell: bash
run: ansible-galaxy collection build . -vvv
4 changes: 2 additions & 2 deletions .github/actions/publish-to-ansible-galaxy/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

name: publish-to-ansible-galaxy
name: "Publish to Ansible Galaxy"
description: Publish to Ansible Galaxy

inputs:
Expand All @@ -23,6 +23,6 @@ inputs:
runs:
using: composite
steps:
- name: Publish the Ansible collection
- name: "Publish the Ansible collection"
shell: bash
run: ansible-galaxy collection publish dynatrace-oneagent* --token ${{ inputs.ansible-galaxy-api-token }}
42 changes: 42 additions & 0 deletions .github/actions/run-component-tests/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright 2024 Dynatrace 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
#
# https://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: "Run component tests"
description: "Runs component tests"

runs:
using: composite
steps:
- name: "Prepare Python environment"
shell: bash
run: |
python -m venv venv
source venv/bin/activate
pip install -r roles/oneagent/tests/requirements.txt

- name: "Install the collection"
shell: bash
run: sudo bash -c "source venv/bin/activate && ansible-galaxy collection install -vvv dynatrace-oneagent*"

- name: "Run component tests"
shell: bash
run: sudo bash -c "source venv/bin/activate && pytest roles/oneagent/tests --linux_x86=localhost"

- name: "Upload logs"
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: component-tests-${{ github.sha }}
retention-days: 1
path: test_dir/logs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.

name: run-tests
description: Runs the tests
name: run-sanity-tests
description: "Runs sanity tests"

runs:
using: composite
steps:
- name: Install the collection
- name: "Install the collection"
shell: bash
run: ansible-galaxy collection install dynatrace-oneagent*
- name: Run sanity test
run: ansible-galaxy collection install -vvv dynatrace-oneagent*

- name: "Run sanity test"
shell: bash
run: pushd ~/.ansible/collections/ansible_collections/dynatrace/oneagent && ansible-test sanity && popd
6 changes: 3 additions & 3 deletions .github/actions/set-environment-variables/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

name: Set environment variables
description: Set environment variables required for other actions
name: "Set environment variables"
description: "Set environment variables required for other actions"

runs:
using: composite
steps:
- name: Set environment variables
- name: "Set environment variables"
shell: bash
run: printf "FILES_DIR=roles/oneagent/files\n" >> $GITHUB_ENV
6 changes: 3 additions & 3 deletions .github/actions/setup-build-environment/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

name: setup-build-environment
description: Prepares build environment
name: "Prepare build environment"
description: "Prepares build environment"

runs:
using: composite
steps:
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
- name: "Install dependencies"
shell: bash
run: pip install ansible
14 changes: 7 additions & 7 deletions .github/actions/update-version/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,35 @@
# See the License for the specific language governing permissions and
# limitations under the License.

name: update-version
description: Update version
name: "Update version"
description: "Updates version"

runs:
using: composite
steps:
- name: Get latest tag
- name: "Get latest tag"
shell: bash
run: printf "LATEST_TAG=%s\n" "$(git describe --tags --abbrev=0 --always)" >> $GITHUB_ENV

- name: Extract version
- name: "Extract version"
shell: bash
run: |
latestTag="${{ env.LATEST_TAG }}"
printf "LATEST_VERSION=%s\n" "${latestTag#v}" >> $GITHUB_ENV

- name: Update galaxy.yml version
- name: "Update galaxy.yml version"
shell: bash
run: |
latestVersion="${{ env.LATEST_VERSION }}"
sed -i "s/version: .*/version: ${latestVersion}/" galaxy.yml

- name: Configure git
- name: "Configure git"
shell: bash
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"

- name: Commit and push changes
- name: "Commit and push changes"
shell: bash
run: |
git checkout master
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/upload-collection/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

name: upload-collection
name: "Upload collection"
description: Uploads the collection locally

runs:
using: composite
steps:
- name: Publish artifact
- name: "Publish artifact"
uses: actions/upload-artifact@v4
with:
name: dynatrace-oneagent-${{ github.sha }}
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

name: Build and test
name: "Build and test"
on:
pull_request:
branches: [ "*" ]
push:
branches: [ "*" ]
workflow_dispatch:
workflow_call:

Expand All @@ -35,5 +32,7 @@ jobs:
uses: ./.github/actions/setup-build-environment
- name: Build the collection
uses: ./.github/actions/build-collection
- name: Run tests
uses: ./.github/actions/run-tests
- name: Run sanity tests
uses: ./.github/actions/run-sanity-tests
- name: Run component tests
uses: ./.github/actions/run-component-tests
8 changes: 5 additions & 3 deletions .github/workflows/build-test-and-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

name: Build, test and publish
name: "Build, test and publish"
on:
push:
tags:
Expand All @@ -33,8 +33,10 @@ jobs:
uses: ./.github/actions/setup-build-environment
- name: Build the collection
uses: ./.github/actions/build-collection
- name: Run tests
uses: ./.github/actions/run-tests
- name: Run sanity tests
uses: ./.github/actions/run-sanity-tests
- name: Run component tests
uses: ./.github/actions/run-component-tests
- name: Publish to Ansible Galaxy
uses: ./.github/actions/publish-to-ansible-galaxy
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-test-and-upload.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

name: Build, test and upload
name: "Build, test and upload"
on:
push:
branches: [ "master" ]
Expand Down
32 changes: 31 additions & 1 deletion .gitignore
jakubrak marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1 +1,31 @@
dynatrace-oneagent-*
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Flask
instance/
.webassets-cache

# Ansible
*.retry
dynatrace-oneagent-*.tar.gz

# JetBrains IDE
.idea

# Tests working directory
**/test_dir/
3 changes: 0 additions & 3 deletions .idea/.gitignore

This file was deleted.

9 changes: 0 additions & 9 deletions .idea/Dynatrace-OneAgent-Ansible.iml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

3 changes: 1 addition & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
---

repos:
- repo: https://github.com/ansible/ansible-lint
rev: v24.2.2
hooks:
- id: ansible-lint
pass_filenames: false
args: ['--exclude', 'roles/oneagent/examples']
args: ['--exclude', 'roles/oneagent/examples', 'tests/component/resources/ansible/oneagent.yml']
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ All notable changes to this project will be documented in this file.

- Added parameter `--restart-service` parameter, once OneAgent configuration is performed
- Fixed problem with `Invalid version string` during collection install
- Added parameter `oneagent_verify_signature` controlling signature verification step
- Removed `oneagent_validate_certs` parameter

## [1.1.0] - 2021-10-06

Expand Down
3 changes: 3 additions & 0 deletions galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ tags:
- deployment
repository: https://github.com/Dynatrace/Dynatrace-OneAgent-Ansible
documentation: https://docs.dynatrace.com/docs/setup-and-configuration/dynatrace-oneagent/deployment-orchestration/ansible
build_ignore:
- roles/oneagent/tests
- roles/oneagent/examples
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ansible >= 2.15.0
pywinrm >= 0.4.1 ; sys_platform == 'win32'
pywinrm >= 0.4.3
2 changes: 1 addition & 1 deletion roles/oneagent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ The following variables are available in `defaults/main/` and can be overridden:
| `oneagent_preserve_installer` | `false` | Preserve installers on secondary machines after deployment.
| `oneagent_package_state` | `present` | OneAgent package state; use `present` or `latest` to make sure it's installed, or `absent` in order to uninstall.
| `oneagent_reboot_host` | `false` | Reboot the secondary machine after OneAgent installation
| `oneagent_validate_certs` | `true` | If set to `false`, allows to download OneAgent from a server with insecure SSL certificate (expired, self-signed, etc).
| `oneagent_verify_signature` | `true` | Verifies installer's signature (available only on AIX/Linux platforms)
| `oneagent_reboot_timeout` | `3600` | Set the timeout for rebooting secondary machine in seconds

For more information, see customize OneAgent installation documentation for [Linux], [Windows], and [AIX].
Expand Down
7 changes: 5 additions & 2 deletions roles/oneagent/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ oneagent_preserve_installer: false
# Set the need of rebooting machine after installation
oneagent_reboot_host: false

# Set the need of validating certs during installer download
oneagent_validate_certs: true
# Set the need of verifying the installer signature
oneagent_verify_signature: true
WStechura marked this conversation as resolved.
Show resolved Hide resolved

# Set the timeout for platform reboot
oneagent_reboot_timeout: 3600

# Set CA certificate download url
oneagent_ca_cert_download_url: https://ca.dynatrace.com/dt-root.cert.pem
2 changes: 1 addition & 1 deletion roles/oneagent/tasks/cleanup/cleanup-windows.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: Remove leftover installer
win_file:
ansible.windows.win_file:
path: "{{ oneagent_installer_path }}"
state: absent
Loading