Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add test coverage for ibmcloud be #193

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
37 changes: 37 additions & 0 deletions .github/workflows/tests_ibmcloud.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CI Tests for IBM Cloud backend

# cancel any prior runs for this workflow and this PR (or branch)
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
ci:
runs-on: ${{ matrix.os }}

strategy:
matrix:
SCRIPT:
- ./tests/bin/ci.sh -i 'test7f.*'
- ./tests/bin/go.sh
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v4

- name: Check Docker
run: docker version && podman version

- name: Run Test with args ${{ matrix.ARGS }}
env:
TERM: xterm-256color
IC_API_KEY: ${{ secrets.IC_API_KEY }}
RESOURCE_GROUP_ID: ${{ secrets.RESOURCE_GROUP_ID }}
SSH_KEY_PUB: ${{ secrets.SSH_KEY_PUB }}
run: bash -c "${{matrix.SCRIPT}} ${{matrix.ARGS }}"
1 change: 1 addition & 0 deletions cmd/subcommands/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ func init() {
cmd.AddCommand(component.Minio())
cmd.AddCommand(component.Worker())
cmd.AddCommand(component.WorkStealer())
cmd.AddCommand(component.RunLocally())
}
42 changes: 42 additions & 0 deletions cmd/subcommands/component/run-locally.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package component

import (
"context"

"github.com/spf13/cobra"
"lunchpail.io/cmd/options"
"lunchpail.io/pkg/build"
"lunchpail.io/pkg/runtime"
)

type RunLocallyOptions struct {
Component string
LLIR string
build.LogOptions
}

func AddRunLocallyOptions(cmd *cobra.Command) *RunLocallyOptions {
options := RunLocallyOptions{}
cmd.Flags().StringVarP(&options.Component, "component", "", "", "")
cmd.Flags().StringVar(&options.LLIR, "llir", "", "")
cmd.MarkFlagRequired("component")
cmd.MarkFlagRequired("llir")
return &options
}

func RunLocally() *cobra.Command {
cmd := &cobra.Command{
Use: "run-locally",
Short: "Commands for running a component locally",
Long: "Commands for running a component locally",
}

runOpts := AddRunLocallyOptions(cmd)
options.AddLogOptions(cmd)

cmd.RunE = func(cmd *cobra.Command, args []string) error {
return runtime.RunLocally(context.Background(), runOpts.Component, runOpts.LLIR, runOpts.LogOptions)
}

return cmd
}
2 changes: 1 addition & 1 deletion cmd/subcommands/queue/drain.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func Drain() *cobra.Command {
return err
}

return queue.Drain(ctx, backend, run.ForStep(step), *opts.Log)
return queue.Drain(ctx, backend, run.ForStep(step), opts.Queue, *opts.Log)
}

return cmd
Expand Down
2 changes: 1 addition & 1 deletion cmd/subcommands/queue/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func Ls() *cobra.Command {
return err
}

files, errors, err := queue.Ls(ctx, backend, runContext.ForStep(step), path, *opts.Log)
files, errors, err := queue.Ls(ctx, backend, runContext.ForStep(step), path, opts.Queue, *opts.Log)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/subcommands/queue/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func Upload() *cobra.Command {
run = rrun.Name
}

return queue.UploadFiles(ctx, backend, q.RunContext{RunName: run}, []upload.Upload{upload.Upload{LocalPath: args[0], Bucket: args[1]}}, *opts.Log)
return queue.UploadFiles(ctx, backend, q.RunContext{RunName: run}, []upload.Upload{upload.Upload{LocalPath: args[0], Bucket: args[1]}}, opts.Queue, *opts.Log)
}

return cmd
Expand Down
2 changes: 1 addition & 1 deletion pkg/be/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type Backend interface {
InstanceCount(ctx context.Context, c lunchpail.Component, run queue.RunContext) (int, error)

// Queue properties for a given run, plus ensure access to the endpoint from this client
AccessQueue(ctx context.Context, run queue.RunContext, opts build.LogOptions) (endpoint, accessKeyID, secretAccessKey, bucket string, stop func(), err error)
AccessQueue(ctx context.Context, run queue.RunContext, rclone string, opts build.LogOptions) (endpoint, accessKeyID, secretAccessKey, bucket string, stop func(), err error)

// Return a streamer
Streamer(ctx context.Context, run queue.RunContext) streamer.Streamer
Expand Down
2 changes: 1 addition & 1 deletion pkg/be/ibmcloud/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ type Backend struct {
config ibmConfig
vpcService *vpcv1.VpcV1
sshKeyType string
sshPublicKey string
sshPublicKey []string
}
2 changes: 1 addition & 1 deletion pkg/be/ibmcloud/authenticate.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func Authenticator(apiKey string, config ibmConfig) (*vpcv1.VpcV1, error) {
Authenticator: auth,
})
if err != nil {
return nil, errors.New("Error creating VPC Service with apikey" + apiKey)
return nil, errors.New("Error creating VPC Service with apikey " + apiKey)
}
fmt.Printf("Accessing the VPC service via %s\n", method)

Expand Down
Loading
Loading