Radish alpha
r
Radicle CI broker
Radicle
Git (anonymous pull)
Log in to clone via SSH
chore: drop unused scenario step implementations
Lars Wirzenius committed 1 year ago
commit d7428e5f94f9b3ad4b56b08e27a1b3bb462790c8
parent a1ff0a41b72dcfd261f626d4349331eac384127d
3 files changed +24 -150
modified ci-broker.md
@@ -619,23 +619,19 @@ in a node change.
_Who:_ `cib-devs`

~~~scenario
-
given an installed CI broker
-
given file radenv.sh
-
given file setup-node.sh
-
when I run bash radenv.sh bash setup-node.sh
-

-
given file refsfetched.json
-
when I run synthetic-events synt.sock refsfetched.json --log synt.log
+
given a Radicle node, with CI configured with broker.yaml and adapter dummy.sh
+
given a Git repository xyzzy in the Radicle node
+
given the Radicle node emits a refsUpdated event for xyzzy
+
when I run ./env.sh synthetic-events synt.sock event.json --log log.txt

-
given file broker.yaml
-
when I try to run bash radenv.sh env RAD_SOCKET=synt.sock cib --config broker.yaml insert
+
when I try to run ./env.sh env cib --config broker.yaml insert
then command is successful

when I run cibtool --db ci-broker.db event list --json
then stdout contains "BranchUpdated"
then stdout contains ""branch": "main""
-
then stdout contains ""tip": "0000000000000000000000000000000000000000""
-
then stdout contains ""old_tip": "0000000000000000000000000000000000000000""
+
then stdout contains ""tip":"
+
then stdout contains ""old_tip":"
~~~

## Insert many events into queue
@@ -646,19 +642,17 @@ _Why:_ We need at least some rudimentary performance testing.

_Who:_ `cib-devs`

-
~~~scenario
-
given an installed CI broker
-
given file radenv.sh
-
given file setup-node.sh
-
when I run bash radenv.sh bash setup-node.sh

-
given file refsfetched.json
when I run synthetic-events synt.sock refsfetched.json --log synt.log --repeat 1000

-
given file broker.yaml
-
when I try to run bash radenv.sh env RAD_SOCKET=synt.sock cib --config broker.yaml insert
-
then command is successful
+
~~~scenario
+
given a Radicle node, with CI configured with broker.yaml and adapter dummy.sh
+
given a Git repository xyzzy in the Radicle node
+
given the Radicle node emits a refsUpdated event for xyzzy
+
when I run ./env.sh synthetic-events synt.sock event.json --log log.txt --repeat 1000

+
when I try to run ./env.sh env RAD_SOCKET=synt.sock cib --config broker.yaml insert
+
then command is successful

when I run cibtool --db ci-broker.db event count
then stdout is exactly "1000\n"
@@ -675,16 +669,12 @@ in a node change.
_Who:_ `cib-devs`

~~~scenario
-
given an installed CI broker
-
given file radenv.sh
-
given file setup-node.sh
-
when I run bash radenv.sh bash setup-node.sh
-

-
given file refsfetched.json
-
when I run synthetic-events synt.sock refsfetched.json --log synt.log
+
given a Radicle node, with CI configured with broker-allow-nothing.yaml and adapter dummy.sh
+
given a Git repository xyzzy in the Radicle node
+
given the Radicle node emits a refsUpdated event for xyzzy
+
when I run ./env.sh synthetic-events synt.sock event.json --log log.txt

-
given file broker.yaml from broker-allow-nothing.yaml
-
when I try to run bash radenv.sh env RAD_SOCKET=synt.sock cib --config broker.yaml insert
+
when I try to run ./env.sh env RAD_SOCKET=synt.sock cib --config broker-allow-nothing.yaml insert
then command is successful

when I run cibtool --db ci-broker.db event count
@@ -707,20 +697,14 @@ events. We carefully add a shutdown event so that the CI broker shuts
down.

~~~scenario
-
given an installed CI broker
-
given a CI adapter adapter.sh from dummy.sh
-

-
given file radenv.sh
-
given file setup-node.sh
-
when I run bash radenv.sh bash setup-node.sh
+
given a Radicle node, with CI configured with broker.yaml and adapter dummy.sh
+
given a Git repository testy in the Radicle node

-
when I run bash radenv.sh cibtool --db ci-broker.db event add --repo testy --ref main --commit HEAD
+
when I run ./env.sh cibtool --db ci-broker.db event add --repo testy --ref main --commit HEAD
when I run cibtool --db ci-broker.db event shutdown

-
given file broker.yaml
given a directory reports
-
when I run ls -l adapter.sh
-
when I run bash radenv.sh cib --config broker.yaml queued
+
when I run ./env.sh cib --config broker.yaml queued
then stderr contains "Action: run:"
then stderr contains "Action: shutdown"

modified ci-broker.yaml
@@ -20,31 +20,6 @@
    rust:
      function: add_event_file

-
- given: "a running Radicle node"
-
  impl:
-
    rust:
-
      function: start_node
-

-
- given: "a CI adapter {filename:path} from {embedded:file}"
-
  impl:
-
    rust:
-
      function: install_adapter
-

-
- when: "I run, with the Radicle node, in {dirname}, {argv0}{args}"
-
  types:
-
    dirname: path
-
    argv0: word
-
    args: text
-
  impl:
-
    rust:
-
      function:
-
        run_command_with_node
-

-
- given: "an installed CI broker"
-
  impl:
-
    rust:
-
      function: install_ci_broker
-

- then: "stdout has one line"
  impl:
    rust:
modified src/subplot.rs
@@ -1,7 +1,7 @@
// Implementations of Subplot scenario steps for the CI broker.

use std::{
-
    fs::{metadata, set_permissions, Permissions},
+
    fs::{metadata, set_permissions},
    io::Write,
    os::unix::fs::PermissionsExt,
    path::{Path, PathBuf},
@@ -18,7 +18,6 @@ use radicle::{
use radicle_git_ext::Oid;

use subplotlib::steplibrary::datadir::Datadir;
-
use subplotlib::steplibrary::files::Files;
use subplotlib::steplibrary::runcmd::Runcmd;

#[derive(Debug, Default)]
@@ -179,14 +178,6 @@ exec "$@"
#[context(SubplotContext)]
#[context(Datadir)]
#[context(Runcmd)]
-
fn start_node(_context: &ScenarioContext, _config: SubplotDataFile, _adapter: SubplotDataFile) {
-
    unimplemented!();
-
}
-

-
#[step]
-
#[context(SubplotContext)]
-
#[context(Datadir)]
-
#[context(Runcmd)]
fn create_repo(context: &ScenarioContext, name: &str) {
    // Create a Git repository and add it to the Radicle node.
    context.with_mut(
@@ -252,42 +243,6 @@ fn create_repo(context: &ScenarioContext, name: &str) {
        false,
    )?;
}
-
#[step]
-
#[context(SubplotContext)]
-
#[context(Datadir)]
-
#[context(Runcmd)]
-
fn run_command_with_node(context: &ScenarioContext, dirname: &Path, argv0: &str, args: &str) {
-
    let path: String = context.with_mut(
-
        |context: &mut Runcmd| Ok(context.join_paths().unwrap().to_string_lossy().to_string()),
-
        false,
-
    )?;
-
    println!("run_command_with_node: PATH={path}");
-

-
    context.with_mut(
-
        |context: &mut Datadir| {
-
            let home = context.canonicalise_filename(".")?;
-
            let home_str = home.display().to_string();
-

-
            let rad_home = context.canonicalise_filename(".radicle")?;
-
            let rad_home_str = rad_home.display().to_string();
-

-
            let envs = &[
-
                ("HOME", home_str.as_str()),
-
                ("RAD_HOME", rad_home_str.as_str()),
-
                ("RAD_PASSPHRASE", "secret"),
-
                ("RAD_SOCKET", "synt.sock"),
-
                ("PATH", path.as_str()),
-
            ];
-

-
            let dirname = context.canonicalise_filename(dirname)?;
-
            let words: Vec<&str> = args.split_ascii_whitespace().collect();
-
            run_in(argv0, &words, envs, &dirname)?;
-

-
            Ok(())
-
        },
-
        false,
-
    )?;
-
}

fn rad_in(args: &[&str], envs: &[(&str, &str)], cwd: &Path) -> Result<(), std::io::Error> {
    run_in("rad", args, envs, cwd)
@@ -421,23 +376,6 @@ fn head(rad_home: &Path, repo: &Path) -> Result<Oid, Box<dyn std::error::Error>>
    )?)
}

-
#[step]
-
#[context(SubplotContext)]
-
#[context(Runcmd)]
-
fn install_ci_broker(context: &ScenarioContext) {
-
    let target_path = bindir();
-
    assert!(target_path.join("cib").exists());
-
    assert!(target_path.join("cibtool").exists());
-
    assert!(target_path.join("synthetic-events").exists());
-
    context.with_mut(
-
        |context: &mut Runcmd| {
-
            context.prepend_to_path(target_path);
-
            Ok(())
-
        },
-
        false,
-
    )?;
-
}
-

fn bindir() -> PathBuf {
    let path = if let Ok(target) = std::env::var("CARGO_TARGET_DIR") {
        Path::new(&target).join("debug")
@@ -449,29 +387,6 @@ fn bindir() -> PathBuf {

#[step]
#[context(SubplotContext)]
-
#[context(Datadir)]
-
#[context(Files)]
-
fn install_adapter(context: &Datadir, filename: &Path, embedded: SubplotDataFile) {
-
    eprintln!(
-
        "install adapter {} from {}:\n{}",
-
        filename.display(),
-
        embedded.name().display(),
-
        String::from_utf8_lossy(embedded.data()),
-
    );
-
    eprintln!("write {}", filename.display());
-
    context.open_write(filename)?.write_all(embedded.data())?;
-
    let realpath = context.canonicalise_filename(filename)?;
-
    eprintln!(
-
        "chmod {} (exists? {})",
-
        realpath.display(),
-
        realpath.exists()
-
    );
-
    let executable = Permissions::from_mode(0o755);
-
    set_permissions(realpath, executable)?;
-
}
-

-
#[step]
-
#[context(SubplotContext)]
#[context(Runcmd)]
fn stdout_has_one_line(runcmd: &Runcmd) {
    let linecount = runcmd.stdout_as_string().lines().count();