-
Notifications
You must be signed in to change notification settings - Fork 551
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
34 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,16 +28,10 @@ on: | |
default: 20 | ||
description: The timeout(in minutes) for the workflow | ||
|
||
env: | ||
machine_user: kitchen | ||
machine_pass: Password1 | ||
machine_port: 5985 | ||
KITCHEN_LOCAL_YAML: 'kitchen.windows.yml' | ||
|
||
jobs: | ||
Test: | ||
name: ${{ matrix.instance }} | ||
runs-on: ${{ inputs.runs-on }} | ||
runs-on: windows-latest | ||
timeout-minutes: ${{ inputs.timeout }} | ||
strategy: | ||
fail-fast: false | ||
|
@@ -47,65 +41,22 @@ jobs: | |
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: 2.6.10 | ||
## ruby-version: 3.3.4 | ||
bundler-cache: true | ||
|
||
- name: Install Chef | ||
uses: actionshub/[email protected] | ||
with: | ||
project: chef | ||
version: 16.10.8 | ||
|
||
- name: Add Chef bindir to PATH | ||
uses: myci-actions/export-env-var-powershell@1 | ||
with: | ||
name: PATH | ||
value: "C:\\opscode\\chef\\bin;C:\\opscode\\chef\\embedded\\bin;$env:PATH" | ||
|
||
- name: Setup test user | ||
run: | | ||
$password = ConvertTo-SecureString $env:machine_pass -AsPlainText -Force | ||
New-LocalUser $env:machine_user -Password $password | ||
Add-LocalGroupMember -Group "Administrators" -Member $env:machine_user | ||
Get-LocalUser | ||
Get-LocalGroupMember -Group "Administrators" | ||
- name: Set up WinRM | ||
run: | | ||
Set-WSManQuickConfig -Force | ||
winrm set winrm/config/service '@{AllowUnencrypted="True"}' | ||
env | ||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.10" | ||
|
||
- name: Install Python Dependencies | ||
- name: Install Pytest | ||
run: | | ||
pip install -U pip | ||
pip install -r tests/requirements.txt | ||
pip install -U pytest | ||
- name: Create Test Instance | ||
- name: Bootstrap Salt | ||
run: | | ||
bundle exec kitchen create ${{ matrix.instance }}-${{ inputs.distro-slug }} | ||
sleep 2 | ||
. .\bootstrap-salt.ps1 | ||
- name: Test Bootstrap | ||
run: | | ||
env | ||
bundle exec kitchen verify ${{ matrix.instance }}-${{ inputs.distro-slug }} | ||
sleep 2 | ||
- name: Destroy Test Instance | ||
if: always() | ||
run: | | ||
bundle exec kitchen destroy ${{ matrix.instance }}-${{ inputs.distro-slug }} | ||
sleep 2 | ||
pytest --cache-clear -v -s -ra --log-cli-level=debug tests/integration/ | ||
- name: Set Exit Status | ||
if: always() | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,37 @@ | ||
import logging | ||
import os | ||
from contextlib import nullcontext | ||
import subprocess | ||
import json | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
def selected_context_manager(host): | ||
if "windows" in os.environ.get("KITCHEN_INSTANCE"): | ||
return nullcontext() | ||
return host.sudo() | ||
def run_salt_call(cmd): | ||
""" | ||
Runs salt call command and returns a dictionary | ||
Accepts cmd as a list | ||
""" | ||
cmd.append("--out=json") | ||
result = subprocess.run(cmd, capture_output=True, text=True) | ||
json_data = json.loads(result.stdout) | ||
return json_data["local"] | ||
|
||
|
||
def test_ping(host): | ||
with selected_context_manager(host): | ||
assert host.salt("test.ping", "--timeout=120") | ||
def test_ping(): | ||
cmd = ["salt-call", "--local", "test.ping"] | ||
result = run_salt_call(cmd) | ||
assert result == True | ||
|
||
|
||
def test_target_python_version(host, target_python_version): | ||
with selected_context_manager(host): | ||
ret = host.salt("grains.item", "pythonversion", "--timeout=120") | ||
assert ret["pythonversion"][0] == target_python_version | ||
def test_target_python_version(target_python_version): | ||
cmd = ["salt-call", "--local", "grains.item", "pythonversion", "--timeout=120"] | ||
result = run_salt_call(cmd) | ||
# Returns: {'pythonversion': [3, 10, 11, 'final', 0]} | ||
py_maj_ver = result["pythonversion"][0] | ||
assert py_maj_ver == target_python_version | ||
|
||
|
||
def test_target_salt_version(host, target_salt_version): | ||
with selected_context_manager(host): | ||
ret = host.salt("grains.item", "saltversion", "--timeout=120") | ||
if target_salt_version.endswith(".0") or target_salt_version.endswith(".x"): | ||
assert ret["saltversion"] == ".".join(target_salt_version.split(".")[:-1]) | ||
else: | ||
assert ret["saltversion"].startswith(target_salt_version) | ||
def test_target_salt_version(target_salt_version): | ||
cmd = ["salt-call", "--local", "grains.item", "saltversion", "--timeout=120"] | ||
result = run_salt_call(cmd) | ||
# Returns: {'saltversion': '3006.9+217.g53cfa53040'} | ||
assert result["saltversion"] == target_salt_version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1 @@ | ||
pytest-testinfra | ||
paramiko | ||
requests-ntlm==1.1.0; sys.platform == 'win32' | ||
pywinrm; sys.platform == 'win32' | ||
six>=1.10.0 | ||
pytest |