@@ -9,7 +9,9 @@ function run(id: string, status: Run['status'], queuedHoursAgo: number, endedHou
99 return { id, status, parentRunId, jobKey, narrowing, window : null , kind : jobKey ? 'job' : 'adhoc' , statusReason : null , queuedAt : hoursAgo ( queuedHoursAgo ) , startedAt : hoursAgo ( queuedHoursAgo ) , endedAt : endedHoursAgo === null ? null : hoursAgo ( endedHoursAgo ) } as Run ;
1010}
1111
12- const node = ( key : string , kind : CatalogNode [ 'kind' ] , stale : StaleReason [ 'reason' ] [ ] = [ ] ) => ( { key, kind, stale : stale . map ( ( reason ) => ( { reason } ) ) } ) as CatalogNode ;
12+ const node = ( key : string , kind : CatalogNode [ 'kind' ] , path : string , stale : StaleReason [ 'reason' ] [ ] = [ ] , extra : Partial < CatalogNode > = { } ) =>
13+ ( { key, kind, path, group : null , lastOutcome : null , lastBuild : null , stale : stale . map ( ( reason ) => ( { reason } ) ) , ...extra } ) as CatalogNode ;
14+ const built = { lastBuild : { builtAt : hoursAgo ( 1 ) } } as Partial < CatalogNode > ;
1315const check = ( id : string , outcome : string | null ) => ( { id, latest : outcome ? { outcome } : null } ) as unknown as Check ;
1416const change = ( publishedHoursAgo : number , nodes : [ NodeChange [ 'op' ] , string ] [ ] ) =>
1517 ( { snapshotId : `s-${ publishedHoursAgo } ` , publishedAt : hoursAgo ( publishedHoursAgo ) , nodes : nodes . map ( ( [ op , key ] ) => ( { key, op } ) ) } ) as SnapshotChange ;
@@ -39,13 +41,28 @@ describe('overview from live reads', () => {
3941 const overview = overviewOf ( {
4042 runs,
4143 checks : [ check ( 'a' , 'pass' ) , check ( 'b' , 'fail' ) , check ( 'c' , 'error' ) , check ( 'd' , 'warn' ) , check ( 'e' , null ) ] ,
42- nodes : [ node ( 'model:orders' , 'table' , [ 'changed' , 'behind' ] ) , node ( 'model:totals' , 'view' ) , node ( 'model:events' , 'incremental' , [ 'behind' ] ) , node ( 'source:raw' , 'source' ) , node ( 'seed:regions' , 'seed' ) ] ,
44+ nodes : [
45+ node ( 'model:orders' , 'table' , 'models/marts/core/orders.sql' , [ 'changed' , 'behind' ] , built ) ,
46+ node ( 'model:totals' , 'view' , 'models/marts/totals.sql' , [ ] , built ) ,
47+ node ( 'model:returns' , 'table' , 'models/marts/returns.sql' , [ ] , { ...built , lastOutcome : 'failed' } ) ,
48+ node ( 'model:events' , 'incremental' , 'models/staging/events.sql' , [ 'behind' ] , built ) ,
49+ node ( 'source:raw' , 'source' , 'models/staging/sources.yml' ) ,
50+ node ( 'seed:regions' , 'seed' , 'seeds/regions.csv' )
51+ ] ,
4352 changes : [ change ( 1 , [ [ 'added' , 'model:orders' ] , [ 'added' , 'seed:regions' ] , [ 'removed' , 'model:old' ] ] ) , change ( 24 * 8 , [ [ 'added' , 'model:totals' ] ] ) ] ,
4453 events : [ event ( 'scheduler' , true ) , event ( 'cleared' , false ) ] ,
4554 acknowledgements : new Map ( [ [ 'orders-new' , { by : 'ada' , at : hoursAgo ( 1 ) } ] ] ) ,
4655 now
4756 } ) ;
4857
58+ it ( 'counts the nodes it builds by top-level folder, leaving sources out' , ( ) => {
59+ expect ( overview . groups ) . toEqual ( [
60+ { group : 'marts' , total : 3 , current : 1 , changed : 1 , behind : 1 , failed : 1 } ,
61+ { group : 'seeds' , total : 1 , current : 0 , changed : 0 , behind : 0 , failed : 0 } ,
62+ { group : 'staging' , total : 1 , current : 0 , changed : 0 , behind : 1 , failed : 0 }
63+ ] ) ;
64+ } ) ;
65+
4966 it ( 'counts top-level runs queued in the last 24 hours' , ( ) => {
5067 expect ( overview . metrics . runs24h ) . toEqual ( { total : 13 , success : 2 , warn : 1 , partial : 1 , failed : 6 , active : 2 } ) ;
5168 } ) ;
@@ -65,7 +82,7 @@ describe('overview from live reads', () => {
6582 } ) ;
6683
6784 it ( 'counts models and this week’s model changes only' , ( ) => {
68- expect ( overview . metrics . models ) . toEqual ( { total : 3 , addedThisWeek : 1 , removedThisWeek : 1 } ) ;
85+ expect ( overview . metrics . models ) . toEqual ( { total : 4 , addedThisWeek : 1 , removedThisWeek : 1 } ) ;
6986 } ) ;
7087
7188 it ( 'counts check outcomes, with errors as failing' , ( ) => {
@@ -82,6 +99,8 @@ describe('overview from live reads', () => {
8299 } ) ;
83100
84101 it ( 'leaves parts without a server read empty instead of zero' , ( ) => {
85- expect ( [ overview . metrics . cost , overview . groups ] ) . toEqual ( [ null , null ] ) ;
102+ expect ( overview . metrics . cost ) . toBeNull ( ) ;
103+ const unknown = overviewOf ( { runs : [ ] , checks : [ ] , nodes : [ { ...node ( 'model:a' , 'table' , 'models/a.sql' ) , stale : null } ] , changes : [ ] , events : [ ] , acknowledgements : new Map ( ) , now } ) ;
104+ expect ( unknown . groups ) . toBeNull ( ) ;
86105 } ) ;
87106} ) ;
0 commit comments