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

Add integration tests for life cycle #113

Merged
merged 14 commits into from
Jul 28, 2021
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
19 changes: 0 additions & 19 deletions tests/integration.rs

This file was deleted.

2 changes: 2 additions & 0 deletions youki_integration_test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target
youki_integration_test
220 changes: 220 additions & 0 deletions youki_integration_test/Cargo.lock

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

12 changes: 12 additions & 0 deletions youki_integration_test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "youki_integration_test"
version = "0.1.0"
edition = "2018"

[dependencies]
uuid = "0.8"
rand = "0.8.0"
tar = "0.4"
flate2 = "1.0"
testanything = "0.2.1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about error handling anyhow?

anyhow = "1.0"
4 changes: 3 additions & 1 deletion tests/README.md → youki_integration_test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
Here is a preview implementation of the integration test.

```
$ cargo test --test integration
$ cp ../youki .
$ ./build.sh
$ sudo ./youki_integration_test
```
14 changes: 14 additions & 0 deletions youki_integration_test/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

TARGET=${TARGET-x86_64-unknown-linux-gnu}
if [ "$TARGET" != "" ]; then
TGT="--target $TARGET"
fi
VERSION=debug
if [[ "$1" == "--release" ]]; then
VERSION=release
fi

cargo build --verbose $TGT $1
rm -f youki_integration_test
cp target/$TARGET/$VERSION/youki_integration_test .
Binary file added youki_integration_test/bundle.tar.gz
Binary file not shown.
19 changes: 19 additions & 0 deletions youki_integration_test/src/command/create.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};

// TODO Allow to receive arguments.
// TODO Wrapping up the results
pub fn exec(project_path: &Path, id: &str) -> bool {
let status = Command::new(project_path.join(PathBuf::from("youki")))
Copy link
Member

@utam0k utam0k Jul 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "youki" is too hard coding, so how about using an environment value, e.g. RUNTIME
I think the default value should be youki.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would be your thoughts on using cmd args instead of env vars? That way we user won't have to define env vars specifically for this purpose, and it might make more sense to pass those as args to the command, rather than to set them as general env vars.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@utamoku What do you think about this?
My feeling is that when comparing env vars and cmd args, env vars is basically unchanged and users are expected to use default values, while cmd args is assumed to be specified by users.
In this case, I think env vars is fine because it is basically used with youki, but cmd args may be an option if you are considering using a runtime other than youki in the future.

.stdout(Stdio::null())
.stderr(Stdio::null())
.arg("-r")
.arg(project_path.join("integration-workspace").join("youki"))
.arg("create")
.arg(id)
.arg("--bundle")
.arg(project_path.join("integration-workspace").join("bundle"))
.status()
.expect("failed to execute process");
status.success()
}
17 changes: 17 additions & 0 deletions youki_integration_test/src/command/delete.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};

// TODO Allow to receive arguments.
// TODO Wrapping up the results
pub fn exec(project_path: &Path, id: &str) -> bool {
let status = Command::new(project_path.join(PathBuf::from("youki")))
.stdout(Stdio::null())
.stderr(Stdio::null())
.arg("-r")
.arg(project_path.join("integration-workspace").join("youki"))
.arg("delete")
.arg(id)
.status()
.expect("failed to execute process");
status.success()
}
18 changes: 18 additions & 0 deletions youki_integration_test/src/command/kill.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};

// TODO Allow to receive arguments.
// TODO Wrapping up the results
pub fn exec(project_path: &Path, id: &str) -> bool {
let status = Command::new(project_path.join(PathBuf::from("youki")))
.stdout(Stdio::null())
.stderr(Stdio::null())
.arg("-r")
.arg(project_path.join("integration-workspace").join("youki"))
.arg("kill")
.arg(id)
.arg("9")
.status()
.expect("failed to execute process");
status.success()
}
6 changes: 6 additions & 0 deletions youki_integration_test/src/command/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pub mod create;
pub mod delete;
pub mod kill;
pub mod start;
pub mod state;
pub mod youki;
17 changes: 17 additions & 0 deletions youki_integration_test/src/command/start.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};

// TODO Allow to receive arguments.
// TODO Wrapping up the results
pub fn exec(project_path: &Path, id: &str) -> bool {
let status = Command::new(project_path.join(PathBuf::from("youki")))
.stdout(Stdio::null())
.stderr(Stdio::null())
.arg("-r")
.arg(project_path.join("integration-workspace").join("youki"))
.arg("start")
.arg(id)
.status()
.expect("failed to execute process");
status.success()
}
17 changes: 17 additions & 0 deletions youki_integration_test/src/command/state.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};

// TODO Allow to receive arguments.
// TODO Wrapping up the results
pub fn exec(project_path: &Path, id: &str) -> bool {
let status = Command::new(project_path.join(PathBuf::from("youki")))
.stdout(Stdio::null())
.stderr(Stdio::null())
.arg("-r")
.arg(project_path.join("integration-workspace").join("youki"))
.arg("state")
.arg(id)
.status()
.expect("failed to execute process");
status.success()
}
Loading