Sample - Powershell Job
The following is a sample Python code for calling QDC public APIs to test using Powershell script.
- Available chipsets
PowerShell jobs can only be used with job targets where the ChipsetCategory is Compute and the OS is Windows. To get the list of available targets, call this QDC public API.
- Artifacts limitation
| Type | Artifacts Number | Suffix |
|---|---|---|
| test package | optional | .zip/.msi |
| test script | optional | .zip |
- Sample code is similar to Monkey Job except
Section (1)part
# Section (1): preparing the parameters and submitting the jobjob_device_target = "SC8380XP" # target chipsettest_script_file = r"./PowerShellTestExample.zip" # same name as the test script preparedtest_script_response = qdc_api.upload_file(public_api_client, test_script_file, ArtifactType.TESTSCRIPT)job_target_id = qdc_api.get_target_id(public_api_client, job_device_target)job_id = qdc_api.submit_job(public_api_client=public_api_client,target_id=job_target_id,job_name="Example Job",external_job_id="ExJobId001",job_type=JobType.AUTOMATED,job_mode=JobMode.APPLICATION,timeout=600,test_framework=TestFramework.POWERSHELL,entry_script="C:\\temp\\TestContent\\PowerShellTestExample\\ScriptToRun.ps1",job_artifacts=[test_script_response],monkey_events=None,monkey_session_timeout=None,job_parameters=[])
- Sample Test Packages
Create a file named ScriptToRun.ps1, copy the following code into it, zip the file to PowerShellTestExample.zip, and and move the zip file into the same folder as hello_qdc.py.
Write-Host "Hi.. Checking powershell testframework!!"Start-Sleep -seconds 3echo "Hello QDC" | Out-File -Filepath "C:/Temp/QDC_logs/logTest.log"
More details can refer to Preparing PowerShell Test Packages.