-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support workflow specs added via UI (#12091)
Uploads were failing due to missing validations Specs are still empty for the time being.
- Loading branch information
Showing
6 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package workflows_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/smartcontractkit/chainlink/v2/core/services/workflows" | ||
) | ||
|
||
func TestDelegate_JobSpecValidator(t *testing.T) { | ||
t.Parallel() | ||
|
||
var tt = []struct { | ||
name string | ||
toml string | ||
valid bool | ||
}{ | ||
{ | ||
"valid spec", | ||
` | ||
type = "workflow" | ||
schemaVersion = 1 | ||
`, | ||
true, | ||
}, | ||
{ | ||
"parse error", | ||
` | ||
invalid syntax{{{{ | ||
`, | ||
false, | ||
}, | ||
{ | ||
"invalid job type", | ||
` | ||
type = "work flows" | ||
schemaVersion = 1 | ||
`, | ||
false, | ||
}, | ||
} | ||
for _, tc := range tt { | ||
tc := tc | ||
t.Run(tc.name, func(t *testing.T) { | ||
_, err := workflows.ValidatedWorkflowSpec(tc.toml) | ||
if tc.valid { | ||
require.NoError(t, err) | ||
} else { | ||
require.Error(t, err) | ||
} | ||
}) | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
core/store/migrate/migrations/0223_workflow_spec_validation.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
-- +goose Up | ||
ALTER TABLE | ||
jobs | ||
DROP | ||
CONSTRAINT chk_specs, | ||
ADD | ||
CONSTRAINT chk_specs CHECK ( | ||
num_nonnulls( | ||
ocr_oracle_spec_id, ocr2_oracle_spec_id, | ||
direct_request_spec_id, flux_monitor_spec_id, | ||
keeper_spec_id, cron_spec_id, webhook_spec_id, | ||
vrf_spec_id, blockhash_store_spec_id, | ||
block_header_feeder_spec_id, bootstrap_spec_id, | ||
gateway_spec_id, | ||
legacy_gas_station_server_spec_id, | ||
legacy_gas_station_sidecar_spec_id, | ||
eal_spec_id, | ||
CASE "type" WHEN 'stream' THEN 1 ELSE NULL END, -- 'stream' type lacks a spec but should not cause validation to fail | ||
CASE "type" WHEN 'workflow' THEN 1 ELSE NULL END -- 'workflow' type currently lacks a spec but should not cause validation to fail | ||
) = 1 | ||
); | ||
|
||
-- +goose Down | ||
ALTER TABLE | ||
jobs | ||
DROP | ||
CONSTRAINT chk_specs, | ||
ADD | ||
CONSTRAINT chk_specs CHECK ( | ||
num_nonnulls( | ||
ocr_oracle_spec_id, ocr2_oracle_spec_id, | ||
direct_request_spec_id, flux_monitor_spec_id, | ||
keeper_spec_id, cron_spec_id, webhook_spec_id, | ||
vrf_spec_id, blockhash_store_spec_id, | ||
block_header_feeder_spec_id, bootstrap_spec_id, | ||
gateway_spec_id, | ||
legacy_gas_station_server_spec_id, | ||
legacy_gas_station_sidecar_spec_id, | ||
eal_spec_id, | ||
CASE "type" WHEN 'stream' THEN 1 ELSE NULL END -- 'stream' type lacks a spec but should not cause validation to fail | ||
) = 1 | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters