feat: rewrite google-metadata test as tdx-test

Signed-off-by: Harald Hoyer <harald@matterlabs.dev>
This commit is contained in:
Harald Hoyer 2025-02-13 15:47:36 +01:00
parent 3325312c0d
commit 908579cd60
Signed by: harald
GPG key ID: F519A1143B3FBE32
12 changed files with 771 additions and 251 deletions

16
bin/tdx-test/Cargo.toml Normal file
View file

@ -0,0 +1,16 @@
[package]
name = "tdx-test"
version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true
repository.workspace = true
homepage.workspace = true
[dependencies]
anyhow.workspace = true
serde.workspace = true
teepot.workspace = true
thiserror.workspace = true
tokio.workspace = true
tracing.workspace = true

59
bin/tdx-test/src/main.rs Normal file
View file

@ -0,0 +1,59 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (c) 2025 Matter Labs
use anyhow::Result;
use serde::{Deserialize, Serialize};
use teepot::config::{load_config_with_telemetry, TelemetryConfig};
use thiserror::Error;
use tracing::{debug, error, info, trace, warn};
// Configuration struct
#[derive(Debug, Serialize, Deserialize)]
struct AppConfig {
server: ServerConfig,
telemetry: TelemetryConfig,
}
impl Default for AppConfig {
fn default() -> Self {
Self {
server: ServerConfig::default(),
telemetry: TelemetryConfig::new(
env!("CARGO_CRATE_NAME").into(),
env!("CARGO_PKG_VERSION").into(),
),
}
}
}
#[derive(Debug, Serialize, Deserialize)]
struct ServerConfig {
port: u16,
}
impl Default for ServerConfig {
fn default() -> Self {
Self { port: 8080 }
}
}
// Error handling
#[derive(Error, Debug)]
enum AppError {
#[error("Internal server error")]
Internal(#[from] anyhow::Error),
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let config = load_config_with_telemetry(|config: &AppConfig| &config.telemetry).await?;
loop {
error!(?config, "error test!");
warn!(?config, "warn test!");
info!(?config, "info test!");
debug!(?config, "debug test!");
trace!(?config, "trace test!");
tokio::time::sleep(std::time::Duration::from_secs(60)).await;
}
}