@@ -106,6 +106,12 @@ func TestBackupFilesystem(t *testing.T) {
106106 _ = runBackup (t , 3 , 1 )
107107 restored := runRestore (t , copyBackupDir , "" , math .MaxUint64 )
108108
109+ // Check the predicates and types in the schema are as expected.
110+ // TODO: refactor tests so that minio and filesystem tests share most of their logic.
111+ preds := []string {"dgraph.graphql.schema" , "dgraph.graphql.xid" , "dgraph.type" , "movie" }
112+ types := []string {"Node" , "dgraph.graphql" }
113+ testutil .CheckSchema (t , preds , types )
114+
109115 checks := []struct {
110116 blank , expected string
111117 }{
@@ -130,10 +136,27 @@ func TestBackupFilesystem(t *testing.T) {
130136 t .Logf ("%+v" , incr1 )
131137 require .NoError (t , err )
132138
139+ // Update schema and types to make sure updates to the schema are backed up.
140+ require .NoError (t , dg .Alter (ctx , & api.Operation {Schema : `
141+ movie: string .
142+ actor: string .
143+ type Node {
144+ movie
145+ }
146+ type NewNode {
147+ actor
148+ }` }))
149+
133150 // Perform first incremental backup.
134151 _ = runBackup (t , 6 , 2 )
135152 restored = runRestore (t , copyBackupDir , "" , incr1 .Txn .CommitTs )
136153
154+ // Check the predicates and types in the schema are as expected.
155+ preds = append (preds , "actor" )
156+ types = append (types , "NewNode" )
157+ testutil .CheckSchema (t , preds , types )
158+
159+ // Perform some checks on the restored values.
137160 checks = []struct {
138161 blank , expected string
139162 }{
@@ -157,6 +180,7 @@ func TestBackupFilesystem(t *testing.T) {
157180 // Perform second incremental backup.
158181 _ = runBackup (t , 9 , 3 )
159182 restored = runRestore (t , copyBackupDir , "" , incr2 .Txn .CommitTs )
183+ testutil .CheckSchema (t , preds , types )
160184
161185 checks = []struct {
162186 blank , expected string
@@ -181,6 +205,7 @@ func TestBackupFilesystem(t *testing.T) {
181205 // Perform second full backup.
182206 dirs := runBackupInternal (t , true , 12 , 4 )
183207 restored = runRestore (t , copyBackupDir , "" , incr3 .Txn .CommitTs )
208+ testutil .CheckSchema (t , preds , types )
184209
185210 // Check all the values were restored to their most recent value.
186211 checks = []struct {
@@ -279,16 +304,6 @@ func runRestore(t *testing.T, backupLocation, lastDir string, commitTs uint64) m
279304 restored , err := testutil .GetPredicateValues (pdir , "movie" , commitTs )
280305 require .NoError (t , err )
281306 t .Logf ("--- Restored values: %+v\n " , restored )
282-
283- restoredPreds , err := testutil .GetPredicateNames (pdir , commitTs )
284- require .NoError (t , err )
285- require .ElementsMatch (t , []string {"dgraph.graphql.schema" , "dgraph.graphql.xid" , "dgraph.type" ,
286- "movie" }, restoredPreds )
287-
288- restoredTypes , err := testutil .GetTypeNames (pdir , commitTs )
289- require .NoError (t , err )
290- require .ElementsMatch (t , []string {"Node" , "dgraph.graphql" }, restoredTypes )
291-
292307 return restored
293308}
294309
0 commit comments