Skip to content

Commit

Permalink
[libbeat] Update lookslike to 0.3.0 (elastic#13498)
Browse files Browse the repository at this point in the history
Updates the go-lookslike library we maintain to 0.3.0 which uses a much improved reflection strategy. This fixed an issue in the last release where Strict() which checked for extra fields wasn't working. As a result some of our tests developed since then didn't assert that the new fields added in elastic#13022 were actually valid. Those tests are fixed in this PR.
  • Loading branch information
andrewvc authored Sep 6, 2019
1 parent 0d7adb0 commit dfd8ed0
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 90 deletions.
4 changes: 2 additions & 2 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -861,8 +861,8 @@ Apache License 2.0

--------------------------------------------------------------------
Dependency: github.com/elastic/go-lookslike
Version: v0.2.0
Revision: 807124eb9fc6684949aa99744577175fd6bac4fd
Version: =v0.3.0
Revision: 747dc7db1c961662d8e225a42af6c3859a1a0f1d
License type (autodetected): Apache-2.0
./vendor/github.com/elastic/go-lookslike/LICENSE:
--------------------------------------------------------------------
Expand Down
18 changes: 17 additions & 1 deletion heartbeat/monitors/active/http/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ import (
btesting "github.com/elastic/beats/libbeat/testing"
"github.com/elastic/go-lookslike"
"github.com/elastic/go-lookslike/isdef"
"github.com/elastic/go-lookslike/llpath"
"github.com/elastic/go-lookslike/llresult"
"github.com/elastic/go-lookslike/testslike"
"github.com/elastic/go-lookslike/validator"
)
Expand Down Expand Up @@ -102,7 +104,21 @@ func respondingHTTPChecks(url string, statusCode int) validator.Validator {
httpBaseChecks(url),
lookslike.MustCompile(map[string]interface{}{
"http": map[string]interface{}{
"response.status_code": statusCode,
"response.status_code": statusCode,
"response.body.hash": isdef.IsString,
// TODO add this isdef to lookslike in a robust way
"response.body.bytes": isdef.Is("an int64 greater than 0", func(path llpath.Path, v interface{}) *llresult.Results {
raw, ok := v.(int64)
if !ok {
return llresult.SimpleResult(path, false, "%s is not an int64", reflect.TypeOf(v))
}
if raw >= 0 {
return llresult.ValidResult(path)
}

return llresult.SimpleResult(path, false, "value %v not >= 0 ", raw)

}),
"rtt.content.us": isdef.IsDuration,
"rtt.response_header.us": isdef.IsDuration,
"rtt.total.us": isdef.IsDuration,
Expand Down
4 changes: 2 additions & 2 deletions vendor/github.com/elastic/go-lookslike/README.md

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

10 changes: 8 additions & 2 deletions vendor/github.com/elastic/go-lookslike/compiled_schema.go

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

41 changes: 21 additions & 20 deletions vendor/github.com/elastic/go-lookslike/core.go

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

13 changes: 13 additions & 0 deletions vendor/github.com/elastic/go-lookslike/internal/llreflect/chase.go

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

34 changes: 16 additions & 18 deletions vendor/github.com/elastic/go-lookslike/llpath/path.go

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

Loading

0 comments on commit dfd8ed0

Please sign in to comment.