Implement example control loop

This commit is contained in:
Patrick Lühne 2018-09-26 01:17:50 +02:00
parent 094cb5a3bb
commit 7c4bf22356
Signed by: patrick
GPG Key ID: 05F3611E97A70ABF
4 changed files with 37 additions and 9 deletions

View File

@ -8,6 +8,7 @@ git2 = "^0.7"
log = "0.4" log = "0.4"
pretty_env_logger = "0.2" pretty_env_logger = "0.2"
indicatif = "0.9" indicatif = "0.9"
yaml-rust = "0.4"
[dependencies.cpython] [dependencies.cpython]
git = "https://github.com/dgrunwald/rust-cpython/" git = "https://github.com/dgrunwald/rust-cpython/"

View File

@ -1,10 +1,12 @@
extern crate benchmark_repository; extern crate benchmark_repository;
extern crate pretty_env_logger; extern crate pretty_env_logger;
extern crate yaml_rust;
use benchmark_repository::{BenchmarkRepository, TargetPath}; use benchmark_repository::{BenchmarkRepository, TargetPath};
use std::io::{self, copy}; use std::io::{self, copy, Read};
use std::path::Path; use std::path::Path;
use yaml_rust::{YamlLoader, YamlEmitter};
fn main() fn main()
{ {
@ -20,7 +22,26 @@ fn main()
benchmark_repository.commit_files(&files[..], "test-results");*/ benchmark_repository.commit_files(&files[..], "test-results");*/
let mut file = benchmark_repository.read_file(Path::new("configurations.yml"), "test-config").unwrap(); let content = benchmark_repository.read_file(Path::new("configurations.yml"), "test-config").unwrap();
let configurations = &YamlLoader::load_from_str(&content).unwrap()[0]["configurations"];
copy(&mut file, &mut io::stdout()); let content = benchmark_repository.read_file(Path::new("instances.yml"), "test-config").unwrap();
let instances = &YamlLoader::load_from_str(&content).unwrap()[0];
for configuration in configurations.as_vec().unwrap()
{
for (instance_set_id, instance_set) in instances.as_hash().unwrap()
{
for instance in instance_set.as_vec().unwrap()
{
let configuration_id = configuration["id"].as_str().unwrap();
let instance_set_id = instance_set_id.as_str().unwrap();
let instance_ipc = instance["ipc"].as_str().unwrap();
let instance_domain = instance["domain"].as_str().unwrap();
let instance_number = instance["instance"].as_i64().unwrap();
println!("[{}, {}, {}/{}/{}]", configuration_id, instance_set_id, instance_ipc, instance_domain, instance_number);
}
}
}
} }

View File

@ -328,7 +328,7 @@ impl BenchmarkRepository
remote.push(&[&push_refspec], Some(&mut push_options)).expect("couldnt push"); remote.push(&[&push_refspec], Some(&mut push_options)).expect("couldnt push");
} }
pub fn read_file(&self, file_path: &Path, branch_name: &str) -> Option<Cursor<Vec<u8>>> pub fn read_file(&self, file_path: &Path, branch_name: &str) -> Option<String>
{ {
let tip_reference_name = format!("refs/remotes/origin/{}", branch_name); let tip_reference_name = format!("refs/remotes/origin/{}", branch_name);
let tip_reference = match self.repository.find_reference(&tip_reference_name) let tip_reference = match self.repository.find_reference(&tip_reference_name)
@ -355,7 +355,13 @@ impl BenchmarkRepository
Err(error) => return None, Err(error) => return None,
}; };
Some(Cursor::new(blob.content().to_owned())) let content = match std::str::from_utf8(blob.content())
{
Ok(content) => content,
Err(error) => panic!("Could not interpret file “{}” as UTF-8: {}", file_path.display(), error),
};
Some(content.to_owned())
} }
} }

View File

@ -2,7 +2,7 @@ repository:
# local directory where remote is cloned to # local directory where remote is cloned to
basePath: storage basePath: storage
# repote Git repository URL # repote Git repository URL
remote: git@git.luehne.de:patrick/tplp-planning-benchmark.git remote: git@git.luehne.de:patrick/benchmark-template.git
# user name of the SSH key pair with access to the remote # user name of the SSH key pair with access to the remote
remoteUser: git remoteUser: git
# user name for commits # user name for commits
@ -14,8 +14,8 @@ repository:
# data branches # data branches
branches: branches:
master: master master: master
results: new-results results: results
config: new-config config: config
status: new-status status: status
# the maximum size of the status log in lines # the maximum size of the status log in lines
statusLogSize: 100 statusLogSize: 100