Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 94 additions & 26 deletions .github/workflows/e2e_test_spice_cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
}
];
return matrix;

build:
name: Build ${{ matrix.target.name }} CLI
if: ${{ github.event.inputs.build_cli == 'true' || github.event.inputs.build_cli == null }}
Expand Down Expand Up @@ -81,7 +81,7 @@ jobs:
run: |
mv target/release/spice spice
chmod +x spice

- name: Move Spice(Windows)
if: matrix.target.target_os == 'windows'
shell: pwsh
Expand Down Expand Up @@ -129,7 +129,7 @@ jobs:
with:
name: build_${{ matrix.target.target_os }}_${{ matrix.target.target_arch }}
path: ./build

- name: download spice cli released version
if: github.event.inputs.build_cli == 'false' && matrix.target.target_os != 'windows'
run: |
Expand All @@ -141,7 +141,7 @@ jobs:
tar -xzf "$output"
rm "$output"
chmod +x spice

- name: download spice cli released version
if: github.event.inputs.build_cli == 'false' && matrix.target.target_os == 'windows'
run: |
Expand All @@ -152,7 +152,7 @@ jobs:
Invoke-WebRequest -Uri $url -OutFile $output
tar -xzf $output
Remove-Item $output

- name: Download a older spiced
shell: pwsh
if: matrix.target.target_os == 'windows'
Expand Down Expand Up @@ -183,14 +183,14 @@ jobs:
- name: Run spice upgrade
run: |
spice upgrade

- name: Check the temp directory (Windows)
if: matrix.target.target_os == 'windows'
run: |
Write-Host "System temp directory: $env:TEMP"
Get-ChildItem -Path $env:TEMP -Recurse |
Where-Object { $_.Name -like "spice*" } |
Select-Object FullName, Length, LastWriteTime |
Get-ChildItem -Path $env:TEMP -Recurse |
Where-Object { $_.Name -like "spice*" } |
Select-Object FullName, Length, LastWriteTime |
Format-Table -AutoSize

- name: Run spice upgrade again
Expand All @@ -202,9 +202,9 @@ jobs:
if: matrix.target.target_os == 'windows'
run: |
Write-Host "System temp directory: $env:TEMP"
Get-ChildItem -Path $env:TEMP -Recurse |
Where-Object { $_.Name -like "spice*" } |
Select-Object FullName, Length, LastWriteTime |
Get-ChildItem -Path $env:TEMP -Recurse |
Where-Object { $_.Name -like "spice*" } |
Select-Object FullName, Length, LastWriteTime |
Format-Table -AutoSize

test_spice_upgrade_without_runtime:
Expand Down Expand Up @@ -244,11 +244,11 @@ jobs:
tar -xzf "$output"
rm "$output"
chmod +x spice

- name: download spice cli released version
if: github.event.inputs.build_cli == 'false' && matrix.target.target_os == 'windows'
run: |
New-Item -ItemType Directory -Force -Path "./build" > $null
New-Item -ItemType Directory -Force -Path "./build" > $null
Set-Location "./build"
$url = "https://github.com/spiceai/spiceai/releases/download/v${{ env.REL_VERSION }}/spice.exe_windows_x86_64.tar.gz"
$output = "spice.exe_windows_x86_64.tar.gz"
Expand All @@ -264,14 +264,14 @@ jobs:
- name: Run spice upgrade
run: |
spice upgrade

- name: Check the temp directory (Windows)
if: matrix.target.target_os == 'windows'
run: |
Write-Host "System temp directory: $env:TEMP"
Get-ChildItem -Path $env:TEMP -Recurse |
Where-Object { $_.Name -like "spice*" } |
Select-Object FullName, Length, LastWriteTime |
Get-ChildItem -Path $env:TEMP -Recurse |
Where-Object { $_.Name -like "spice*" } |
Select-Object FullName, Length, LastWriteTime |
Format-Table -AutoSize

- name: Run spice upgrade again
Expand All @@ -283,9 +283,9 @@ jobs:
if: matrix.target.target_os == 'windows'
run: |
Write-Host "System temp directory: $env:TEMP"
Get-ChildItem -Path $env:TEMP -Recurse |
Where-Object { $_.Name -like "spice*" } |
Select-Object FullName, Length, LastWriteTime |
Get-ChildItem -Path $env:TEMP -Recurse |
Where-Object { $_.Name -like "spice*" } |
Select-Object FullName, Length, LastWriteTime |
Format-Table -AutoSize

test_spice_install_without_runtime:
Expand Down Expand Up @@ -325,11 +325,11 @@ jobs:
tar -xzf "$output"
rm "$output"
chmod +x spice

- name: download spice cli released version
if: github.event.inputs.build_cli == 'false' && matrix.target.target_os == 'windows'
run: |
New-Item -ItemType Directory -Force -Path "./build" > $null
New-Item -ItemType Directory -Force -Path "./build" > $null
Set-Location "./build"
$url = "https://github.com/spiceai/spiceai/releases/download/v${{ env.REL_VERSION }}/spice.exe_windows_x86_64.tar.gz"
$output = "spice.exe_windows_x86_64.tar.gz"
Expand Down Expand Up @@ -387,11 +387,11 @@ jobs:
tar -xzf "$output"
rm "$output"
chmod +x spice

- name: download spice cli released version
if: github.event.inputs.build_cli == 'false' && matrix.target.target_os == 'windows'
run: |
New-Item -ItemType Directory -Force -Path "./build" > $null
New-Item -ItemType Directory -Force -Path "./build" > $null
Set-Location "./build"
$url = "https://github.com/spiceai/spiceai/releases/download/v${{ env.REL_VERSION }}/spice.exe_windows_x86_64.tar.gz"
$output = "spice.exe_windows_x86_64.tar.gz"
Expand Down Expand Up @@ -455,7 +455,7 @@ jobs:
target_os: "darwin"
target_arch: "aarch64"
target_arch_go: "arm64"

steps:
- uses: actions/checkout@v4

Expand All @@ -482,3 +482,71 @@ jobs:
- name: run spice upgrade
run: |
spice upgrade

test_spice_chat:
name: 'Test spice chat'
if: github.event.inputs.build_cli == 'true'
continue-on-error: true
runs-on: ${{ matrix.target.runner }}
env:
REL_VERSION: ${{ github.event.inputs.rel_version || '1.0.2' }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
needs:
- build
timeout-minutes: 5

strategy:
matrix:
target:
- name: "macOS aarch64 (Apple Silicon)"
runner: "macos-14"
target_os: "darwin"
target_arch: "aarch64"
target_arch_go: "arm64"

steps:
- uses: actions/checkout@v4

- name: download artifacts - build_${{ matrix.target.target_os }}_${{ matrix.target.target_arch }}
if: github.event.inputs.build_cli != 'false'
uses: actions/download-artifact@v4
with:
name: build_${{ matrix.target.target_os }}_${{ matrix.target.target_arch }}
path: ./build

- name: Install spice
uses: ./.github/actions/install-spice-cli
with:
build-path: ./build

- name: Init spice app
run: |
cp ./test/models/spicepod_openai.yml ./spicepod.yaml
cat ./spicepod.yaml

- name: Start spice runtime
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SPICE_OPENAI_API_KEY: ${{ secrets.SPICE_SECRET_OPENAI_API_KEY }}
run: |
spice run &> spice.log &

- name: Wait for Spice runtime is ready
timeout-minutes: 1
run: |
while [[ "$(curl -s http://localhost:8090/v1/ready)" != "ready" ]]; do sleep 1; done

- name: Install expect (macOS)
if: matrix.target.target_os == 'darwin'
run: |
brew install expect

- name: Test `spice chat` error
run: |
./test/cli/spice_chat_error.exp

- name: Stop spice and check logs
if: always()
run: |
killall spice || true
cat spice.log
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ datafusion-execution = { git = "https://github.com/spiceai/datafusion.git", rev
datafusion-expr = { git = "https://github.com/spiceai/datafusion.git", rev = "e0e423e9e29a711d076892865d51747b06429d1b" } # spiceai-45

datafusion-federation = { git = "https://github.com/spiceai/datafusion-federation.git", rev = "1c814422cfbdeb7f7bd2399e3369656710413aa8" } # spiceai-45
datafusion-table-providers = { git = "https://github.com/datafusion-contrib/datafusion-table-providers.git", rev = "f60653b6ff9a0f26e5b44a1d43d947fdf1fd8853" } # spiceai
datafusion-table-providers = { git = "https://github.com/datafusion-contrib/datafusion-table-providers.git", rev = "1713e9af2729f686aac46aef63e8c84545083e29" } # spiceai


duckdb = { git = "https://github.com/spiceai/duckdb-rs.git", rev = "b850ae60dbe67209320c86daeadf47b51f937660" } # spiceai-1.2.2

Expand Down
104 changes: 104 additions & 0 deletions test/cli/spice_chat_error.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/usr/bin/expect -f

# Test invalid --model error case
proc test_invalid_model {} {
set command "spice chat --model not_exist"

catch {exec sh -c "$command 2>&1"} output
puts "Command output: $output"

# Check for expected error messages in the output
if {[regexp {ERROR.*Requested model is not available.*not_exist} $output]} {
puts "✓ Error message about unavailable model detected"
} else {
puts "✗ Missing error about unavailable model"
exit 1
}

# Check that available models are listed
if {[regexp {INFO.*Available models} $output]} {
puts "✓ Available models list is shown"
} else {
puts "✗ Available models list not shown"
exit 1
}

# Check that expected models are in the list
if {[regexp {openai-gpt} $output]} {
puts "✓ Found expected model 'openai-gpt' in the list"
} else {
puts "✗ Expected model 'openai-gpt' not found in the list"
exit 1
}

puts "✓ Invalid model test passed"
}

# Test invalid --http-endpoint error case
proc test_invalid_http_endpoint {} {
set command "spice chat --http-endpoint https://data.spicea"

catch {exec sh -c "$command 2>&1"} output
puts "Command output: $output"

# Check for expected error messages in the output
if {[regexp {ERROR.*could not list models.*no such host} $output]} {
puts "✓ Error message about invalid host detected"
} else {
puts "✗ Missing error about invalid host"
exit 1
}

# Check for the specific host name in the error
if {[regexp {lookup data.spicea: no such host} $output]} {
puts "✓ Invalid hostname correctly reported in error"
} else {
puts "✗ Invalid hostname not correctly reported"
exit 1
}

puts "✓ Invalid host test passed"
}

# Test invalid --temperature error case
proc test_invalid_temperature {} {
set command "spice chat --temperature -1"

catch {exec sh -c "$command 2>&1"} output
puts "Command output: $output"

# Check for expected error messages in the output
if {[regexp {ERROR.*temperature must be greater than or equal to 0} $output]} {
puts "✓ Error message about invalid temperature detected"
} else {
puts "✗ Missing error about invalid temperature"
exit 1
}

puts "✓ Invalid temperature test passed"
}

# Test invalid --api-key error case
proc test_invalid_api_key {} {
set command "spice chat --http-endpoint https://data.spiceai.io --api-key \"wrong_key\""

catch {exec sh -c "$command 2>&1"} output
puts "Command output: $output"

# Check for expected error messages in the output
if {[regexp {ERROR.*could not list models.*unauthorized: invalid or missing Spice API key} $output]} {
puts "✓ Error message about invalid API key detected"
} else {
puts "✗ Missing error about invalid API key"
exit 1
}

puts "✓ Invalid API key test passed"
}

# Run the test
test_invalid_model
test_invalid_http_endpoint
test_invalid_temperature
test_invalid_api_key
exit 0
9 changes: 9 additions & 0 deletions test/cli/spicepod_openai.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: v1
kind: Spicepod
name: ai-test-spicepod

models:
- from: openai:gpt-4o-mini
name: openai-gpt
params:
openai_api_key: ${ secrets:SPICE_OPENAI_API_KEY }
Loading