MCPcopy Create free account
hub / github.com/rilldata/rill / TestInterdependence

Function TestInterdependence

runtime/controller_test.go:665–720  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

663}
664
665func TestInterdependence(t *testing.T) {
666 // Test D -> C, D -> A, C -> A,B (-> = refs)
667 // Test error propagation on source error
668
669 // Create interdependent model
670 rt, id := testruntime.NewInstance(t)
671 testruntime.PutFiles(t, rt, id, map[string]string{
672 "/data/foo.csv": `a,b,c,d,e
6731,2,3,4,5
6741,2,3,4,5
6751,2,3,4,5
676`,
677 "/sources/foo.yaml": `
678connector: local_file
679path: data/foo.csv
680`,
681 "/models/bar1.sql": `SELECT * FROM foo`,
682 "/models/bar2.sql": `SELECT * FROM bar1`,
683 "/models/bar3.sql": `SELECT * FROM bar2`,
684 "/metrics/dash.yaml": `
685version: 1
686type: metrics_view
687display_name: Dash
688model: bar3
689dimensions:
690- column: b
691- column: c
692measures:
693- expression: count(*)
694- expression: avg(a)
695`,
696 })
697 metrics, metricsRes := newMetricsView("dash", "bar3", "", []any{"count(*)", runtimev1.Type_CODE_INT64, "avg(a)", runtimev1.Type_CODE_FLOAT64}, []any{"b", runtimev1.Type_CODE_INT64, "c", runtimev1.Type_CODE_INT64})
698 testruntime.ReconcileParserAndWait(t, rt, id)
699 testruntime.RequireReconcileState(t, rt, id, 6, 0, 0)
700 testruntime.RequireOLAPTableCount(t, rt, id, "bar1", 3)
701 testruntime.RequireOLAPTableCount(t, rt, id, "bar2", 3)
702 testruntime.RequireOLAPTableCount(t, rt, id, "bar3", 3)
703 testruntime.RequireResource(t, rt, id, metricsRes)
704
705 // Update the source to invalid file
706 testruntime.PutFiles(t, rt, id, map[string]string{
707 "/sources/foo.yaml": `
708connector: local_file
709path: data/bar.csv
710`,
711 })
712 testruntime.ReconcileParserAndWait(t, rt, id)
713 testruntime.RequireReconcileState(t, rt, id, 6, 5, 0)
714 testruntime.RequireNoOLAPTable(t, rt, id, "bar1")
715 testruntime.RequireNoOLAPTable(t, rt, id, "bar2")
716 testruntime.RequireNoOLAPTable(t, rt, id, "bar3")
717 metricsRes.Meta.ReconcileError = `table "bar3" does not exist`
718 metrics.State = &runtimev1.MetricsViewState{}
719 testruntime.RequireResource(t, rt, id, metricsRes)
720}
721
722func TestCyclesWithTwoModels(t *testing.T) {

Callers

nothing calls this directly

Calls 8

NewInstanceFunction · 0.92
PutFilesFunction · 0.92
ReconcileParserAndWaitFunction · 0.92
RequireReconcileStateFunction · 0.92
RequireOLAPTableCountFunction · 0.92
RequireResourceFunction · 0.92
RequireNoOLAPTableFunction · 0.92
newMetricsViewFunction · 0.70

Tested by

no test coverage detected