@@ -80,21 +80,6 @@ func tryAddArangoSearchLink(ctx context.Context, db driver.Database, view driver
8080 return checkLinkExists (ctx , view , colName , t )
8181}
8282
83- // assertArangoSearchView is a helper to check if an arangosearch view exists and fail if it does not.
84- func assertArangoSearchView (ctx context.Context , db driver.Database , name string , t * testing.T ) driver.ArangoSearchView {
85- v , err := db .View (ctx , name )
86- if driver .IsNotFound (err ) {
87- t .Fatalf ("View '%s': does not exist" , name )
88- } else if err != nil {
89- t .Fatalf ("Failed to open view '%s': %s" , name , describe (err ))
90- }
91- result , err := v .ArangoSearchView ()
92- if err != nil {
93- t .Fatalf ("Failed to open view '%s' as arangosearch view: %s" , name , describe (err ))
94- }
95- return result
96- }
97-
9883// TestCreateArangoSearchView creates an arangosearch view and then checks that it exists.
9984func TestCreateArangoSearchView (t * testing.T ) {
10085 ctx := context .Background ()
@@ -906,3 +891,97 @@ func TestArangoSearchViewProperties353(t *testing.T) {
906891 require .EqualValues (t , analyzer .Properties .Case , driver .ArangoSearchCaseLower )
907892 require .Equal (t , newBool (true ), link .IncludeAllFields )
908893}
894+
895+ func TestArangoSearchViewLinkAndStoredValueCache (t * testing.T ) {
896+ ctx := context .Background ()
897+ c := createClientFromEnv (t , true )
898+ // feature was introduced in 3.9.5 and in 3.10.2:
899+ skipBelowVersion (c , "3.9.5" , t )
900+ skipBetweenVersions (c , "3.10.0" , "3.10.1" , t )
901+ skipNoEnterprise (t )
902+ db := ensureDatabase (ctx , c , "view_test_links_stored_value_cache" , nil , t )
903+ linkedColName := "linkedColumn"
904+ ensureCollection (ctx , db , linkedColName , nil , t )
905+ name := "test_create_asview"
906+ opts := & driver.ArangoSearchViewProperties {
907+ StoredValues : []driver.StoredValue {
908+ {
909+ Fields : []string {"f1" , "f2" },
910+ Cache : newBool (true ),
911+ },
912+ },
913+ Links : driver.ArangoSearchLinks {
914+ linkedColName : driver.ArangoSearchElementProperties {
915+ Cache : newBool (false ),
916+ },
917+ },
918+ }
919+ v , err := db .CreateArangoSearchView (ctx , name , opts )
920+ require .NoError (t , err )
921+
922+ // check props
923+ p , err := v .Properties (ctx )
924+ require .NoError (t , err )
925+ require .Len (t , p .StoredValues , 1 )
926+ require .Equal (t , newBool (true ), p .StoredValues [0 ].Cache )
927+ linkedColumnProps := p .Links [linkedColName ]
928+ require .NotNil (t , linkedColumnProps )
929+ require .Nil (t , linkedColumnProps .Cache )
930+ // update props: set to cached
931+ p .Links [linkedColName ] = driver.ArangoSearchElementProperties {Cache : newBool (true )}
932+ err = v .SetProperties (ctx , p )
933+ require .NoError (t , err )
934+
935+ // check updates applied
936+ p , err = v .Properties (ctx )
937+ require .NoError (t , err )
938+ linkedColumnProps = p .Links [linkedColName ]
939+ require .NotNil (t , linkedColumnProps )
940+ require .Equal (t , newBool (true ), linkedColumnProps .Cache )
941+ }
942+
943+ func TestArangoSearchViewInMemoryCache (t * testing.T ) {
944+ ctx := context .Background ()
945+ c := createClientFromEnv (t , true )
946+
947+ skipNoEnterprise (t )
948+ db := ensureDatabase (ctx , c , "view_test_in_memory_cache" , nil , t )
949+
950+ t .Run ("primarySortCache" , func (t * testing.T ) {
951+ // feature was introduced in 3.9.5 and in 3.10.2:
952+ skipBelowVersion (c , "3.9.5" , t )
953+ skipBetweenVersions (c , "3.10.0" , "3.10.1" , t )
954+
955+ name := "test_create_asview"
956+ opts := & driver.ArangoSearchViewProperties {
957+ PrimarySortCache : newBool (true ),
958+ }
959+ v , err := db .CreateArangoSearchView (ctx , name , opts )
960+ require .NoError (t , err )
961+
962+ p , err := v .Properties (ctx )
963+ require .NoError (t , err )
964+ // bug in arangod: the primarySortCache field is not returned in response. Fixed only in 3.9.6+:
965+ t .Run ("must-be-returned-in-response" , func (t * testing.T ) {
966+ skipBelowVersion (c , "3.9.6" , t )
967+ require .Equal (t , newBool (true ), p .PrimarySortCache )
968+ })
969+ })
970+
971+ t .Run ("primaryKeyCache" , func (t * testing.T ) {
972+ // feature was introduced in 3.9.6 and 3.10.2:
973+ skipBelowVersion (c , "3.9.6" , t )
974+ skipBetweenVersions (c , "3.10.0" , "3.10.1" , t )
975+
976+ name := "test_view_"
977+ opts := & driver.ArangoSearchViewProperties {
978+ PrimaryKeyCache : newBool (true ),
979+ }
980+ v , err := db .CreateArangoSearchView (ctx , name , opts )
981+ require .NoError (t , err )
982+
983+ p , err := v .Properties (ctx )
984+ require .NoError (t , err )
985+ require .Equal (t , newBool (true ), p .PrimaryKeyCache )
986+ })
987+ }
0 commit comments