github.com/weaviate/weaviate@v1.24.6/test/helper/journey/cluster_backup_journey.go (about) 1 // _ _ 2 // __ _____ __ ___ ___ __ _| |_ ___ 3 // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \ 4 // \ V V / __/ (_| |\ V /| | (_| | || __/ 5 // \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___| 6 // 7 // Copyright © 2016 - 2024 Weaviate B.V. All rights reserved. 8 // 9 // CONTACT: hello@weaviate.io 10 // 11 12 package journey 13 14 import ( 15 "fmt" 16 "math/rand" 17 "testing" 18 19 "github.com/weaviate/weaviate/entities/models" 20 "github.com/weaviate/weaviate/test/helper" 21 ) 22 23 func clusterBackupJourneyTest(t *testing.T, backend, className, 24 backupID, coordinatorEndpoint string, tenantNames []string, pqEnabled bool, 25 nodeEndpoints ...string, 26 ) { 27 uploaderEndpoint := nodeEndpoints[rand.Intn(len(nodeEndpoints))] 28 helper.SetupClient(uploaderEndpoint) 29 t.Logf("uploader selected -> %s:%s", helper.ServerHost, helper.ServerPort) 30 31 if len(tenantNames) > 0 { 32 // upload data to a node other than the coordinator 33 t.Run(fmt.Sprintf("add test data to endpoint: %s", uploaderEndpoint), func(t *testing.T) { 34 addTestClass(t, className, multiTenant) 35 tenants := make([]*models.Tenant, len(tenantNames)) 36 for i := range tenantNames { 37 tenants[i] = &models.Tenant{Name: tenantNames[i]} 38 } 39 helper.CreateTenants(t, className, tenants) 40 addTestObjects(t, className, tenantNames) 41 }) 42 } else { 43 // upload data to a node other than the coordinator 44 t.Run(fmt.Sprintf("add test data to endpoint: %s", uploaderEndpoint), func(t *testing.T) { 45 addTestClass(t, className, !multiTenant) 46 addTestObjects(t, className, nil) 47 }) 48 } 49 50 if pqEnabled { 51 pq := map[string]interface{}{ 52 "enabled": true, 53 "segments": 1, 54 "centroids": 16, 55 } 56 helper.EnablePQ(t, className, pq) 57 } 58 59 helper.SetupClient(coordinatorEndpoint) 60 t.Logf("coordinator selected -> %s:%s", helper.ServerHost, helper.ServerPort) 61 62 // send backup requests to the chosen coordinator 63 t.Run(fmt.Sprintf("with coordinator endpoint: %s", coordinatorEndpoint), func(t *testing.T) { 64 backupJourney(t, className, backend, backupID, clusterJourney, 65 checkClassAndDataPresence, tenantNames, pqEnabled) 66 }) 67 68 t.Run("cleanup", func(t *testing.T) { 69 helper.DeleteClass(t, className) 70 }) 71 } 72 73 func clusterBackupEmptyClassJourneyTest(t *testing.T, backend, className, backupID, 74 coordinatorEndpoint string, tenantNames []string, nodeEndpoints ...string, 75 ) { 76 uploaderEndpoint := nodeEndpoints[rand.Intn(len(nodeEndpoints))] 77 helper.SetupClient(uploaderEndpoint) 78 t.Logf("uploader selected -> %s:%s", helper.ServerHost, helper.ServerPort) 79 80 if len(tenantNames) > 0 { 81 // upload data to a node other than the coordinator 82 t.Run(fmt.Sprintf("add test data to endpoint: %s", uploaderEndpoint), func(t *testing.T) { 83 addTestClass(t, className, multiTenant) 84 tenants := make([]*models.Tenant, len(tenantNames)) 85 for i := range tenantNames { 86 tenants[i] = &models.Tenant{Name: tenantNames[i]} 87 } 88 helper.CreateTenants(t, className, tenants) 89 }) 90 } else { 91 // upload data to a node other than the coordinator 92 t.Run(fmt.Sprintf("add test data to endpoint: %s", uploaderEndpoint), func(t *testing.T) { 93 addTestClass(t, className, !multiTenant) 94 }) 95 } 96 97 helper.SetupClient(coordinatorEndpoint) 98 t.Logf("coordinator selected -> %s:%s", helper.ServerHost, helper.ServerPort) 99 100 // send backup requests to the chosen coordinator 101 t.Run(fmt.Sprintf("with coordinator endpoint: %s", coordinatorEndpoint), func(t *testing.T) { 102 backupJourney(t, className, backend, backupID, clusterJourney, 103 checkClassPresenceOnly, tenantNames, false) 104 }) 105 106 t.Run("cleanup", func(t *testing.T) { 107 helper.DeleteClass(t, className) 108 }) 109 }