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

Component test for scheduler #445

Merged
merged 2 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
52 changes: 43 additions & 9 deletions .github/workflows/rcc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,64 @@
name: "RCC"

on:
workflow_call: {}
workflow_call:
{}

env:
RCC_TAG: "v14.15.4"
GO_VERSION: "1.20.x"
RUBY_VERSION: "2.7"

jobs:
build_and_test:
check_cache:
runs-on: ubuntu-latest
outputs:
cache_hit: ${{ steps.restore-from-cache.outputs.cache-hit }}
steps:
- id: restore-from-cache
uses: actions/cache/restore@v3
with:
key: rcc-${{ env.RCC_TAG }}-${{ env.GO_VERSION }}-${{ env.RUBY_VERSION }}
path: build
lookup-only: true

build_and_cache:
runs-on: ubuntu-latest
needs:
- check_cache
if: ${{ needs.check_cache.outputs.cache_hit != 'true' }}
steps:
- uses: actions/checkout@v4
with:
repository: robocorp/rcc
ref: v14.15.4

ref: ${{ env.RCC_TAG }}
- uses: actions/setup-go@v3
with:
go-version: '1.20.x'

go-version: ${{ env.GO_VERSION }}
- uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'

ruby-version: ${{ env.RUBY_VERSION }}
- run: rake build

- run: rake test
- uses: actions/cache/save@v3
with:
key: rcc-${{ env.RCC_TAG }}-${{ env.GO_VERSION }}-${{ env.RUBY_VERSION }}
path: build

upload:
runs-on: ubuntu-latest
needs:
- build_and_cache
# See https://github.com/actions/runner/issues/491 for the following condition
if: |
always() &&
(needs.build_and_cache.result == 'success' || needs.build_and_cache.result == 'skipped')
steps:
- uses: actions/cache/restore@v3
with:
path: build
key: rcc-${{ env.RCC_TAG }}-${{ env.GO_VERSION }}-${{ env.RUBY_VERSION }}
fail-on-cache-miss: true
- uses: actions/upload-artifact@v3
with:
path: build
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/system_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: "System tests"

on: [push, pull_request]

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

test_scheduler:
runs-on: windows-latest
needs:
- rcc
steps:
- uses: actions/download-artifact@v3
with:
path: C:\
- 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:\artifact\windows64\rcc.exe
RUN_FOR: 240
- uses: actions/upload-artifact@v3
with:
path: C:\test_scheduler
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- run: cargo fmt -- --check
working-directory: ${{ github.workspace }}/v2/robotmk/

- run: cargo test --all-targets --target ${{ matrix.type.target }}
- run: cargo test --all-targets --target ${{ matrix.type.target }} -- --skip test_scheduler
working-directory: ${{ github.workspace }}/v2/robotmk/

- run: cargo clippy --all-targets --target ${{ matrix.type.target }} -- --deny warnings
Expand Down
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:
- robotframework==6.1.1
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
Loading
Loading