Skip to content

Commit

Permalink
Merge pull request #4 from rylev/conformance-tests
Browse files Browse the repository at this point in the history
Local OCI Registry
  • Loading branch information
kate-goldenring authored Jun 18, 2024
2 parents 05e8a2c + 4b53164 commit 2f973d3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

28 changes: 22 additions & 6 deletions conformance-tests/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,24 @@ fn main() {

'test: for test in conformance_tests::tests(&tests_dir).unwrap() {
println!("running test: {}", test.name);
// Just using TTL.sh until we decide where to host these (local registry, ghcr, etc)
let oci_image = format!("ttl.sh/{}:72h", test.name);
let mut services = vec!["registry".into()];
for precondition in &test.config.preconditions {
match precondition {
conformance_tests::config::Precondition::HttpEcho => {
services.push("http-echo".into());
}
conformance_tests::config::Precondition::KeyValueStore(k) => {
if k.label != "default" {
panic!("unsupported label: {}", k.label);
}
}
}
}
let env_config = SpinShim::config(
ctr_binary.into(),
spin_binary.into(),
oci_image.clone(),
test_environment::services::ServicesConfig::new(test.config.services).unwrap(),
test.name.clone(),
test_environment::services::ServicesConfig::new(services).unwrap(),
);
let mut env = TestEnvironment::up(env_config, move |e| {
let mut manifest =
Expand Down Expand Up @@ -81,6 +92,12 @@ impl SpinShim {
TestEnvironmentConfig {
services_config,
create_runtime: Box::new(move |env| {
let oci_image = format!(
"localhost:{port}/{oci_image}:latest",
port = env
.get_port(5000)?
.context("environment doesn't expose port for OCI registry")?
);
SpinShim::regisry_push(&spin_binary, &oci_image, env)?;
SpinShim::image_pull(&ctr_binary, &oci_image)?;
SpinShim::start(&ctr_binary, env, &oci_image, CTR_RUN_ID)
Expand All @@ -95,7 +112,7 @@ impl SpinShim {
) -> anyhow::Result<()> {
// TODO: consider enabling configuring a port
let mut cmd = Command::new(spin_binary_path);
cmd.args(["registry", "push"]).arg(image);
cmd.args(["registry", "push", "-k"]).arg(image);
env.run_in(&mut cmd)
.context("failed to push spin app to registry with 'spin'")?;
Ok(())
Expand All @@ -113,7 +130,6 @@ impl SpinShim {
}

/// Start the Spin app using `ctr run`
/// Equivalent of `sudo ctr run --rm --net-host --runtime io.containerd.spin.v2 ttl.sh/myapp:48h ctr-run-id bogus-arg` for image `ttl.sh/myapp:48h` and run id `ctr-run-id`
pub fn start<R>(
ctr_binary_path: &Path,
env: &mut TestEnvironment<R>,
Expand Down

0 comments on commit 2f973d3

Please sign in to comment.