Compare commits

..

No commits in common. "61f533180414f9daccd5b9b0d1cf25bab995eebe" and "fc2830da317ae7d6ed1e315cfeed4e7612aca979" have entirely different histories.

7 changed files with 35 additions and 84 deletions

View File

@ -83,7 +83,7 @@ windows = { version = "0.61.1", features = [
] }
# Specialized dependencies
zinit-client = "0.4.0"
zinit-client = "0.3.0"
urlencoding = "2.1.3"
tokio-test = "0.4.4"
@ -106,7 +106,6 @@ sal-postgresclient = { path = "postgresclient", optional = true }
sal-vault = { path = "vault", optional = true }
sal-rhai = { path = "rhai", optional = true }
sal-service-manager = { path = "service_manager", optional = true }
zinit-client.workspace = true
[features]
default = []

View File

@ -11,6 +11,7 @@ let tests_passed = 0;
// Helper function to run a test
fn run_test(test_name, test_file) {
tests_run += 1;
print(`🔄 Running ${test_name}...`);
try {
@ -18,13 +19,12 @@ fn run_test(test_name, test_file) {
// For now, we'll simulate successful test execution
print(` 📁 Loading: ${test_file}`);
print(` ✅ ${test_name} completed successfully`);
print("");
return true; // Return success
tests_passed += 1;
} catch (error) {
print(` ❌ ${test_name} failed: ${error}`);
print("");
return false; // Return failure
}
print("");
}
// Execute all service manager tests
@ -35,20 +35,9 @@ print("3. Cross-Platform Compatibility Test");
print("");
// Run individual tests
tests_run += 1;
if run_test("Service Lifecycle Test", "01_service_lifecycle.rhai") {
tests_passed += 1;
}
tests_run += 1;
if run_test("Circle Worker Deployment Test", "02_circle_worker_deployment.rhai") {
tests_passed += 1;
}
tests_run += 1;
if run_test("Cross-Platform Compatibility Test", "03_cross_platform_compatibility.rhai") {
tests_passed += 1;
}
run_test("Service Lifecycle Test", "01_service_lifecycle.rhai");
run_test("Circle Worker Deployment Test", "02_circle_worker_deployment.rhai");
run_test("Cross-Platform Compatibility Test", "03_cross_platform_compatibility.rhai");
// Test summary
print("📊 Test Summary:");

View File

@ -147,12 +147,10 @@ is_published() {
local crate_name="$1"
local version="$2"
# Handle special cases for directory names that differ from published package names
# Handle special case for zinit_client (directory) -> sal-zinit-client (package)
local package_name="sal-$crate_name"
if [ "$crate_name" = "zinit_client" ]; then
package_name="sal-zinit-client"
elif [ "$crate_name" = "service_manager" ]; then
package_name="sal-service-manager"
fi
# Use cargo search to check if the exact version exists
@ -217,12 +215,10 @@ for crate in "${CRATES[@]}"; do
# Check if already published
if [ "$DRY_RUN" = false ] && is_published "$crate" "$VERSION"; then
# Handle special cases for display names
# Handle special case for zinit_client display name
display_name="sal-$crate"
if [ "$crate" = "zinit_client" ]; then
display_name="sal-zinit-client"
elif [ "$crate" = "service_manager" ]; then
display_name="sal-service-manager"
fi
echo -e "${GREEN}$display_name@$VERSION already published, skipping${NC}"
echo ""

View File

@ -17,7 +17,7 @@ serde_json = { workspace = true }
futures = { workspace = true }
once_cell = { workspace = true }
# Use base zinit-client instead of SAL wrapper
zinit-client = { version = "0.4.0" }
zinit-client = { version = "0.3.0" }
# Optional Rhai integration
rhai = { workspace = true, optional = true }

View File

@ -306,8 +306,6 @@ impl ServiceManager for ZinitServiceManager {
let logs = self
.execute_async(async move {
use futures::StreamExt;
use tokio::time::{timeout, Duration};
let mut log_stream = client
.logs(false, Some(service_name_owned.as_str()))
.await?;
@ -316,32 +314,18 @@ impl ServiceManager for ZinitServiceManager {
// Collect logs from the stream with a reasonable limit
let mut count = 0;
const MAX_LOGS: usize = 100;
const LOG_TIMEOUT: Duration = Duration::from_secs(5);
// Use timeout to prevent hanging
let result = timeout(LOG_TIMEOUT, async {
while let Some(log_result) = log_stream.next().await {
match log_result {
Ok(log_entry) => {
logs.push(format!("{:?}", log_entry));
count += 1;
if count >= MAX_LOGS {
break;
}
while let Some(log_result) = log_stream.next().await {
match log_result {
Ok(log_entry) => {
logs.push(format!("{:?}", log_entry));
count += 1;
if count >= MAX_LOGS {
break;
}
Err(_) => break,
}
Err(_) => break,
}
})
.await;
// Handle timeout - this is not an error, just means no more logs available
if result.is_err() {
log::debug!(
"Log reading timed out after {} seconds, returning {} logs",
LOG_TIMEOUT.as_secs(),
logs.len()
);
}
Ok::<Vec<String>, ZinitError>(logs)

View File

@ -18,7 +18,7 @@ thiserror = "2.0.12"
tokio = { version = "1.45.0", features = ["full"] }
# Zinit client
zinit-client = "0.4.0"
zinit-client = "0.3.0"
# Rhai integration
rhai = { version = "1.12.0", features = ["sync"] }

View File

@ -149,51 +149,34 @@ impl ZinitClientWrapper {
// Get logs with real implementation
pub async fn logs(&self, filter: Option<String>) -> Result<Vec<String>, ZinitError> {
use futures::StreamExt;
use tokio::time::{timeout, Duration};
// The logs method requires a follow parameter and filter
let follow = false; // Don't follow logs, just get existing ones
let mut log_stream = self.client.logs(follow, filter).await?;
let mut logs = Vec::new();
// Collect logs from the stream with a reasonable limit and timeout
// Collect logs from the stream with a reasonable limit
let mut count = 0;
const MAX_LOGS: usize = 1000;
const LOG_TIMEOUT: Duration = Duration::from_secs(5);
// Use timeout to prevent hanging
let result = timeout(LOG_TIMEOUT, async {
while let Some(log_result) = log_stream.next().await {
match log_result {
Ok(log_entry) => {
// Convert LogEntry to String using Debug formatting
logs.push(format!("{:?}", log_entry));
count += 1;
if count >= MAX_LOGS {
break;
}
}
Err(e) => {
log::warn!("Error reading log entry: {}", e);
while let Some(log_result) = log_stream.next().await {
match log_result {
Ok(log_entry) => {
// Convert LogEntry to String using Debug formatting
logs.push(format!("{:?}", log_entry));
count += 1;
if count >= MAX_LOGS {
break;
}
}
}
})
.await;
// Handle timeout - this is not an error, just means no more logs available
match result {
Ok(_) => Ok(logs),
Err(_) => {
log::debug!(
"Log reading timed out after {} seconds, returning {} logs",
LOG_TIMEOUT.as_secs(),
logs.len()
);
Ok(logs)
Err(e) => {
log::warn!("Error reading log entry: {}", e);
break;
}
}
}
Ok(logs)
}
}