Skip to content

Commit

Permalink
chore(upgrade): run tests from v23.1.0 -> main (#9097)
Browse files Browse the repository at this point in the history
Co-authored-by: shivaji-dgraph <shivaji@dgraph.io>
  • Loading branch information
mangalaman93 and shivaji-kharse authored May 28, 2024
1 parent fffeecd commit 96fc4f4
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 66 deletions.
5 changes: 2 additions & 3 deletions dgraphtest/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,8 @@ func AllUpgradeCombos(v20 bool) []UpgradeCombo {
// In mainCombos list, we keep latest version to current HEAD as well as
// older versions of dgraph to ensure that a change does not cause failures.
mainCombos := []UpgradeCombo{
{"v23.0.1", localVersion, BackupRestore},
{"v23.0.1", localVersion, InPlace},
{"v21.03.0", "4fc9cfd", BackupRestore},
{"v23.1.0", localVersion, BackupRestore},
{"v23.1.0", localVersion, InPlace},
}

if v20 {
Expand Down
59 changes: 32 additions & 27 deletions query/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,14 @@ type Speaker {
language
}
type User {
name
password
gender
friend
alive
}
name : string @index(term, exact, trigram) @count @lang .
name_lang : string @lang .
lang_type : string @index(exact) .
Expand Down Expand Up @@ -337,7 +345,6 @@ tweet-c : string @index(fulltext) .
tweet-d : string @index(trigram) .
name2 : string @index(term) .
age2 : int @index(int) .
vectorNonIndex : float32vector .
`

func populateCluster(dc dgraphtest.Cluster) {
Expand All @@ -348,32 +355,30 @@ func populateCluster(dc dgraphtest.Cluster) {
// all the UIDs we are using during the tests.
x.Panic(dc.AssignUids(client.Dgraph, 65536))

higher, err := dgraphtest.IsHigherVersion(dc.GetVersion(), "160a0faa5fc6233fdc5a4caa4a7a3d1591f460d0")
x.Panic(err)
var ts string
if higher {
ts = testSchema + `type User {
name
password
gender
friend
alive
user_profile
}
user_profile : float32vector @index(hnsw(metric:"euclidian")) .`
} else {
ts = testSchema + `type User {
name
password
gender
friend
alive
}`
}
setSchema(ts)
err = addTriplesToCluster(`
<1> <vectorNonIndex> "[1.0, 1.0, 2.0, 2.0]" .
<2> <vectorNonIndex> "[2.0, 1.0, 2.0, 2.0]" .
// higher, err := dgraphtest.IsHigherVersion(dc.GetVersion(), "160a0faa5fc6233fdc5a4caa4a7a3d1591f460d0")
// x.Panic(err)
// var ts string
// if higher {
// ts = testSchema + `type User {
// name
// password
// gender
// friend
// alive
// user_profile
// }
// user_profile : float32vector @index(hnsw(metric:"euclidian")) .`
// } else {
// ts = testSchema + `type User {
// name
// password
// gender
// friend
// alive
// }`
// }
setSchema(testSchema)
err := addTriplesToCluster(`
<1> <name> "Michonne" .
<2> <name> "King Lear" .
<3> <name> "Margaret" .
Expand Down
36 changes: 0 additions & 36 deletions query/query0_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,42 +31,6 @@ import (
"github.com/dgraph-io/dgraph/dql"
)

func TestGetVector(t *testing.T) {
query := `
{
me(func: has(vectorNonIndex)) {
a as vectorNonIndex
}
aggregation() {
avg(val(a))
sum(val(a))
}
}
`
js := processQueryNoErr(t, query)
k := `{
"data": {
"me": [
{
"vectorNonIndex": [1,1,2,2]
},
{
"vectorNonIndex": [2,1,2,2]
}
],
"aggregation": [
{
"avg(val(a))": [1.5,1,2,2]
},
{
"sum(val(a))": [3,2,4,4]
}
]
}
}`
require.JSONEq(t, k, js)
}

func TestGetUID(t *testing.T) {
query := `
{
Expand Down
63 changes: 63 additions & 0 deletions query/vector/vector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -727,3 +727,66 @@ func TestVectorTwoTxnWithoutCommit(t *testing.T) {
require.Contains(t, resp, vectors[i])
}
}

func TestGetVector(t *testing.T) {
setSchema("vectorNonIndex : float32vector .")

rdfs := `
<1> <vectorNonIndex> "[1.0, 1.0, 2.0, 2.0]" .
<2> <vectorNonIndex> "[2.0, 1.0, 2.0, 2.0]" .`
require.NoError(t, addTriplesToCluster(rdfs))

query := `
{
me(func: has(vectorNonIndex)) {
a as vectorNonIndex
}
aggregation() {
avg(val(a))
sum(val(a))
}
}
`
js := processQueryNoErr(t, query)
k := `{
"data": {
"me": [
{
"vectorNonIndex": [
1,
1,
2,
2
]
},
{
"vectorNonIndex": [
2,
1,
2,
2
]
}
],
"aggregation": [
{
"avg(val(a))": [
1.5,
1,
2,
2
]
},
{
"sum(val(a))": [
3,
2,
4,
4
]
}
]
}
}`
require.JSONEq(t, k, js)
}

0 comments on commit 96fc4f4

Please sign in to comment.