Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate tests related to changing replication factor at runtime #4749

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 0 additions & 30 deletions test/acceptance/replication/crud_ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,14 @@ import (
"github.com/go-openapi/strfmt"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/weaviate/weaviate/client/nodes"
"github.com/weaviate/weaviate/client/objects"
"github.com/weaviate/weaviate/entities/filters"
"github.com/weaviate/weaviate/entities/models"
"github.com/weaviate/weaviate/entities/verbosity"
"github.com/weaviate/weaviate/test/helper"
graphqlhelper "github.com/weaviate/weaviate/test/helper/graphql"
"github.com/weaviate/weaviate/usecases/replica"
)

func getClass(t *testing.T, host, class string) *models.Class {
t.Helper()
helper.SetupClient(host)
return helper.GetClass(t, class)
}

func updateClass(t *testing.T, host string, class *models.Class) {
t.Helper()
helper.SetupClient(host)
helper.UpdateClass(t, class)
}

func createObjectCL(t *testing.T, host string, obj *models.Object, cl replica.ConsistencyLevel) error {
t.Helper()
helper.SetupClient(host)
Expand Down Expand Up @@ -100,12 +86,6 @@ func getTenantObjectFromNode(t *testing.T, host, class string, id strfmt.UUID, n
return helper.GetTenantObjectFromNode(t, class, id, nodename, tenant)
}

func patchObject(t *testing.T, host string, patch *models.Object) {
t.Helper()
helper.SetupClient(host)
helper.PatchObject(t, patch)
}

func updateObjectCL(t *testing.T, host string, obj *models.Object, cl replica.ConsistencyLevel) error {
t.Helper()
helper.SetupClient(host)
Expand Down Expand Up @@ -272,16 +252,6 @@ func countTenantObjects(t *testing.T, host, class string,
return count
}

func getNodes(t *testing.T, host string) *models.NodesStatusResponse {
t.Helper()
helper.SetupClient(host)
verbose := verbosity.OutputVerbose
params := nodes.NewNodesGetParams().WithOutput(&verbose)
resp, err := helper.Client(t).Nodes.NodesGet(params, nil)
helper.AssertRequestOk(t, resp, err, nil)
return resp.Payload
}

func vec2String(v []interface{}) (s string) {
for _, n := range v {
x := n.(json.Number)
Expand Down
180 changes: 0 additions & 180 deletions test/acceptance/replication/crud_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/weaviate/weaviate/test/helper"
"github.com/weaviate/weaviate/test/helper/sample-schema/articles"
"github.com/weaviate/weaviate/usecases/replica"
"golang.org/x/sync/errgroup"
)

var (
Expand Down Expand Up @@ -293,185 +292,6 @@ func immediateReplicaCRUD(t *testing.T) {
})
}

func eventualReplicaCRUD(t *testing.T) {
t.Skip("To be addressed as part of https://semi-technology.atlassian.net/browse/WEAVIATE-701")
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()

compose, err := docker.New().
WithWeaviateCluster().
WithText2VecContextionary().
Start(ctx)
require.Nil(t, err)
defer func() {
if err := compose.Terminate(ctx); err != nil {
t.Fatalf("failed to terminate test containers: %s", err.Error())
}
}()

helper.SetupClient(compose.GetWeaviate().URI())
paragraphClass := articles.ParagraphsClass()
articleClass := articles.ArticlesClass()

t.Run("create schema on node 1", func(t *testing.T) {
paragraphClass.ShardingConfig = map[string]interface{}{"desiredCount": 1}
helper.CreateClass(t, paragraphClass)
articleClass.ShardingConfig = map[string]interface{}{"desiredCount": 1}
helper.CreateClass(t, articleClass)
})

t.Run("insert paragraphs batch on node 1", func(t *testing.T) {
batch := make([]*models.Object, len(paragraphIDs))
for i, id := range paragraphIDs {
batch[i] = articles.NewParagraph().
WithID(id).
WithContents(fmt.Sprintf("paragraph#%d", i)).
Object()
}
createObjects(t, compose.GetWeaviate().URI(), batch)
})

t.Run("insert articles batch on node 1", func(t *testing.T) {
batch := make([]*models.Object, len(articleIDs))
for i, id := range articleIDs {
batch[i] = articles.NewArticle().
WithID(id).
WithTitle(fmt.Sprintf("Article#%d", i)).
Object()
}
createObjects(t, compose.GetWeaviate().URI(), batch)
})

t.Run("configure classes to replicate to node 2", func(t *testing.T) {
ac := helper.GetClass(t, "Article")
ac.ReplicationConfig = &models.ReplicationConfig{
Factor: 2,
}
helper.UpdateClass(t, ac)

pc := helper.GetClass(t, "Paragraph")
pc.ReplicationConfig = &models.ReplicationConfig{
Factor: 2,
}
helper.UpdateClass(t, pc)
})

t.Run("StopNode-1", func(t *testing.T) {
stopNodeAt(ctx, t, compose, 1)
})

t.Run("assert all previous data replicated to node 2", func(t *testing.T) {
resp := gqlGet(t, compose.GetWeaviateNode2().URI(), "Article", replica.One)
assert.Len(t, resp, len(articleIDs))
resp = gqlGet(t, compose.GetWeaviateNode2().URI(), "Paragraph", replica.One)
assert.Len(t, resp, len(paragraphIDs))
})

t.Run("RestartNode-1", func(t *testing.T) {
restartNode1(ctx, t, compose)
})

t.Run("assert any future writes are replicated", func(t *testing.T) {
t.Run("PatchObject", func(t *testing.T) {
before, err := getObject(t, compose.GetWeaviate().URI(), "Article", articleIDs[0], false)
require.Nil(t, err)
newTitle := "Article#9000"

t.Run("OnNode-2", func(t *testing.T) {
patch := &models.Object{
ID: before.ID,
Class: "Article",
Properties: map[string]interface{}{"title": newTitle},
}
patchObject(t, compose.GetWeaviateNode2().URI(), patch)
})

t.Run("StopNode-2", func(t *testing.T) {
stopNodeAt(ctx, t, compose, 2)
})

t.Run("PatchedOnNode-1", func(t *testing.T) {
after, err := getObjectFromNode(t, compose.GetWeaviate().URI(), "Article", articleIDs[0], "node1")
require.Nil(t, err)

newVal, ok := after.Properties.(map[string]interface{})["title"]
require.True(t, ok)
assert.Equal(t, newTitle, newVal)
})

t.Run("RestartNode-2", func(t *testing.T) {
err = compose.Start(ctx, compose.GetWeaviateNode2().Name())
require.Nil(t, err)
})
})

t.Run("DeleteObject", func(t *testing.T) {
t.Run("OnNode-1", func(t *testing.T) {
deleteObject(t, compose.GetWeaviate().URI(), "Article", articleIDs[0])
})

t.Run("StopNode-1", func(t *testing.T) {
stopNodeAt(ctx, t, compose, 1)
})

t.Run("OnNode-2", func(t *testing.T) {
_, err := getObjectFromNode(t, compose.GetWeaviateNode2().URI(), "Article", articleIDs[0], "node2")
assert.Equal(t, &objects.ObjectsClassGetNotFound{}, err)
})

t.Run("RestartNode-1", func(t *testing.T) {
restartNode1(ctx, t, compose)
})
})

t.Run("BatchAllObjects", func(t *testing.T) {
t.Run("OnNode-2", func(t *testing.T) {
deleteObjects(t, compose.GetWeaviateNode2().URI(),
"Article", []string{"title"}, "Article#*")
})

t.Run("StopNode-2", func(t *testing.T) {
stopNodeAt(ctx, t, compose, 2)
})

t.Run("OnNode-1", func(t *testing.T) {
resp := gqlGet(t, compose.GetWeaviate().URI(), "Article", replica.One)
assert.Empty(t, resp)
})

t.Run("RestartNode-2", func(t *testing.T) {
err = compose.Start(ctx, compose.GetWeaviateNode2().Name())
require.Nil(t, err)
})
})
})
}

func restartNode1(ctx context.Context, t *testing.T, compose *docker.DockerCompose) {
// since node1 is the gossip "leader", node 2 must be stopped and restarted
// after node1 to re-facilitate internode communication
eg := errgroup.Group{}
eg.Go(func() error {
require.Nil(t, compose.StartAt(ctx, 1))
return nil
})
eg.Go(func() error { // restart node 2
time.Sleep(3 * time.Second) // wait for member list initialization
stopNodeAt(ctx, t, compose, 2)
require.Nil(t, compose.StartAt(ctx, 2))
return nil
})
eg.Go(func() error { // restart node 3
time.Sleep(3 * time.Second) // wait for member list initialization
stopNodeAt(ctx, t, compose, 3)
require.Nil(t, compose.StartAt(ctx, 3))
return nil
})

eg.Wait()
<-time.After(3 * time.Second) // wait for initialization
}

func stopNodeAt(ctx context.Context, t *testing.T, compose *docker.DockerCompose, index int) {
<-time.After(1 * time.Second)
require.Nil(t, compose.StopAt(ctx, index, nil))
Expand Down
146 changes: 0 additions & 146 deletions test/acceptance/replication/scale_test.go

This file was deleted.