Skip to content

Commit

Permalink
Merge pull request #1088 from oom-ai/test/oomagent-join
Browse files Browse the repository at this point in the history
Test/oomagent join
  • Loading branch information
lianxmfor authored Jan 26, 2022
2 parents d8d1e01 + 539c32a commit 6775b4e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
8 changes: 7 additions & 1 deletion oomagent/test/data/driver_stats.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
kind: Entity
name: driver
groups:
- name: driver_stats
category: batch
description: ~
features:
- name: conv_rate
value-type: float64
Expand All @@ -14,5 +14,11 @@ groups:
- name: avg_daily_trips
value-type: int64
description: ~
- name: fake_stream
category: stream
snapshot-interval: 1s
description: ~
features:
- name: f1
value-type: int64
description: ~
34 changes: 25 additions & 9 deletions oomagent/test/test_channel_join.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@ for i in {1..5}; do
import_sample driver_stats "./data/driver_stats_revision_$i.csv" "$i"
done

arg='
oomcli push --entity-key 1 --group fake_stream --features f1=10
t1=${1:-$(perl -MTime::HiRes=time -E 'say int(time * 1000)')}
oomcli snapshot fake_stream

arg=$(cat <<-EOF
{
"join_features": [
"driver_stats.conv_rate",
"driver_stats.acc_rate",
"driver_stats.avg_daily_trips"
"driver_stats.avg_daily_trips",
"fake_stream.f1"
],
"entity_row": {
"entity_key": "1",
Expand All @@ -35,7 +40,14 @@ arg='
"unix_milli": 0
}
}
'
{
"entity_row": {
"entity_key": "1",
"unix_milli": $t1
}
}
EOF
)

actual=$(testgrpc ChannelJoin <<<"$arg")

Expand All @@ -47,16 +59,20 @@ expected_header='
"unix_milli",
"driver_stats.conv_rate",
"driver_stats.acc_rate",
"driver_stats.avg_daily_trips"
"driver_stats.avg_daily_trips",
"fake_stream.f1"
]
'
assert_json_eq "$case" "$expected_header" "$actual_header"

case="api returns correct joined rows"
actual_rows=$(jq -c ".joinedRow" <<< "$actual" | sort)
expected_rows='
[{"string":"1"},{"int64":"3"},{"double":0.556},{"double":0.465},{"int64":"464"}]
[{"string":"7"},{"int64":"1"},{"double":0.758},{"double":0.02},{"int64":"389"}]
[{"string":"7"},{"int64":"0"},{},{},{}]
'
expected_rows=$(cat <<-EOF
[{"string":"1"},{"int64":"3"},{"double":0.556},{"double":0.465},{"int64":"464"},{}]
[{"string":"7"},{"int64":"1"},{"double":0.758},{"double":0.02},{"int64":"389"},{}]
[{"string":"7"},{"int64":"0"},{},{},{},{}]
[{"string":"1"},{"int64":"$t1"},{"double":0.146},{"double":0.031},{"int64":"286"},{"int64": "10"}]
EOF
)

assert_json_eq "$case" "$(sort <<<"$expected_rows")" "$actual_rows"

0 comments on commit 6775b4e

Please sign in to comment.