From 623f1a289e50ad3838cfed6768e3a42d21c08e79 Mon Sep 17 00:00:00 2001 From: mariobassem Date: Mon, 27 Jan 2025 12:31:00 +0200 Subject: [PATCH] test: Add workaround for zinit installation in tests - Added a workaround to download and execute zinit if it's not found in the path. - This is necessary because the zinit installer cannot be imported due to a circular dependency. - This ensures that the tests can run reliably even without zinit being pre-installed. Co-authored-by: mahmmoud.hassanein --- lib/osal/zinit/rpc_test.v | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/osal/zinit/rpc_test.v b/lib/osal/zinit/rpc_test.v index 03b5d313..bd9c6bcd 100644 --- a/lib/osal/zinit/rpc_test.v +++ b/lib/osal/zinit/rpc_test.v @@ -2,11 +2,35 @@ module zinit import os import time +import freeflowuniverse.herolib.core +import freeflowuniverse.herolib.osal fn test_zinit() { + if !core.is_linux()! { + // zinit is only supported on linux + return + } + + // TODO: use zinit installer to install zinit + // this is a workaround since we can't import zinit installer due to circular dependency + zinit_version := os.execute('zinit --version') + if zinit_version.exit_code != 0 { + release_url := 'https://github.com/threefoldtech/zinit/releases/download/v0.2.14/zinit' + + mut dest := osal.download( + url: release_url + minsize_kb: 2000 + reset: true + dest: '/tmp/zinit' + )! + + chmod_cmd := os.execute('chmod +x /tmp/zinit') + assert chmod_cmd.exit_code == 0, 'failed to chmod +x /tmp/zinit: ${chmod_cmd.output}' + } + this_dir := os.dir(@FILE) // you need to have zinit in your path to run this test - spawn os.execute('zinit -s ${this_dir}/zinit/zinit.sock init -c ${this_dir}/zinit') + spawn os.execute('/tmp/zinit -s ${this_dir}/zinit/zinit.sock init -c ${this_dir}/zinit') time.sleep(time.second) client := new_rpc_client(socket_path: '${this_dir}/zinit/zinit.sock')