Skip to content

Commit

Permalink
test(smoke): add installer test
Browse files Browse the repository at this point in the history
  • Loading branch information
philwinder committed Dec 28, 2024
1 parent 1afdcb2 commit 70c8485
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,12 @@ trigger:
- cron
cron:
- smoke-test-hourly
- developer
# To run this manually, create a new cron job in Drone called developer and pointing to your-branch-name .
# Then send a curl request to:
# curl --request POST \
# --url 'https://drone.lukemarsden.net/api/repos/helixml/helix/cron/developer?branch=your-branch-name' \
# --header 'Authorization: Bearer XXXXXX'

steps:
- name: smoke-test-saas
Expand All @@ -508,6 +514,7 @@ steps:
- name: integration-test
path: /integration-test
commands:
- apk add --no-cache curl bash openssl
- cp -r integration-test/* /integration-test
- go test -timeout 300s -tags=integration -v ./integration-test/smoke
depends_on: []
Expand Down
57 changes: 57 additions & 0 deletions integration-test/smoke/install_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//go:build integration
// +build integration

package smoke

import (
"os"
"os/exec"
"path/filepath"
"testing"

"github.com/stretchr/testify/require"
)

func TestInstallScript(t *testing.T) {
t.Parallel()

// Create temp dir for test
tmpDir, err := os.MkdirTemp("", "helix-install-test-*")
require.NoError(t, err)
defer os.RemoveAll(tmpDir)

// Change to temp dir
err = os.Chdir(tmpDir)
require.NoError(t, err)

// Download install script
downloadCmd := exec.Command("curl", "-sL", "-O", "https://get.helix.ml/install.sh")
output, err := downloadCmd.CombinedOutput()
require.NoError(t, err, "Failed to download install script: %s", string(output))

// Verify script was downloaded
_, err = os.Stat("install.sh")
require.NoError(t, err, "install.sh should exist")

// Create a shim for sudo that runs commands without sudo
sudoShim := filepath.Join(tmpDir, "sudo")
sudoShimFile, err := os.Create(sudoShim)
require.NoError(t, err)
sudoShimFile.WriteString("#!/bin/sh\n$@\n")
sudoShimFile.Close()
os.Chmod(sudoShim, 0755)

// Create a shim for docker that does nothing but return success
dockerShim := filepath.Join(tmpDir, "docker")
dockerShimFile, err := os.Create(dockerShim)
require.NoError(t, err)
dockerShimFile.WriteString("#!/bin/sh\nexit 0\n")
dockerShimFile.Close()
os.Chmod(dockerShim, 0755)

// Run install script, using the shim for sudo
installCmd := exec.Command("bash", "install.sh", "-y", "--controlplane")
installCmd.Env = append(os.Environ(), "PATH="+tmpDir+":"+os.Getenv("PATH"))
output, err = installCmd.CombinedOutput()
require.NoError(t, err, "Install script failed: %s", string(output))
}

0 comments on commit 70c8485

Please sign in to comment.