In a local PC environment, it is not possible to set up scheduled batch test execution on MagicPod as in a cloud environment. Therefore, it is necessary to use a schedule execution tool on your local PC. This section describes how to use launchd in the Mac environment and the Task Scheduler in the Windows environment for scheduled execution in a local PC environment.
Table of contents
1. Periodic batch run on Mac using launchd
launchd is a service management tool for managing macOS system processes and tasks. Here we explain how to use launchd to run batch tests at 10:00 every day.
1-1 Create Batch run settings
First, create Batch run settings on MagicPod that you want to run periodically. Click here to learn how to create it.
After the creation, confirm the number of the Batch run settings from the Setting name. It will be used in the next step.
1-2 Edit magic_pod_config.json
Open the configuration file, magic_pod_config.json.
For MacPC, the file is located in the following path by default.
/Users/<UserName>/Library/Application Support/magic_pod_desktop/magic_pod_config.json
Then edit magic_pod_config.json as follows:
{
"owner": <Organization name. This is not the display name, but the alphabet description in the URL>,
"project": <Project name. This is not the display name, but the alphabet description in the URL>,
"testSettingsNumber": <Test Settings Number>
}
Reference:Run batch tests from the command line (Local PC environment)
1-3 Create .plist file for launchd
Create a .plist file based on the following code example and place it in the '~Library/LaunchAgents/' directory. Here, the file name is 'com.example.magicpod.plist'.
- In ProgramArguments, please write down the full path to the MagicPodDesktop file and the magic_pod_config.json file.
- In this example, the batch test is set to run every day at 10:00 AM. If you want to change the time, change StartCalendarInterval.
- If you do not want the batch execution to be performed when the .plist file is loaded for the first time, set RunAtLoad to false.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.example.magicpod</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/MagicPodDesktop.app/Contents/MacOS/MagicPodDesktop</string>
<string>run</string>
<string>--magic_pod_config=/Users/<User_name>/Library/Application Support/magic_pod_desktop/magic_pod_config.json</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>10</integer>
<key>Minute</key>
<integer>0</integer>
</dict>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
1-4 Load the .plist file
Execute this command using a command line tool such as Terminal. If RunAtLoad in the .plist file is set to true, the batch test will be executed not only at the specified time, but also when the file is loaded.
launchctl load ~/Library/LaunchAgents/com.example.magicpod.plist
The setup for periodic execution has been completed. If you want to stop the periodic execution, unload it by executing the following command.
launchctl unload ~/Library/LaunchAgents/com.example.magicpod.plist
2. Periodic batch run on Windows using Task Scheduler
Task Scheduler is a scheduling tool installed in Windows. Here we will explain how to use Task Scheduler to execute a batch of tests at 10:00 every day.
2-1 Create Batch run settings
First, create Batch run settings on MagicPod that you want to run periodically. Click here to learn how to create it.
After the creation, confirm the number of the Batch run settings from the Setting names. It will be used in the next step.
2-2 Edit magic_pod_config.json
Open the configuration file, magic_pod_config.json.
For MacPC, the file is located in the following path by default.
/Users/<UserName>/Library/Application Support/magic_pod_desktop/magic_pod_config.json
Then edit magic_pod_config.json as follows:
{
"owner": <Organization name. This is not the display name, but the alphabet description in the URL>,
"project": <Project name. This is not the display name, but the alphabet description in the URL>,
"testSettingsNumber": <Test Settings Number>
}
Reference:Run batch tests from the command line (Local PC environment)
2-3 Create a .ps1 file to run in PowerShell
Create a .ps1 file based on the following example. Here, the file name is 'RunMagicPod.ps1'.
& "C:\Users\<UserName>\AppData\Local\magic_pod_desktop\app-1.20.0\MagicPodDesktop.exe" run --magic_pod_config="C:\Users\<UserName>\AppData\Roaming\magic_pod_desktop\magic_pod_config.json"; Wait-Process -Name MagicPodDesktop -Timeout 3600
2-4 Create Task on Task Scheduler
Launch the Task Scheduler and click on 'Create Task'.
In the 'General' tab, name the task as you prefer.
In the 'Triggers' tab, click 'New' and set a trigger to run at 10:00 AM every day.
In the 'Actions' tab, click 'New'.
Make the following settings in 'Edit Action' and click 'OK'.
Action: Start a program
Program/script: powershell.exe
Add arguments:-ExecutionPolicy Bypass -File "C:\Users\<.ps1 file path>\RunMagicPod.ps1"
The setup for periodic execution has been completed.
If the batch test execution does not go as expected, please check the settings in the 'Conditions' tab and 'Settings' tab of the Task Scheduler, as well as the Security options in the 'General' tab.
If you want to stop the periodic execution, please delete the target trigger in the 'Triggers' tab.