github.com/weaviate/weaviate@v1.24.6/test/modules/backup-azure/multi_tenant_backup_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  	"fmt"
    17  	"testing"
    18  	"time"
    19  
    20  	"github.com/stretchr/testify/require"
    21  	"github.com/weaviate/weaviate/test/docker"
    22  	"github.com/weaviate/weaviate/test/helper"
    23  	"github.com/weaviate/weaviate/test/helper/journey"
    24  	moduleshelper "github.com/weaviate/weaviate/test/helper/modules"
    25  )
    26  
    27  const (
    28  	numTenants = 50
    29  )
    30  
    31  func Test_MultiTenantBackupJourney(t *testing.T) {
    32  	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Minute)
    33  	defer cancel()
    34  
    35  	tenantNames := make([]string, numTenants)
    36  	for i := range tenantNames {
    37  		tenantNames[i] = fmt.Sprintf("Tenant%d", i)
    38  	}
    39  
    40  	t.Run("single node", func(t *testing.T) {
    41  		t.Log("pre-instance env setup")
    42  		t.Setenv(envAzureContainer, azureBackupJourneyContainerName)
    43  
    44  		compose, err := docker.New().
    45  			WithBackendAzure(azureBackupJourneyContainerName).
    46  			WithText2VecContextionary().
    47  			WithWeaviate().
    48  			Start(ctx)
    49  		require.Nil(t, err)
    50  
    51  		t.Log("post-instance env setup")
    52  		azuriteEndpoint := compose.GetAzurite().URI()
    53  		t.Setenv(envAzureEndpoint, azuriteEndpoint)
    54  		moduleshelper.CreateAzureContainer(ctx, t, azuriteEndpoint, azureBackupJourneyContainerName)
    55  		helper.SetupClient(compose.GetWeaviate().URI())
    56  
    57  		t.Run("backup-azure", func(t *testing.T) {
    58  			journey.BackupJourneyTests_SingleNode(t, compose.GetWeaviate().URI(),
    59  				"azure", azureBackupJourneyClassName, azureBackupJourneyBackupIDSingleNode, tenantNames)
    60  		})
    61  
    62  		require.Nil(t, compose.Terminate(ctx))
    63  	})
    64  
    65  	t.Run("multiple node", func(t *testing.T) {
    66  		t.Log("pre-instance env setup")
    67  		t.Setenv(envAzureContainer, azureBackupJourneyContainerName)
    68  
    69  		compose, err := docker.New().
    70  			WithBackendAzure(azureBackupJourneyContainerName).
    71  			WithText2VecContextionary().
    72  			WithWeaviateCluster().
    73  			Start(ctx)
    74  		require.Nil(t, err)
    75  
    76  		t.Log("post-instance env setup")
    77  		azuriteEndpoint := compose.GetAzurite().URI()
    78  		t.Setenv(envAzureEndpoint, azuriteEndpoint)
    79  		moduleshelper.CreateAzureContainer(ctx, t, azuriteEndpoint, azureBackupJourneyContainerName)
    80  		helper.SetupClient(compose.GetWeaviate().URI())
    81  
    82  		t.Run("backup-azure", func(t *testing.T) {
    83  			journey.BackupJourneyTests_Cluster(t, "azure", azureBackupJourneyClassName,
    84  				azureBackupJourneyBackupIDCluster, tenantNames, compose.GetWeaviate().URI(), compose.GetWeaviateNode2().URI())
    85  		})
    86  
    87  		require.Nil(t, compose.Terminate(ctx))
    88  	})
    89  }