github.com/weaviate/weaviate@v1.24.6/test/modules/multi2vec-palm/setup_test.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 multi2vec_palm_tests 13 14 import ( 15 "context" 16 "os" 17 "testing" 18 19 "github.com/stretchr/testify/require" 20 "github.com/weaviate/weaviate/test/docker" 21 ) 22 23 const ( 24 location = "us-central1" 25 ) 26 27 func TestNamedVectors_SingleNode(t *testing.T) { 28 gcpProject := os.Getenv("GCP_PROJECT") 29 if gcpProject == "" { 30 t.Skip("skipping, GCP_PROJECT environment variable not present") 31 } 32 palmApiKey := os.Getenv("PALM_APIKEY") 33 if palmApiKey == "" { 34 t.Skip("skipping, PALM_APIKEY environment variable not present") 35 } 36 ctx := context.Background() 37 compose, err := createSingleNodeEnvironment(ctx, palmApiKey) 38 require.NoError(t, err) 39 defer func() { 40 require.NoError(t, compose.Terminate(ctx)) 41 }() 42 endpoint := compose.GetWeaviate().URI() 43 44 t.Run("tests", testMulti2VecPaLM(endpoint, gcpProject, location)) 45 } 46 47 func TestNamedVectors_Cluster(t *testing.T) { 48 gcpProject := os.Getenv("GCP_PROJECT") 49 if gcpProject == "" { 50 t.Skip("skipping, GCP_PROJECT environment variable not present") 51 } 52 palmApiKey := os.Getenv("PALM_APIKEY") 53 if palmApiKey == "" { 54 t.Skip("skipping, PALM_APIKEY environment variable not present") 55 } 56 ctx := context.Background() 57 compose, err := createClusterEnvironment(ctx, palmApiKey) 58 require.NoError(t, err) 59 defer func() { 60 require.NoError(t, compose.Terminate(ctx)) 61 }() 62 endpoint := compose.GetWeaviate().URI() 63 64 t.Run("tests", testMulti2VecPaLM(endpoint, gcpProject, location)) 65 } 66 67 func createSingleNodeEnvironment(ctx context.Context, palmApiKey string, 68 ) (compose *docker.DockerCompose, err error) { 69 compose, err = composeModules(palmApiKey). 70 WithWeaviate(). 71 Start(ctx) 72 return 73 } 74 75 func createClusterEnvironment(ctx context.Context, palmApiKey string, 76 ) (compose *docker.DockerCompose, err error) { 77 compose, err = composeModules(palmApiKey). 78 WithWeaviateCluster(). 79 Start(ctx) 80 return 81 } 82 83 func composeModules(palmApiKey string) (composeModules *docker.Compose) { 84 composeModules = docker.New(). 85 WithMulti2VecPaLM(palmApiKey) 86 return 87 }