Skip to content

Commit

Permalink
2024 09 support yaml scripts (#75)
Browse files Browse the repository at this point in the history
YAML script support
  • Loading branch information
kleineshertz authored Sep 22, 2024
1 parent 143db52 commit 71e69ee
Show file tree
Hide file tree
Showing 56 changed files with 1,554 additions and 332 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- name: pkg/custom/py_calc test coverage threshold check
env:
TESTCOVERAGE_THRESHOLD: 83.4
TESTCOVERAGE_THRESHOLD: 83.5
run: |
go test -v ./pkg/custom/py_calc/... -coverprofile coverage.out -covermode count
totalCoverage=`go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+'`
Expand All @@ -68,7 +68,7 @@ jobs:
- name: pkg/custom/tag_and_denormalize test coverage threshold check
env:
TESTCOVERAGE_THRESHOLD: 80.6
TESTCOVERAGE_THRESHOLD: 76.1
run: |
go test -v ./pkg/custom/tag_and_denormalize/... -coverprofile coverage.out -covermode count
totalCoverage=`go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+'`
Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:
- name: pkg/sc test coverage threshold check
env:
TESTCOVERAGE_THRESHOLD: 90.7
TESTCOVERAGE_THRESHOLD: 89.8
run: |
go test -v ./pkg/sc/... -coverprofile coverage.out -covermode count
totalCoverage=`go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+'`
Expand Down
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ linters:
- forbidigo
linters-settings:
errcheck:
ignore : "" # Remove after upgrading golangci-lint 1.58 : https://github.com/golangci/golangci-lint/issues/4733
severity: error
confidence: 0.8
rules:
Expand Down
3 changes: 2 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"type": "go",
"request": "launch",
"mode": "debug",
"envFile": "${env:HOME}/UserAccessCapillariesTestbucket.env",
"cwd":"${workspaceFolder}/pkg/exe/daemon",
"program": "${workspaceFolder}/pkg/exe/daemon/capidaemon.go",
"args": []
Expand All @@ -92,7 +93,7 @@
"type": "go",
"request": "launch",
"mode": "debug",
"envFile": "${env:HOME}/capiaws.rc",
"envFile": "${env:HOME}/UserAccessCapillariesTestbucket.env",
"cwd":"${workspaceFolder}/pkg/exe/webapi",
"program": "${workspaceFolder}/pkg/exe/webapi/capiwebapi.go",
"args": []
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# <img src="doc/logo.svg" alt="logo" width="60"/> Capillaries <div style="float:right;"> [![coveralls](https://coveralls.io/repos/github/capillariesio/capillaries/badge.svg?branch=main)](https://coveralls.io/github/capillariesio/capillaries?branch=main) [![goreport](https://goreportcard.com/badge/github.com/capillariesio/capillaries)](https://goreportcard.com/report/github.com/capillariesio/capillaries) [![Go Reference](https://pkg.go.dev/badge/github.com/capillariesio/capillaries.svg)](https://pkg.go.dev/github.com/capillariesio/capillaries)</div>
# <img src="doc/logo.svg" alt="logo" width="60"/> <a href="capillaries.io">Capillaries</a> <div style="float:right;"> [![coveralls](https://coveralls.io/repos/github/capillariesio/capillaries/badge.svg?branch=main)](https://coveralls.io/github/capillariesio/capillaries?branch=main) [![goreport](https://goreportcard.com/badge/github.com/capillariesio/capillaries)](https://goreportcard.com/report/github.com/capillariesio/capillaries) [![Go Reference](https://pkg.go.dev/badge/github.com/capillariesio/capillaries.svg)](https://pkg.go.dev/github.com/capillariesio/capillaries)</div>


Capillaries is a data processing framework that:
Expand Down Expand Up @@ -83,10 +83,10 @@ Cassandra read/write statistics collected by Prometheus available at:
### Kubernetes
There is a [Kubernetes deployment POC](./test/k8s/README.md), but it may require some work: Minikube cluster setup, S3 buckets with proper permissions, S3-based Docker image repositories.

### Blog at capillaries.io
### Blog at <a href="capillaries.io/blog">capillaries.io</a>
For more details about this particular demo, see Capillaries blog: [Use Capillaries to calculate ARK portfolio performance](https://capillaries.io/blog/2023-04-08-portfolio/index.html). To learn how this demo runs on a bigger dataset with 14 million transactions, see [Capillaries: ARK portfolio performance calculation at scale](https://capillaries.io/blog/2023-11-15-portfolio-scale/index.html).

### More introduction
### Further introduction
For more details about getting started, see [Getting started](doc/started.md).

### Deploy Capillaries at scale
Expand Down
8 changes: 6 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,15 @@ services:
capinet:
ipv4_address: 10.5.0.7

# Stop all containers
# docker stop $(docker ps -a -q)
# Stop Capillaries binaries containers
# docker stop $(docker ps -a | grep -e daemon -e webapi | awk '{print $1}')
# Delete Capillaries binaries containers
# docker rm $(docker ps -a | grep -e daemon -e webapi | awk '{print $1}')
# All containers
# Delete all containers
# docker rm $(docker ps -qa)
# Delete Capillaries binaries images
# docker image rm $(docker images | grep -e daemon -e webapi | awk '{print $3}')
# All images
# Delete all images
# docker image rm $(docker images | awk '{print $3}')
10 changes: 5 additions & 5 deletions pkg/custom/py_calc/py_calc.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,12 @@ func harvestCallExp(callExp *ast.CallExpr, sigMap map[string]struct{}) error {
return nil
}

func (procDef *PyCalcProcessorDef) Deserialize(raw json.RawMessage, customProcSettings json.RawMessage, caPath string, privateKeys map[string]string) error {
var err error
if err = json.Unmarshal(raw, procDef); err != nil {
func (procDef *PyCalcProcessorDef) Deserialize(raw json.RawMessage, customProcSettings json.RawMessage, scriptType sc.ScriptType, caPath string, privateKeys map[string]string) error {
if err := sc.JsonOrYamlUnmarshal(scriptType, raw, procDef); err != nil {
return fmt.Errorf("cannot unmarshal py_calc processor def: %s", err.Error())
}

if err = json.Unmarshal(customProcSettings, &procDef.EnvSettings); err != nil {
if err := sc.JsonOrYamlUnmarshal(scriptType, customProcSettings, &procDef.EnvSettings); err != nil {
return fmt.Errorf("cannot unmarshal py_calc processor env settings: %s", err.Error())
}

Expand All @@ -104,7 +103,7 @@ func (procDef *PyCalcProcessorDef) Deserialize(raw json.RawMessage, customProcSe

// Calculated fields
for _, fieldDef := range procDef.CalculatedFields {

var err error
// Use relaxed Go parser for Python - we are lucky that Go designers liked Python, so we do not have to implement a separate Python partser (for now)
if fieldDef.ParsedExpression, err = sc.ParseRawRelaxedGolangExpressionStringAndHarvestFieldRefs(fieldDef.RawExpression, &fieldDef.UsedFields, sc.FieldRefAllowUnknownIdents); err != nil {
errors = append(errors, fmt.Sprintf("cannot parse field expression [%s]: [%s]", fieldDef.RawExpression, err.Error()))
Expand Down Expand Up @@ -168,6 +167,7 @@ func (procDef *PyCalcProcessorDef) Deserialize(raw json.RawMessage, customProcSe
}

// Check DAG and return calc fields in the order they should be calculated
var err error
if procDef.CalculationOrder, err = kahn(dag); err != nil {
errors = append(errors, fmt.Sprintf("%s. Calc dependency map:\n%v", err, dag))
}
Expand Down
55 changes: 39 additions & 16 deletions pkg/custom/py_calc/py_calc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/capillariesio/capillaries/pkg/sc"
"github.com/shopspring/decimal"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v3"
)

type PyCalcTestTestProcessorDefFactory struct {
Expand Down Expand Up @@ -184,22 +185,33 @@ const scriptJson string = `
}
},
"dependency_policies": {
"current_active_first_stopped_nogo":` + sc.DefaultPolicyCheckerConf +
"current_active_first_stopped_nogo":` + sc.DefaultPolicyCheckerConfJson +
`
}
}`

const envSettings string = `
const envSettingsJson string = `
{
"python_interpreter_path": "/some/bad/python/path",
"python_interpreter_params": ["-u", "-"]
"python_interpreter_path": "/some/bad/python/path",
"python_interpreter_params": ["-u", "-"]
}`

func TestPyCalcDefCalculator(t *testing.T) {
func jsonToYamlToScriptDef(t *testing.T) *sc.ScriptDef {
var jsonDeserializedAsMap map[string]any
err := json.Unmarshal([]byte(scriptJson), &jsonDeserializedAsMap)
assert.Nil(t, err)

scriptYamlBytes, err := yaml.Marshal(jsonDeserializedAsMap)
assert.Nil(t, err)

scriptDef := &sc.ScriptDef{}
err := scriptDef.Deserialize([]byte(scriptJson), &PyCalcTestTestProcessorDefFactory{}, map[string]json.RawMessage{"py_calc": []byte(envSettings)}, "", nil)
err = scriptDef.Deserialize(scriptYamlBytes, sc.ScriptYaml, &PyCalcTestTestProcessorDefFactory{}, map[string]json.RawMessage{"py_calc": []byte(envSettingsJson)}, "", nil)
assert.Nil(t, err)

return scriptDef
}

func testCalculator(t *testing.T, scriptDef *sc.ScriptDef) {
// Initializing rowset is tedious and error-prone. Add schema first.
rs := proc.NewRowsetFromFieldRefs(sc.FieldRefs{
{TableName: "r", FieldName: "field_int1", FieldType: sc.FieldTypeInt},
Expand Down Expand Up @@ -356,34 +368,45 @@ bla
assert.Equal(t, time.Date(2003, 3, 3, 3, 3, 3, 0, time.FixedZone("", -7200)), flushedRow["p"]["taxed_field_dt1"])
}

func TestPyCalcDefCalculatorJson(t *testing.T) {
scriptDef := &sc.ScriptDef{}
assert.Nil(t, scriptDef.Deserialize([]byte(scriptJson), sc.ScriptJson, &PyCalcTestTestProcessorDefFactory{}, map[string]json.RawMessage{"py_calc": []byte(envSettingsJson)}, "", nil))
testCalculator(t, scriptDef)
}

func TestPyCalcDefCalculatorYaml(t *testing.T) {
scriptDef := jsonToYamlToScriptDef(t)
testCalculator(t, scriptDef)
}

func TestPyCalcDefBadScript(t *testing.T) {

scriptDef := &sc.ScriptDef{}
err := scriptDef.Deserialize(
[]byte(strings.Replace(scriptJson, `"having": "w.taxed_field_decimal > 10"`, `"having": "p.taxed_field_int1 > 10"`, 1)),
&PyCalcTestTestProcessorDefFactory{}, map[string]json.RawMessage{"py_calc": []byte(envSettings)}, "", nil)
[]byte(strings.Replace(scriptJson, `"having": "w.taxed_field_decimal > 10"`, `"having": "p.taxed_field_int1 > 10"`, 1)), sc.ScriptJson,
&PyCalcTestTestProcessorDefFactory{}, map[string]json.RawMessage{"py_calc": []byte(envSettingsJson)}, "", nil)
assert.Contains(t, err.Error(), "prohibited field p.taxed_field_int1")

err = scriptDef.Deserialize(
[]byte(strings.Replace(scriptJson, `increase_by_ten_percent(r.field_int1)`, `bad_func(r.field_int1)`, 1)),
&PyCalcTestTestProcessorDefFactory{}, map[string]json.RawMessage{"py_calc": []byte(envSettings)}, "", nil)
[]byte(strings.Replace(scriptJson, `increase_by_ten_percent(r.field_int1)`, `bad_func(r.field_int1)`, 1)), sc.ScriptJson,
&PyCalcTestTestProcessorDefFactory{}, map[string]json.RawMessage{"py_calc": []byte(envSettingsJson)}, "", nil)
assert.Contains(t, err.Error(), "function def 'bad_func(arg)' not found in Python file")

re := regexp.MustCompile(`"python_code_urls": \[[^\]]+\]`)
err = scriptDef.Deserialize(
[]byte(re.ReplaceAllString(scriptJson, `"python_code_urls":[123]`)),
&PyCalcTestTestProcessorDefFactory{}, map[string]json.RawMessage{"py_calc": []byte(envSettings)}, "", nil)
[]byte(re.ReplaceAllString(scriptJson, `"python_code_urls":[123]`)), sc.ScriptJson,
&PyCalcTestTestProcessorDefFactory{}, map[string]json.RawMessage{"py_calc": []byte(envSettingsJson)}, "", nil)
assert.Contains(t, err.Error(), "cannot unmarshal py_calc processor def")

re = regexp.MustCompile(`"python_interpreter_path": "[^"]+"`)
err = scriptDef.Deserialize(
[]byte(scriptJson),
&PyCalcTestTestProcessorDefFactory{}, map[string]json.RawMessage{"py_calc": []byte(re.ReplaceAllString(envSettings, `"python_interpreter_path": 123`))}, "", nil)
[]byte(scriptJson), sc.ScriptJson,
&PyCalcTestTestProcessorDefFactory{}, map[string]json.RawMessage{"py_calc": []byte(re.ReplaceAllString(envSettingsJson, `"python_interpreter_path": 123`))}, "", nil)
assert.Contains(t, err.Error(), "cannot unmarshal py_calc processor env settings")

err = scriptDef.Deserialize(
[]byte(scriptJson),
&PyCalcTestTestProcessorDefFactory{}, map[string]json.RawMessage{"py_calc": []byte(re.ReplaceAllString(envSettings, `"python_interpreter_path": ""`))}, "", nil)
[]byte(scriptJson), sc.ScriptJson,
&PyCalcTestTestProcessorDefFactory{}, map[string]json.RawMessage{"py_calc": []byte(re.ReplaceAllString(envSettingsJson, `"python_interpreter_path": ""`))}, "", nil)
assert.Contains(t, err.Error(), "py_calc interpreter path cannot be empty")

}
Expand Down
14 changes: 11 additions & 3 deletions pkg/custom/tag_and_denormalize/tag_and_denormalize.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,18 @@ func (procDef *TagAndDenormalizeProcessorDef) GetUsedInTargetExpressionsFields()
return &procDef.UsedInCriteriaFields
}

func (procDef *TagAndDenormalizeProcessorDef) Deserialize(raw json.RawMessage, _ json.RawMessage, caPath string, privateKeys map[string]string) error {
func (procDef *TagAndDenormalizeProcessorDef) Deserialize(raw json.RawMessage, _ json.RawMessage, scriptType sc.ScriptType, caPath string, privateKeys map[string]string) error {
var err error
if err = json.Unmarshal(raw, procDef); err != nil {
return fmt.Errorf("cannot unmarshal tag_and_denormalize processor def: %s", err.Error())
if scriptType == sc.ScriptJson {
if err = json.Unmarshal(raw, procDef); err != nil {
return fmt.Errorf("cannot unmarshal tag_and_denormalize processor def json: %s", err.Error())
}
} else if scriptType == sc.ScriptYaml {
if err = json.Unmarshal(raw, procDef); err != nil {
return fmt.Errorf("cannot unmarshal tag_and_denormalize processor def yaml: %s", err.Error())
}
} else {
return fmt.Errorf("cannot unmarshal tag_and_denormalize processor def: json or yaml expected")
}

if err := envconfig.Process(context.TODO(), procDef); err != nil {
Expand Down
24 changes: 12 additions & 12 deletions pkg/custom/tag_and_denormalize/tag_and_denormalize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const scriptJson string = `
}
},
"dependency_policies": {
"current_active_first_stopped_nogo":` + sc.DefaultPolicyCheckerConf +
"current_active_first_stopped_nogo":` + sc.DefaultPolicyCheckerConfJson +
`
}
}`
Expand All @@ -150,7 +150,7 @@ func TestTagAndDenormalizeDeserializeFileCriteria(t *testing.T) {

re := regexp.MustCompile(`"tag_criteria": \{[^\}]+\}`)
err := scriptDef.Deserialize(
[]byte(re.ReplaceAllString(scriptJson, `"tag_criteria_uri": "../../../test/data/cfg/tag_and_denormalize_quicktest/tag_criteria.json"`)),
[]byte(re.ReplaceAllString(scriptJson, `"tag_criteria_uri": "../../../test/data/cfg/tag_and_denormalize_quicktest/tag_criteria.json"`)), sc.ScriptJson,
&TagAndDenormalizeTestTestProcessorDefFactory{}, map[string]json.RawMessage{"tag_and_denormalize": {}}, "", nil)
assert.Nil(t, err)

Expand All @@ -162,7 +162,7 @@ func TestTagAndDenormalizeDeserializeFileCriteria(t *testing.T) {
func TestTagAndDenormalizeRunEmbeddedCriteria(t *testing.T) {
scriptDef := &sc.ScriptDef{}

err := scriptDef.Deserialize([]byte(scriptJson), &TagAndDenormalizeTestTestProcessorDefFactory{}, map[string]json.RawMessage{"tag_and_denormalize": {}}, "", nil)
err := scriptDef.Deserialize([]byte(scriptJson), sc.ScriptJson, &TagAndDenormalizeTestTestProcessorDefFactory{}, map[string]json.RawMessage{"tag_and_denormalize": {}}, "", nil)
assert.Nil(t, err)

tndProcessor, ok := scriptDef.ScriptNodes["tag_products"].CustomProcessor.(*TagAndDenormalizeProcessorDef)
Expand Down Expand Up @@ -237,7 +237,7 @@ func TestTagAndDenormalizeRunEmbeddedCriteria(t *testing.T) {

// Bad function used
assert.Nil(t, scriptDef.Deserialize(
[]byte(re.ReplaceAllString(scriptJson, `"tag_criteria": {"boys":"re.BadGoMethod(\"aaa\")"}`)),
[]byte(re.ReplaceAllString(scriptJson, `"tag_criteria": {"boys":"re.BadGoMethod(\"aaa\")"}`)), sc.ScriptJson,
&TagAndDenormalizeTestTestProcessorDefFactory{}, map[string]json.RawMessage{"tag_and_denormalize": {}}, "", nil))

tndProcessor, ok = scriptDef.ScriptNodes["tag_products"].CustomProcessor.(*TagAndDenormalizeProcessorDef)
Expand All @@ -249,7 +249,7 @@ func TestTagAndDenormalizeRunEmbeddedCriteria(t *testing.T) {

// Bad type
assert.Nil(t, scriptDef.Deserialize(
[]byte(re.ReplaceAllString(scriptJson, `"tag_criteria": {"boys":"math.Round(1.1)"}`)),
[]byte(re.ReplaceAllString(scriptJson, `"tag_criteria": {"boys":"math.Round(1.1)"}`)), sc.ScriptJson,
&TagAndDenormalizeTestTestProcessorDefFactory{}, map[string]json.RawMessage{"tag_and_denormalize": {}}, "", nil))
tndProcessor, ok = scriptDef.ScriptNodes["tag_products"].CustomProcessor.(*TagAndDenormalizeProcessorDef)
assert.True(t, ok)
Expand All @@ -264,40 +264,40 @@ func TestTagAndDenormalizeDeserializeFailures(t *testing.T) {

// Exercise checkFieldUsageInCustomProcessor() error code path
err := scriptDef.Deserialize(
[]byte(strings.ReplaceAll(scriptJson, `r.product_spec`, `w.product_spec`)),
[]byte(strings.ReplaceAll(scriptJson, `r.product_spec`, `w.product_spec`)), sc.ScriptJson,
&TagAndDenormalizeTestTestProcessorDefFactory{}, map[string]json.RawMessage{"tag_and_denormalize": {}}, "", nil)
assert.Contains(t, err.Error(), "unknown field w.product_spec")

// Prohibited field
err = scriptDef.Deserialize(
[]byte(strings.Replace(scriptJson, `"having": "len(w.tag) > 0"`, `"having": "len(p.tag) > 0"`, 1)),
[]byte(strings.Replace(scriptJson, `"having": "len(w.tag) > 0"`, `"having": "len(p.tag) > 0"`, 1)), sc.ScriptJson,
&TagAndDenormalizeTestTestProcessorDefFactory{}, map[string]json.RawMessage{"tag_and_denormalize": {}}, "", nil)
assert.Contains(t, err.Error(), "prohibited field p.tag")

// Bad criteria
re := regexp.MustCompile(`"tag_criteria": \{[^\}]+\}`)
err = scriptDef.Deserialize(
[]byte(re.ReplaceAllString(scriptJson, `"some_bogus_key": 123`)),
[]byte(re.ReplaceAllString(scriptJson, `"some_bogus_key": 123`)), sc.ScriptJson,
&TagAndDenormalizeTestTestProcessorDefFactory{}, map[string]json.RawMessage{"tag_and_denormalize": {}}, "", nil)
assert.Contains(t, err.Error(), "cannot unmarshal with tag_criteria and tag_criteria_url missing")

err = scriptDef.Deserialize(
[]byte(re.ReplaceAllString(scriptJson, `"tag_criteria":{"a":"b"},"tag_criteria_uri":"aaa"`)),
[]byte(re.ReplaceAllString(scriptJson, `"tag_criteria":{"a":"b"},"tag_criteria_uri":"aaa"`)), sc.ScriptJson,
&TagAndDenormalizeTestTestProcessorDefFactory{}, map[string]json.RawMessage{"tag_and_denormalize": {}}, "", nil)
assert.Contains(t, err.Error(), "cannot unmarshal both tag_criteria and tag_criteria_url - pick one")

err = scriptDef.Deserialize(
[]byte(re.ReplaceAllString(scriptJson, `"tag_criteria_uri":"aaa"`)),
[]byte(re.ReplaceAllString(scriptJson, `"tag_criteria_uri":"aaa"`)), sc.ScriptJson,
&TagAndDenormalizeTestTestProcessorDefFactory{}, map[string]json.RawMessage{"tag_and_denormalize": {}}, "", nil)
assert.Contains(t, err.Error(), "cannot get criteria file")

err = scriptDef.Deserialize(
[]byte(re.ReplaceAllString(scriptJson, `"tag_criteria": ["boys"]`)),
[]byte(re.ReplaceAllString(scriptJson, `"tag_criteria": ["boys"]`)), sc.ScriptJson,
&TagAndDenormalizeTestTestProcessorDefFactory{}, map[string]json.RawMessage{"tag_and_denormalize": {}}, "", nil)
assert.Contains(t, err.Error(), "cannot unmarshal array into Go struct")

err = scriptDef.Deserialize(
[]byte(re.ReplaceAllString(scriptJson, `"tag_criteria": {"boys":"["}`)),
[]byte(re.ReplaceAllString(scriptJson, `"tag_criteria": {"boys":"["}`)), sc.ScriptJson,
&TagAndDenormalizeTestTestProcessorDefFactory{}, map[string]json.RawMessage{"tag_and_denormalize": {}}, "", nil)
assert.Contains(t, err.Error(), "cannot parse tag criteria expression")
}
4 changes: 2 additions & 2 deletions pkg/dpc/dependency_policy_checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestDefaultDependencyPolicyChecker(t *testing.T) {
NodeStatusTs: time.Date(2000, 1, 1, 0, 0, 2, 0, time.UTC)}}

polDef := sc.DependencyPolicyDef{}
if err := polDef.Deserialize([]byte(sc.DefaultPolicyCheckerConf)); err != nil {
if err := polDef.Deserialize([]byte(sc.DefaultPolicyCheckerConfJson), sc.ScriptJson); err != nil {
t.Error(err)
return
}
Expand Down Expand Up @@ -113,7 +113,7 @@ func TestDefaultDependencyPolicyChecker(t *testing.T) {
// Failures

re := regexp.MustCompile(`"expression": "e\.run[^"]+"`)
err = polDef.Deserialize([]byte(re.ReplaceAllString(sc.DefaultPolicyCheckerConf, `"expression": "1"`)))
err = polDef.Deserialize([]byte(re.ReplaceAllString(sc.DefaultPolicyCheckerConfJson, `"expression": "1"`)), sc.ScriptJson)
assert.Nil(t, err)
_, _, _, err = CheckDependencyPolicyAgainstNodeEventList(&polDef, events)
assert.Contains(t, err.Error(), "expected result type was bool, got int64")
Expand Down
Loading

0 comments on commit 71e69ee

Please sign in to comment.