Skip to content

Commit

Permalink
System test
Browse files Browse the repository at this point in the history
  • Loading branch information
jherbel committed Nov 30, 2023
1 parent 9986e64 commit c176440
Show file tree
Hide file tree
Showing 11 changed files with 395 additions and 14 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/system_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: "System tests"

on: [push]

jobs:
rcc:
uses: ./.github/workflows/rcc.yaml

setup:
runs-on: windows-latest
needs:
- rcc
steps:
- uses: actions/download-artifact@v3
with:
path: C:\rcc
- uses: actions/checkout@v4
- uses: actions-rust-lang/[email protected]
with:
target: x86_64-pc-windows-gnu
- run: cargo test --target=x86_64-pc-windows-gnu --test test_scheduler -- --nocapture
working-directory: ${{ github.workspace }}/v2/robotmk/
env:
TEST_DIR: C:\test_scheduler
RCC_BINARY_PATH: C:\rcc\windows64\rcc.exe
6 changes: 3 additions & 3 deletions ci
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ main() {
cargo clippy --manifest-path "${cargo_toml_path}" --all-targets --target "${target}" -- --deny warnings
;;

'cargo-test')
cargo test --manifest-path "${cargo_toml_path}" --all-targets --target "${target}"
'cargo-test-unit')
cargo test --manifest-path "${cargo_toml_path}" --all-targets --target "${target}" -- --skip test_scheduler
;;

'check-all')
exit_code=0
for rust_step in fmt-check clippy test
for rust_step in fmt-check clippy test-unit
do
"${self}" "cargo-${rust_step}"
exit_code=$(( exit_code + $? ))
Expand Down
91 changes: 91 additions & 0 deletions v2/robotmk/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions v2/robotmk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ tokio = { version = "1.33.0", features = ["full"] }
tokio-util = { version = "0.7.10", features = ["full"] }
walkdir = "2.4.0"

[dev-dependencies]
assert_cmd = "2.0.12"

[[bin]]
name = "robotmk_agent"
path = "src/bin/agent.rs"
Expand Down
22 changes: 11 additions & 11 deletions v2/robotmk/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::section::Host;
use anyhow::Result;
use camino::{Utf8Path, Utf8PathBuf};
use serde::Deserialize;
use serde::{Deserialize, Serialize};
use serde_json::from_str;
use std::collections::HashMap;
use std::fs::read_to_string;
Expand All @@ -10,15 +10,15 @@ pub fn load(path: &Utf8Path) -> Result<Config> {
Ok(from_str(&read_to_string(path)?)?)
}

#[derive(Clone, Debug, Deserialize, PartialEq)]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct Config {
pub working_directory: Utf8PathBuf,
pub results_directory: Utf8PathBuf,
pub rcc_binary_path: Utf8PathBuf,
pub suites: HashMap<String, SuiteConfig>,
}

#[derive(Clone, Debug, Deserialize, PartialEq)]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct SuiteConfig {
pub robot_framework_config: RobotFrameworkConfig,
pub execution_config: ExecutionConfig,
Expand All @@ -28,51 +28,51 @@ pub struct SuiteConfig {
pub host: Host,
}

#[derive(Clone, Debug, Deserialize, PartialEq)]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct RobotFrameworkConfig {
pub robot_target: Utf8PathBuf,
pub command_line_args: Vec<String>,
}

#[derive(Clone, Debug, Deserialize, PartialEq)]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct ExecutionConfig {
pub n_attempts_max: usize,
pub retry_strategy: RetryStrategy,
pub execution_interval_seconds: u32,
pub timeout: u64,
}

#[derive(Clone, Debug, Deserialize, PartialEq)]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub enum RetryStrategy {
Incremental,
Complete,
}

#[derive(Clone, Debug, Deserialize, PartialEq)]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub enum EnvironmentConfig {
System,
Rcc(RCCEnvironmentConfig),
}

#[derive(Clone, Debug, Deserialize, PartialEq)]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct RCCEnvironmentConfig {
pub robot_yaml_path: Utf8PathBuf,
pub build_timeout: u64,
pub env_json_path: Option<Utf8PathBuf>,
}

#[derive(Clone, Debug, Deserialize, PartialEq)]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub enum SessionConfig {
Current,
SpecificUser(UserSessionConfig),
}

#[derive(Clone, Debug, Deserialize, PartialEq)]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub struct UserSessionConfig {
pub user_name: String,
}

#[derive(Clone, Debug, Deserialize, PartialEq)]
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub enum WorkingDirectoryCleanupConfig {
MaxAgeSecs(u64),
MaxExecutions(usize),
Expand Down
1 change: 1 addition & 0 deletions v2/robotmk/tests/minimal_suite/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tmp/
8 changes: 8 additions & 0 deletions v2/robotmk/tests/minimal_suite/conda.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
channels:
- conda-forge

dependencies:
- python=3.11.6
- pip=23.3.1
- pip:
- rpaframework==27.7.0
10 changes: 10 additions & 0 deletions v2/robotmk/tests/minimal_suite/lib/add.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
def setup() -> None:
print("Setting up...")


def teardown() -> None:
print("Tearing down...")


def add(left: int, right: int) -> int:
return left + right
12 changes: 12 additions & 0 deletions v2/robotmk/tests/minimal_suite/robot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
tasks:
execute:
command:
- python
- --version

condaConfigFile: conda.yaml
artifactsDir: /tmp/outputdir # Leading slash is ignored, instead we get $(pwd)/tmp/outputdir/
PATH:
- .
PYTHONPATH:
- .
21 changes: 21 additions & 0 deletions v2/robotmk/tests/minimal_suite/tasks.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
*** Settings ***
Documentation Test file for configuring RobotFramework
Library ${CURDIR}/lib/add.py WITH NAME math

Suite Setup math.setup
Suite Teardown math.teardown


*** Test Cases ***
Addition One
${result}= math.add ${20} ${5}
Should Be Equal As Integers ${result} ${25}

Addition Two
${result}= math.add ${20} ${15}
Should Be Equal As Integers ${result} ${35}

Addition Three
${result}= math.add ${20} ${25}
Should Be Equal As Integers ${result} ${45}
Loading

0 comments on commit c176440

Please sign in to comment.