Some checks are pending
Rhai Tests / Run Rhai Tests (push) Waiting to run
- Add `zinit_client` package to the workspace, enabling its use in the SAL monorepo. This allows for better organization and dependency management. - Update `MONOREPO_CONVERSION_PLAN.md` to reflect the addition of `zinit_client` and its status. This ensures the conversion plan stays up-to-date. - Move `src/zinit_client/` directory to `zinit_client/` for better organization. This improves the overall structure of the project. - Update references to `zinit_client` to use the new path. This ensures the codebase correctly links to the `zinit_client` package.
128 lines
3.6 KiB
Plaintext
128 lines
3.6 KiB
Plaintext
// Basic Zinit operations test script
|
|
// This script tests fundamental zinit client operations
|
|
|
|
// Configuration
|
|
let socket_paths = [
|
|
"/var/run/zinit.sock",
|
|
"/tmp/zinit.sock",
|
|
"/run/zinit.sock",
|
|
"./zinit.sock"
|
|
];
|
|
|
|
// Find available socket
|
|
let socket_path = "";
|
|
for path in socket_paths {
|
|
try {
|
|
let test_services = zinit_list(path);
|
|
socket_path = path;
|
|
print(`✓ Found working Zinit socket at: ${path}`);
|
|
break;
|
|
} catch(e) {
|
|
// Continue to next path
|
|
}
|
|
}
|
|
|
|
if socket_path == "" {
|
|
print("⚠ No working Zinit socket found. Skipping tests.");
|
|
return;
|
|
}
|
|
|
|
print("=== Basic Zinit Operations Test ===");
|
|
|
|
// Test 1: List services
|
|
print("\n1. Testing service listing...");
|
|
try {
|
|
let services = zinit_list(socket_path);
|
|
print(`✓ Successfully listed ${services.len()} services`);
|
|
|
|
if services.len() > 0 {
|
|
print(" Sample services:");
|
|
let count = 0;
|
|
for name in services.keys() {
|
|
if count >= 3 { break; }
|
|
let state = services[name];
|
|
print(` ${name}: ${state}`);
|
|
count += 1;
|
|
}
|
|
} else {
|
|
print(" No services currently managed by Zinit");
|
|
}
|
|
} catch(e) {
|
|
print(`✗ Service listing failed: ${e}`);
|
|
}
|
|
|
|
// Test 2: Service status (if services exist)
|
|
print("\n2. Testing service status...");
|
|
try {
|
|
let services = zinit_list(socket_path);
|
|
if services.len() > 0 {
|
|
let service_names = services.keys();
|
|
let first_service = service_names[0];
|
|
|
|
try {
|
|
let status = zinit_status(socket_path, first_service);
|
|
print(`✓ Status for '${first_service}':`);
|
|
print(` Name: ${status.name}`);
|
|
print(` PID: ${status.pid}`);
|
|
print(` State: ${status.state}`);
|
|
print(` Target: ${status.target}`);
|
|
|
|
if status.after.len() > 0 {
|
|
print(" Dependencies:");
|
|
for dep in status.after.keys() {
|
|
let dep_state = status.after[dep];
|
|
print(` ${dep}: ${dep_state}`);
|
|
}
|
|
}
|
|
} catch(e) {
|
|
print(`⚠ Status check failed for '${first_service}': ${e}`);
|
|
}
|
|
} else {
|
|
print(" No services available for status testing");
|
|
}
|
|
} catch(e) {
|
|
print(`✗ Service status test failed: ${e}`);
|
|
}
|
|
|
|
// Test 3: Logs functionality
|
|
print("\n3. Testing logs functionality...");
|
|
try {
|
|
let all_logs = zinit_logs_all(socket_path);
|
|
print(`✓ Retrieved ${all_logs.len()} log entries`);
|
|
|
|
if all_logs.len() > 0 {
|
|
print(" Recent log entries:");
|
|
let count = 0;
|
|
for log_entry in all_logs {
|
|
if count >= 3 { break; }
|
|
print(` ${log_entry}`);
|
|
count += 1;
|
|
}
|
|
} else {
|
|
print(" No log entries available");
|
|
}
|
|
} catch(e) {
|
|
print(`⚠ Logs retrieval failed: ${e}`);
|
|
}
|
|
|
|
// Test 4: Filtered logs
|
|
print("\n4. Testing filtered logs...");
|
|
try {
|
|
let filtered_logs = zinit_logs(socket_path, "zinit");
|
|
print(`✓ Retrieved ${filtered_logs.len()} filtered log entries`);
|
|
} catch(e) {
|
|
print(`⚠ Filtered logs retrieval failed: ${e}`);
|
|
}
|
|
|
|
// Test 5: Error handling with invalid service
|
|
print("\n5. Testing error handling...");
|
|
let invalid_service = "non-existent-service-12345";
|
|
try {
|
|
let status = zinit_status(socket_path, invalid_service);
|
|
print(`⚠ Unexpected success for non-existent service: ${status}`);
|
|
} catch(e) {
|
|
print(`✓ Correctly failed for non-existent service: ${e}`);
|
|
}
|
|
|
|
print("\n=== Basic Operations Test Complete ===");
|