mirror of
https://codeberg.org/icewind/haze.git
synced 2026-06-03 17:14:08 +02:00
test running
This commit is contained in:
parent
4ad207f58d
commit
c2f85e009e
5 changed files with 135 additions and 14 deletions
76
Cargo.lock
generated
76
Cargo.lock
generated
|
|
@ -269,6 +269,15 @@ version = "1.6.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
|
checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "encoding_rs"
|
||||||
|
version = "0.8.28"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "80df024fbc5ac80f87dfef0d9f5209a252f2a497f7f42944cff24d8253cac065"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "eyre"
|
name = "eyre"
|
||||||
version = "0.6.5"
|
version = "0.6.5"
|
||||||
|
|
@ -405,6 +414,7 @@ dependencies = [
|
||||||
"opener",
|
"opener",
|
||||||
"parse-display",
|
"parse-display",
|
||||||
"petname",
|
"petname",
|
||||||
|
"reqwest",
|
||||||
"serde",
|
"serde",
|
||||||
"termion",
|
"termion",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
|
@ -529,6 +539,12 @@ dependencies = [
|
||||||
"hashbrown",
|
"hashbrown",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ipnet"
|
||||||
|
version = "2.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "47be2f14c678be2fdcab04ab1171db51b2762ce6f0a8ee87c8dd4a04ed216135"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itertools"
|
name = "itertools"
|
||||||
version = "0.9.0"
|
version = "0.9.0"
|
||||||
|
|
@ -592,6 +608,12 @@ version = "2.3.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525"
|
checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mime"
|
||||||
|
version = "0.3.16"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "miniz_oxide"
|
name = "miniz_oxide"
|
||||||
version = "0.4.4"
|
version = "0.4.4"
|
||||||
|
|
@ -891,6 +913,37 @@ version = "0.6.23"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548"
|
checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "reqwest"
|
||||||
|
version = "0.11.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bf12057f289428dbf5c591c74bf10392e4a8003f993405a902f20117019022d4"
|
||||||
|
dependencies = [
|
||||||
|
"base64",
|
||||||
|
"bytes",
|
||||||
|
"encoding_rs",
|
||||||
|
"futures-core",
|
||||||
|
"futures-util",
|
||||||
|
"http",
|
||||||
|
"http-body",
|
||||||
|
"hyper",
|
||||||
|
"ipnet",
|
||||||
|
"js-sys",
|
||||||
|
"lazy_static",
|
||||||
|
"log",
|
||||||
|
"mime",
|
||||||
|
"percent-encoding",
|
||||||
|
"pin-project-lite",
|
||||||
|
"serde",
|
||||||
|
"serde_urlencoded",
|
||||||
|
"tokio",
|
||||||
|
"url",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"wasm-bindgen-futures",
|
||||||
|
"web-sys",
|
||||||
|
"winreg",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ring"
|
name = "ring"
|
||||||
version = "0.16.20"
|
version = "0.16.20"
|
||||||
|
|
@ -1303,6 +1356,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7ee1280240b7c461d6a0071313e08f34a60b0365f14260362e5a2b17d1d31aa7"
|
checksum = "7ee1280240b7c461d6a0071313e08f34a60b0365f14260362e5a2b17d1d31aa7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
"wasm-bindgen-macro",
|
"wasm-bindgen-macro",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -1321,6 +1376,18 @@ dependencies = [
|
||||||
"wasm-bindgen-shared",
|
"wasm-bindgen-shared",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-futures"
|
||||||
|
version = "0.4.21"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8e67a5806118af01f0d9045915676b22aaebecf4178ae7021bc171dab0b897ab"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"js-sys",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"web-sys",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-macro"
|
name = "wasm-bindgen-macro"
|
||||||
version = "0.2.71"
|
version = "0.2.71"
|
||||||
|
|
@ -1381,3 +1448,12 @@ name = "winapi-x86_64-pc-windows-gnu"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winreg"
|
||||||
|
version = "0.7.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69"
|
||||||
|
dependencies = [
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ toml = "0.5"
|
||||||
directories-next = "1"
|
directories-next = "1"
|
||||||
serde = "1"
|
serde = "1"
|
||||||
petname = "1"
|
petname = "1"
|
||||||
|
reqwest = { version = "0.11", default-features = false }
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
lto = true
|
lto = true
|
||||||
|
|
@ -2,13 +2,4 @@
|
||||||
|
|
||||||
cd $WEBROOT
|
cd $WEBROOT
|
||||||
|
|
||||||
# we need write permissions for these
|
phpunit --configuration $WEBROOT/tests/phpunit-autotest.xml $@
|
||||||
chmod 0777 tests/apps
|
|
||||||
mkdir -p $WEBROOT/apps/namespacetestapp
|
|
||||||
chmod 0777 $WEBROOT/apps/namespacetestapp
|
|
||||||
chmod 0777 tests/data
|
|
||||||
chown www-data /var/www/html/tests/.phpunit.result.cache
|
|
||||||
|
|
||||||
command="cd $WEBROOT; phpunit --configuration $WEBROOT/tests/phpunit-autotest.xml $@"
|
|
||||||
|
|
||||||
su - www-data -s /bin/sh -c "$command"
|
|
||||||
|
|
|
||||||
34
src/cloud.rs
34
src/cloud.rs
|
|
@ -10,6 +10,7 @@ use camino::{Utf8Path, Utf8PathBuf};
|
||||||
use color_eyre::{eyre::WrapErr, Report, Result};
|
use color_eyre::{eyre::WrapErr, Report, Result};
|
||||||
use futures_util::stream::StreamExt;
|
use futures_util::stream::StreamExt;
|
||||||
use petname::petname;
|
use petname::petname;
|
||||||
|
use reqwest::{Client, Url};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
@ -19,7 +20,7 @@ use std::os::unix::fs::MetadataExt;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use tokio::fs::{create_dir_all, remove_dir_all, write};
|
use tokio::fs::{create_dir_all, remove_dir_all, write};
|
||||||
use tokio::time::sleep;
|
use tokio::time::{sleep, timeout};
|
||||||
|
|
||||||
#[derive(Clone, Default, Debug, Eq, PartialEq)]
|
#[derive(Clone, Default, Debug, Eq, PartialEq)]
|
||||||
pub struct CloudOptions {
|
pub struct CloudOptions {
|
||||||
|
|
@ -143,6 +144,7 @@ impl Cloud {
|
||||||
"PHP_IDE_CONFIG=serverName=haze".to_string(),
|
"PHP_IDE_CONFIG=serverName=haze".to_string(),
|
||||||
format!("UID={}", uid),
|
format!("UID={}", uid),
|
||||||
format!("GID={}", gid),
|
format!("GID={}", gid),
|
||||||
|
format!("SQL={}", options.db.name()),
|
||||||
];
|
];
|
||||||
let volumes = vec![
|
let volumes = vec![
|
||||||
format!("{}:/var/www/html", config.sources_root),
|
format!("{}:/var/www/html", config.sources_root),
|
||||||
|
|
@ -286,7 +288,7 @@ impl Cloud {
|
||||||
Ok(logs)
|
Ok(logs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn exec(&self, docker: &mut Docker, cmd: Vec<String>) -> Result<()> {
|
pub async fn exec<S: Into<String>>(&self, docker: &mut Docker, cmd: Vec<S>) -> Result<()> {
|
||||||
exec_tty(docker, &self.id, "haze", cmd, vec![]).await
|
exec_tty(docker, &self.id, "haze", cmd, vec![]).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -369,6 +371,34 @@ impl Cloud {
|
||||||
.next()
|
.next()
|
||||||
.ok_or(Report::msg("No clouds running matching filter"))
|
.ok_or(Report::msg("No clouds running matching filter"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn wait_for_start(&self) -> Result<()> {
|
||||||
|
let client = Client::new();
|
||||||
|
let url = Url::parse(&format!(
|
||||||
|
"http://{}/status.php",
|
||||||
|
self.ip.ok_or(Report::msg("Container not running"))?
|
||||||
|
))?;
|
||||||
|
timeout(Duration::from_secs(5), async {
|
||||||
|
while !client.get(url.clone()).send().await.is_ok() {
|
||||||
|
sleep(Duration::from_millis(100)).await
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.wrap_err("Timeout after 5 seconds")
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn enable_app<S: Into<String>>(&self, docker: &mut Docker, app: S) -> Result<()> {
|
||||||
|
self.exec(
|
||||||
|
docker,
|
||||||
|
vec![
|
||||||
|
"occ".to_string(),
|
||||||
|
"app:enable".to_string(),
|
||||||
|
app.into(),
|
||||||
|
"--force".to_string(),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn setup_workdir(base: &Utf8Path, id: &str) -> Result<Utf8PathBuf> {
|
async fn setup_workdir(base: &Utf8Path, id: &str) -> Result<Utf8PathBuf> {
|
||||||
|
|
|
||||||
27
src/main.rs
27
src/main.rs
|
|
@ -96,8 +96,31 @@ async fn main() -> Result<()> {
|
||||||
None => eprintln!("{} is not running", cloud.id),
|
None => eprintln!("{} is not running", cloud.id),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HazeArgs::Test { .. } => {
|
HazeArgs::Test { options, path } => {
|
||||||
todo!();
|
let cloud = Cloud::create(&mut docker, options, &config).await?;
|
||||||
|
cloud.wait_for_start().await?;
|
||||||
|
println!("Installing");
|
||||||
|
cloud
|
||||||
|
.exec(&mut docker, vec!["install", "admin", "admin"])
|
||||||
|
.await?;
|
||||||
|
if let Some(app) = path
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|path| path.strip_prefix("apps/"))
|
||||||
|
.map(|path| &path[0..path.find('/').unwrap_or(path.len())])
|
||||||
|
{
|
||||||
|
if app.starts_with("files_") {
|
||||||
|
cloud.enable_app(&mut docker, "files_external").await?;
|
||||||
|
}
|
||||||
|
println!("Enabling {}", app);
|
||||||
|
cloud.enable_app(&mut docker, app).await?;
|
||||||
|
}
|
||||||
|
cloud
|
||||||
|
.exec(
|
||||||
|
&mut docker,
|
||||||
|
vec!["tests".to_string(), path.unwrap_or_default()],
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
cloud.destroy(&mut docker).await?;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue