6 Commits

Author SHA1 Message Date
11dbe7d4f0 Merge branch 'wip2' into multi-docker 2023-12-02 14:53:02 +11:00
b4f81ccf30 chore: remove tmp file from git index 2023-12-02 14:45:01 +11:00
64fa76d39b add: log test helper 2023-12-02 14:04:58 +11:00
342ac49bea add: test helper binaries 2023-12-01 22:33:52 +00:00
d26cc87713 wip: using different versions of rust images 2023-12-02 09:11:12 +11:00
212ae4847a wip: rearrange docker directory 2023-12-02 09:09:02 +11:00
24 changed files with 115 additions and 11 deletions

View File

@@ -1,8 +1,8 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/debian
{
"name": "Alpine Dev",
"image": "alpine-dev:user",
"name": "Ubuntu Dev",
"image": "ubuntu-dev:user",
"customizations": {
"vscode": {
"extensions": [

1
.gitignore vendored
View File

@@ -1 +1,2 @@
/target
/coba.txt

View File

@@ -5,6 +5,19 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[[bin]]
name = "wmtest-helper-dummy"
path = "src/bin/test-helper/dummy.rs"
[[bin]]
name = "wmtest-helper-spawner"
path = "src/bin/test-helper/spawner.rs"
[[bin]]
name = "wmtest-helper-log"
path = "src/bin/test-helper/log.rs"
[dependencies]
anyhow = "1.0.75"
lazy_static = "1.4.0"

13
docker/alpine/Dockerfile Normal file
View File

@@ -0,0 +1,13 @@
FROM rust:alpine as builder
FROM alpine
COPY --from=builder target/debug/init /usr/local/bin/init
ADD docker/etc/ /etc/
RUN chmod ugo+x /etc/wingmate/services/one && chmod ugo+x /etc/wingmate/services/two.sh && \
chmod ugo-x /etc/wingmate/services/three.sh
CMD [ "/usr/local/bin/init" ]

View File

@@ -0,0 +1,3 @@
17 * * * * sleep 1
*/12 * * * * sleep 1
12,17,27 * * * * sleep 1

View File

@@ -0,0 +1 @@
you cannot run this file

View File

@@ -0,0 +1,3 @@
#!/bin/bash
exec sleep 1

View File

@@ -0,0 +1,3 @@
#!/bin/bash
exec sleep 1

9
docker/dev/Dockerfile Normal file
View File

@@ -0,0 +1,9 @@
FROM ubuntu:22.04
ADD target/debug/init /usr/local/bin/init
ADD docker/etc/ /etc/
RUN chmod ugo+x /etc/wingmate/services/one && chmod ugo+x /etc/wingmate/services/two.sh && \
chmod ugo-x /etc/wingmate/services/three.sh
CMD [ "/usr/local/bin/init" ]

View File

@@ -0,0 +1,3 @@
17 * * * * sleep 1
*/12 * * * * sleep 1
12,17,27 * * * * sleep 1

View File

@@ -0,0 +1 @@
you cannot run this file

View File

@@ -0,0 +1,3 @@
#!/bin/bash
exec sleep 1

View File

@@ -0,0 +1,3 @@
#!/bin/bash
exec sleep 1

View File

@@ -0,0 +1,15 @@
use std::{env, thread, time};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let myi: u64;
let args: Vec<String> = env::args().collect();
if args.len() > 1 {
myi = args[1].parse().unwrap();
thread::sleep(time::Duration::from_secs(myi));
} else {
return Err(anyhow::anyhow!("invalid arguments").into());
}
Ok(())
}

View File

@@ -0,0 +1,19 @@
use std::env;
use std::fs;
use std::io;
use std::io::Write;
use time::OffsetDateTime;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let args: Vec<String> = env::args().collect();
if args.len() == 3 {
let file = fs::OpenOptions::new().create(true).append(true).open(&args[1])?;
let mut buf = io::BufWriter::new(file);
let local_time = OffsetDateTime::now_local()?;
buf.write_all(format!("{} {}\n", local_time, &args[2]).as_bytes())?;
} else {
return Err(anyhow::anyhow!("invalid argument").into());
}
Ok(())
}

View File

@@ -0,0 +1,17 @@
use std::error::Error;
use std::process::Command;
use std::env;
fn main() -> Result<(), Box<dyn Error>> {
let args: Vec<String> = env::args().collect();
if args.len() > 1 {
let x: u64 = args[1].parse()?;
for _i in 0..x {
// println!("spawning {}", _i);
Command::new("/usr/local/bin/dummy").arg("10").spawn()?;
}
} else {
return Err(anyhow::anyhow!("invalid arguments").into());
}
Ok(())
}

View File

@@ -75,14 +75,11 @@ pub enum CronConfigError {
#[error("setting day of week and day of month at the same time will lead to unexpected behavior")]
ClashingConfig,
#[error("when setting time for higher order, the smallest (minute) muste be set")]
MissingMinute,
#[error("something went wrong")]
Other {
#[source]
source: anyhow::Error,
}
// #[error("something went wrong")]
// Other {
// #[source]
// source: anyhow::Error,
// }
}
#[derive(Error,Debug)]

View File

@@ -1,6 +1,6 @@
mod init;
use std::error;
use wingmate_rs::init;
#[tokio::main]
async fn main() -> Result<(), Box<dyn error::Error>> {