Skip to content

Commit

Permalink
Update Legacy Tests to V2
Browse files Browse the repository at this point in the history
  • Loading branch information
js-ts committed Mar 23, 2024
1 parent 0948775 commit aa9d419
Show file tree
Hide file tree
Showing 17 changed files with 304 additions and 278 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ repos:
- id: detect-private-key
exclude: testdata/.*
- id: check-yaml
exclude: testdata/.*
- id: check-json
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
Expand Down
13 changes: 7 additions & 6 deletions cmd/cli/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ func TestCreateSuite(t *testing.T) {

func (s *CreateSuite) TestCreateGenericSubmitBetter() {
tests := []struct {
Name string
Fixture *testdata.FixtureLegacy
Name string
Fixture *testdata.Fixture
FixtureLegacy *testdata.FixtureLegacy
}{
{
Name: "noop json",
Expand All @@ -51,12 +52,12 @@ func (s *CreateSuite) TestCreateGenericSubmitBetter() {
Fixture: testdata.YamlJobNoopUrl,
},
{
Name: "docker task json",
Fixture: testdata.IPVMTaskDocker,
Name: "docker task json",
FixtureLegacy: testdata.IPVMTaskDocker,
},
{
Name: "task with config json",
Fixture: testdata.IPVMTaskWithConfig,
Name: "task with config json",
FixtureLegacy: testdata.IPVMTaskWithConfig,
},
//"TODO: re-enable wasm job which is currently broken as it relies on pulling data from the public IPFS network")
/*
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/validate/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestValidateSuite(t *testing.T) {

func (s *ValidateSuite) TestValidate() {
tests := map[string]struct {
testFile *testdata.FixtureLegacy
testFile *testdata.Fixture
valid bool
}{
"validJobFile": {testFile: testdata.YamlJobNoop, valid: true},
Expand Down
41 changes: 25 additions & 16 deletions testdata/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@ var noopJobYAML []byte
var wasmJobYAML []byte

var (
JsonJobNoop *FixtureLegacy
JsonJobNoop *Fixture
JsonJobCancel *FixtureLegacy
JsonJobDockerEngineSpec *FixtureLegacy
JsonJobWasmEngineSpec *FixtureLegacy
JsonJobDockerEngineSpec *Fixture
JsonJobWasmEngineSpec *Fixture

YamlJobS3 *FixtureLegacy
YamlJobNoop *FixtureLegacy
YamlJobNoopInvalid *FixtureLegacy
YamlJobNoopUrl *FixtureLegacy
YamlJobDockerEngineSpec *FixtureLegacy
YamlJobS3 *Fixture
YamlJobNoop *Fixture
YamlJobNoopInvalid *Fixture
YamlJobNoopUrl *Fixture
YamlJobDockerEngineSpec *Fixture

IPVMTaskDocker *FixtureLegacy
IPVMTaskWasm *FixtureLegacy
Expand All @@ -97,24 +97,24 @@ var (
)

func init() {
JsonJobNoop = NewLegacySpecFixture(jobNoopJSON)
YamlJobNoop = NewLegacySpecFixture(jobNoopYAML)
YamlJobNoopInvalid = NewLegacySpecFixture(jobNoopYAMLInvalid)
JsonJobNoop = NewJobFixture("json noop job", jobNoopJSON, false)
YamlJobNoop = NewJobFixture("yaml noop job", jobNoopYAML, false)
YamlJobNoopInvalid = NewJobFixture("yaml invalid noop job", jobNoopYAMLInvalid, true)

JsonJobCancel = NewLegacySpecFixture(jobCancelJSON)

YamlJobS3 = NewLegacySpecFixture(jobS3YAML)
YamlJobS3 = NewJobFixture("yaml s3 job", jobS3YAML, false)

YamlJobNoopUrl = NewLegacySpecFixture(jobNoopURLYAML)
YamlJobNoopUrl = NewJobFixture("yaml noop url job", jobNoopURLYAML, false)

IPVMTaskDocker = NewLegacyIPVMFixture(dockerTaskJSON)
IPVMTaskWasm = NewLegacyIPVMFixture(wasmTaskJSON)
IPVMTaskWithConfig = NewLegacyIPVMFixture(taskWithConfigJSON)

JsonJobDockerEngineSpec = NewLegacySpecFixture(jobJsonDockerEngineSpec)
YamlJobDockerEngineSpec = NewLegacySpecFixture(jobYamlDockerEngineSpec)
JsonJobDockerEngineSpec = NewJobFixture("json docker job", jobJsonDockerEngineSpec, false)
YamlJobDockerEngineSpec = NewJobFixture("yaml docker job", jobYamlDockerEngineSpec, false)

JsonJobWasmEngineSpec = NewLegacySpecFixture(jobJsonWasmEngineSpec)
JsonJobWasmEngineSpec = NewJobFixture("json wasm docker job", jobJsonWasmEngineSpec, false)

DockerJobYAML = NewJobFixture("docker job", dockerJobYAML, false)
DockerOutputYAML = NewJobFixture("docker with output yaml", dockerOutputYAML, false)
Expand All @@ -134,6 +134,15 @@ type Fixture struct {

func AllFixtures() []*Fixture {
return []*Fixture{
JsonJobNoop,
JsonJobDockerEngineSpec,
JsonJobWasmEngineSpec,
YamlJobS3,
YamlJobNoop,
YamlJobNoopInvalid,
YamlJobNoopUrl,
YamlJobDockerEngineSpec,

DockerJobYAML,
DockerOutputYAML,
DockerOutputJSON,
Expand Down
54 changes: 28 additions & 26 deletions testdata/job-docker-engine-spec.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
{
"APIVersion": "v1beta1",
"Spec": {
"EngineSpec": {
"Type": "docker",
"Params": {
"Image": "ubuntu:latest",
"Entrypoint": ["/bin/bash", "-c", "echo 15"]
}
}
},
"Publisher": "ipfs",
"Resources": {
"CPU": "",
"GPU": "",
"Memory": "",
"Disk": ""
},
"Inputs": [
],
"Outputs": [
"Name": "Job Docker Engine Spec",
"Type": "batch",
"Count": 1,
"Tasks": [
{
"StorageSource": "ipfs",
"Name": "output_custom",
"CID": "",
"Path": "/output_custom"
"Name": "main",
"Engine": {
"Type": "docker",
"Params": {
"Image": "ubuntu:latest",
"Entrypoint": [
"/bin/bash"
],
"Parameters": [
"-c",
"echo 15"
]
}
},
"Publisher": {
"Type": "ipfs"
},
"ResultPaths": [
{
"Name": "output_custom",
"Path": "/output_custom"
}
]
}
],
"Annotations": []
]
}
42 changes: 19 additions & 23 deletions testdata/job-docker-engine-spec.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
APIVersion: v1beta1
Spec:
Publisher: ipfs
EngineSpec:
Type: docker
Params:
Image: ubuntu:latest
Entrypoint:
- /bin/bash
- -c
- echo 15
Resources:
CPU: ''
GPU: ''
Memory: ''
Disk: ''
Inputs: []
Outputs:
- StorageSource: ipfs
Name: output_custom
CID: ''
Path: /output_custom
Annotations: []
Name: Job Docker Engine Spec
Type: batch
Count: 1
Tasks:
- Name: main
Engine:
Type: docker
Params:
Image: "ubuntu:latest"
Entrypoint:
- /bin/bash
Parameters:
- -c
- echo 15
Publisher:
Type: "ipfs"
ResultPaths:
- Name: output_custom
Path: /output_custom
37 changes: 20 additions & 17 deletions testdata/job-invalid.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
# Missing API Version
# APIVersion: v1beta1
Spec:
Engine: docker
Publisher: ipfs
Docker:
Image: gromacs/gromacs
Entrypoint:
- /bin/bash
- -c
- echo 15 | gmx pdb2gmx -f input/1AKI.pdb -o output/1AKI_processed.gro -water spc
Outputs:
- StorageSource: ipfs
Name: output_custom
Path: /output_custom
Deal:
Concurrency: 1
Name: Job Docker Output Engine Spec
# Missing Job Type
# Type: batch
Count: 1
Tasks:
- Name: main
Engine:
Type: docker
Params:
Image: gromacs/gromacs
Entrypoint:
- /bin/bash
Parameters:
- -c
- echo 15 | gmx pdb2gmx -f input/1AKI.pdb -o output/1AKI_processed.gro -water spc
Publisher:
Type: "ipfs"
ResultPaths:
- Name: outputs
Path: /outputs
23 changes: 12 additions & 11 deletions testdata/job-noop-invalid.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Missing API Version
# APIVersion: v1beta1
Spec:
Engine: noop
Publisher: noop
Outputs:
- StorageSource: ipfs
Name: output_custom
Path: /output_custom
Deal:
Concurrency: 1
# Type: batch
Namespace: default
Count: 1
Tasks:
- Name: main
Engine:
Type: noop
Publisher:
Type: noop
ResultPaths:
- Name: output_custom
Path: /output_custom
33 changes: 19 additions & 14 deletions testdata/job-noop-url.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
APIVersion: v1beta1
Spec:
Engine: noop
Publisher: noop
Inputs:
- StorageSource: urlDownload
URL: https://gist.githubusercontent.com/enricorotundo/990f0ad01a50d08dfb580e4ad404870e/raw/aa6934257351a0da93f1e740c72f27128590cebc/foo_data.txt
Path: /app/foo_data_1.txt
Outputs:
- StorageSource: ipfs
Name: output_custom
Path: /output_custom
Deal:
Concurrency: 1
Name: Noop Job URL
Type: batch
Namespace: default
Count: 1
Tasks:
- Name: main
Engine:
Type: noop
Publisher:
Type: ipfs
ResultPaths:
- Name: output_custom
Path: /output_custom
InputSources:
- Target: /inputs
Source:
Type: urlDownload
Params:
URL: https://raw.githubusercontent.com/bacalhau-project/bacalhau/main/README.md
30 changes: 16 additions & 14 deletions testdata/job-noop.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
{
"APIVersion": "v1beta1",
"Spec": {
"Engine": "noop",
"Publisher": "noop",
"Resources": {
"CPU": "",
"GPU": "",
"Memory": "",
"Disk": ""
"Name": "Noop Job",
"Type": "batch",
"Namespace": "default",
"Count": 1,
"Tasks": [
{
"Name": "main",
"Engine": {
"Type": "noop"
},
"Inputs": [],
"Outputs": [],
"Annotations": []
}
}
"Publisher": {
"Type": "noop"
},
"ResultPaths": []
}
]
}
23 changes: 13 additions & 10 deletions testdata/job-noop.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
APIVersion: v1beta1
Spec:
Engine: noop
Publisher: noop
Outputs:
- StorageSource: ipfs
Name: output_custom
Path: /output_custom
Deal:
Concurrency: 1
Name: Noop Job
Type: batch
Namespace: default
Count: 1
Tasks:
- Name: main
Engine:
Type: noop
Publisher:
Type: noop
ResultPaths:
- Name: output_custom
Path: /output_custom
Loading

0 comments on commit aa9d419

Please sign in to comment.