github.com/weaviate/weaviate@v1.24.6/test/modules/backup-s3/node_mapping_backup_journey_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 test
    13  
    14  import (
    15  	"context"
    16  	"testing"
    17  	"time"
    18  
    19  	"github.com/stretchr/testify/require"
    20  	"github.com/weaviate/weaviate/test/docker"
    21  	"github.com/weaviate/weaviate/test/helper"
    22  	"github.com/weaviate/weaviate/test/helper/journey"
    23  )
    24  
    25  func Test_NodeMappingBackupJourney(t *testing.T) {
    26  	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Minute)
    27  	defer cancel()
    28  
    29  	t.Run("single node", func(t *testing.T) {
    30  		t.Log("pre-instance env setup")
    31  		t.Setenv(envS3AccessKey, s3BackupJourneyAccessKey)
    32  		t.Setenv(envS3SecretKey, s3BackupJourneySecretKey)
    33  		t.Setenv(envS3Bucket, s3BackupJourneyBucketName)
    34  
    35  		compose, err := docker.New().
    36  			WithBackendS3(s3BackupJourneyBucketName).
    37  			WithText2VecContextionary().
    38  			WithWeaviate().
    39  			WithSecondWeaviate().
    40  			Start(ctx)
    41  		require.Nil(t, err)
    42  		defer func() {
    43  			if err := compose.Terminate(ctx); err != nil {
    44  				t.Fatalf("failed to terminate test containers: %s", err.Error())
    45  			}
    46  		}()
    47  
    48  		t.Run("post-instance env setup", func(t *testing.T) {
    49  			createBucket(ctx, t, compose.GetMinIO().URI(), s3BackupJourneyRegion, s3BackupJourneyBucketName)
    50  			helper.SetupClient(compose.GetWeaviate().URI())
    51  		})
    52  
    53  		t.Run("backup-s3", func(t *testing.T) {
    54  			journey.NodeMappingBackupJourneyTests_SingleNode_Backup(t, compose.GetWeaviate().URI(),
    55  				"s3", s3BackupJourneyClassName, s3BackupJourneyBackupIDSingleNode, nil)
    56  		})
    57  
    58  		// Now change our tests to use the second cluster and trigger a backup restore
    59  		helper.SetupClient(compose.GetSecondWeaviate().URI())
    60  
    61  		t.Run("restore-s3", func(t *testing.T) {
    62  			journey.NodeMappingBackupJourneyTests_SingleNode_Restore(t, compose.GetSecondWeaviate().URI(),
    63  				"s3", s3BackupJourneyClassName, s3BackupJourneyBackupIDSingleNode, nil, map[string]string{
    64  					docker.Weaviate: docker.SecondWeaviate,
    65  				})
    66  		})
    67  	})
    68  }