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

Function RefreshModelAndWait

runtime/testruntime/reconcile.go:67–100  ·  view source on GitHub ↗
(t testing.TB, rt *runtime.Runtime, id string, model *runtimev1.RefreshModelTrigger)

Source from the content-addressed store, hash-verified

65}
66
67func RefreshModelAndWait(t testing.TB, rt *runtime.Runtime, id string, model *runtimev1.RefreshModelTrigger) {
68 ctx := t.Context()
69 ctrl, err := rt.Controller(ctx, id)
70 require.NoError(t, err)
71 n := &runtimev1.ResourceName{Kind: runtime.ResourceKindModel, Name: model.Model}
72
73 // Get resource before refresh
74 rPrev, err := ctrl.Get(ctx, n, false)
75 require.NoError(t, err)
76
77 // Create refresh trigger
78 trgName := &runtimev1.ResourceName{Kind: runtime.ResourceKindRefreshTrigger, Name: time.Now().String()}
79 err = ctrl.Create(ctx, trgName, nil, nil, nil, false, &runtimev1.Resource{
80 Resource: &runtimev1.Resource_RefreshTrigger{
81 RefreshTrigger: &runtimev1.RefreshTrigger{
82 Spec: &runtimev1.RefreshTriggerSpec{
83 Models: []*runtimev1.RefreshModelTrigger{model},
84 },
85 },
86 },
87 })
88 require.NoError(t, err)
89
90 // Wait for refresh to complete
91 err = ctrl.WaitUntilIdle(ctx, false)
92 require.NoError(t, err)
93
94 // Get resource after refresh
95 rNew, err := ctrl.Get(ctx, n, false)
96 require.NoError(t, err)
97
98 // Check the resource's spec version has increased
99 require.Greater(t, rNew.Meta.SpecVersion, rPrev.Meta.SpecVersion)
100}
101
102func RefreshAndWait(t testing.TB, rt *runtime.Runtime, id string, n *runtimev1.ResourceName) {
103 ctx := t.Context()

Callers 2

TestModelChangeModesFunction · 0.92

Calls 6

ControllerMethod · 0.80
CreateMethod · 0.80
ContextMethod · 0.65
GetMethod · 0.65
StringMethod · 0.65
WaitUntilIdleMethod · 0.45

Tested by 2

TestModelChangeModesFunction · 0.74