github.com/weaviate/weaviate@v1.24.6/test/acceptance/schema/get_schema_without_client_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  	"encoding/json"
    16  	"fmt"
    17  	"net/http"
    18  	"testing"
    19  
    20  	"github.com/stretchr/testify/assert"
    21  	"github.com/stretchr/testify/require"
    22  	"github.com/weaviate/weaviate/entities/vectorindex/hnsw"
    23  	"github.com/weaviate/weaviate/test/helper"
    24  )
    25  
    26  func testGetSchemaWithoutClient(t *testing.T) {
    27  	res, err := http.Get(fmt.Sprintf("%s%s", helper.GetWeaviateURL(), "/v1/schema"))
    28  	require.Nil(t, err)
    29  
    30  	defer res.Body.Close()
    31  	var body map[string]interface{}
    32  	err = json.NewDecoder(res.Body).Decode(&body)
    33  	require.Nil(t, err)
    34  
    35  	expected := map[string]interface{}{
    36  		"classes": []interface{}{
    37  			map[string]interface{}{
    38  				"class":           "YellowCars",
    39  				"properties":      (interface{})(nil),
    40  				"vectorIndexType": "hnsw", // from default
    41  				"vectorIndexConfig": map[string]interface{}{ // from default
    42  					"skip":                   false,
    43  					"cleanupIntervalSeconds": float64(300),
    44  					"efConstruction":         float64(128),
    45  					"flatSearchCutoff":       float64(40000),
    46  					"ef":                     float64(-1),
    47  					"maxConnections":         float64(64),
    48  					"vectorCacheMaxObjects":  float64(1e12),
    49  					"dynamicEfMin":           float64(100),
    50  					"dynamicEfMax":           float64(500),
    51  					"dynamicEfFactor":        float64(8),
    52  					"distance":               "cosine",
    53  					"bq": map[string]interface{}{
    54  						"enabled": false,
    55  					},
    56  					"pq": map[string]interface{}{
    57  						"bitCompression": false,
    58  						"centroids":      float64(256),
    59  						"enabled":        false,
    60  						"encoder": map[string]interface{}{
    61  							"distribution": "log-normal",
    62  							"type":         hnsw.PQEncoderTypeKMeans,
    63  						},
    64  						"segments":      float64(0),
    65  						"trainingLimit": float64(100000),
    66  					},
    67  				},
    68  				"shardingConfig": map[string]interface{}{
    69  					"actualCount":         float64(1),
    70  					"actualVirtualCount":  float64(128),
    71  					"desiredCount":        float64(1),
    72  					"desiredVirtualCount": float64(128),
    73  					"function":            "murmur3",
    74  					"strategy":            "hash",
    75  					"key":                 "_id",
    76  					"virtualPerPhysical":  float64(128),
    77  				},
    78  				"replicationConfig": map[string]interface{}{
    79  					"factor": float64(1),
    80  				},
    81  				"vectorizer": "text2vec-contextionary", // global default from env var, see docker-compose-test.yml
    82  				"invertedIndexConfig": map[string]interface{}{
    83  					"cleanupIntervalSeconds": float64(60),
    84  					"bm25": map[string]interface{}{
    85  						"k1": float64(1.2),
    86  						"b":  float64(0.75),
    87  					},
    88  					"stopwords": map[string]interface{}{
    89  						"preset":    "en",
    90  						"additions": nil,
    91  						"removals":  nil,
    92  					},
    93  				},
    94  				"moduleConfig": map[string]interface{}{
    95  					"text2vec-contextionary": map[string]interface{}{
    96  						"vectorizeClassName": true,
    97  					},
    98  				},
    99  				"multiTenancyConfig": map[string]interface{}{"enabled": false},
   100  			},
   101  		},
   102  	}
   103  
   104  	assert.Equal(t, expected, body)
   105  }