|
| 1 | +//go:build integration |
| 2 | + |
| 3 | +package test |
| 4 | + |
| 5 | +import ( |
| 6 | + "context" |
| 7 | + "crypto/rand" |
| 8 | + "fmt" |
| 9 | + "os" |
| 10 | + "testing" |
| 11 | + |
| 12 | + "github.com/aws-gopher/unstructured-sdk-go" |
| 13 | +) |
| 14 | + |
| 15 | +func TestDestinationPermutations(t *testing.T) { |
| 16 | + t.Parallel() |
| 17 | + |
| 18 | + if os.Getenv("UNSTRUCTURED_API_KEY") == "" { |
| 19 | + t.Skip("skipping because UNSTRUCTURED_API_KEY is not set") |
| 20 | + } |
| 21 | + |
| 22 | + client, err := unstructured.New() |
| 23 | + if err != nil { |
| 24 | + t.Fatalf("failed to create client: %v", err) |
| 25 | + } |
| 26 | + |
| 27 | + for name, src := range map[string]unstructured.DestinationConfigInput{ |
| 28 | + "astra-db": unstructured.AstraDBConnectorConfigInput{ |
| 29 | + CollectionName: "foo", |
| 30 | + APIEndpoint: "https://foo.apps.astra.datastax.com", |
| 31 | + Token: "foo", |
| 32 | + }, |
| 33 | + |
| 34 | + "azure-ai-search": unstructured.AzureAISearchConnectorConfigInput{ |
| 35 | + Endpoint: "https://foo.search.windows.net", |
| 36 | + Index: "foo", |
| 37 | + Key: "foo", |
| 38 | + }, |
| 39 | + |
| 40 | + "couchbase": unstructured.CouchbaseDestinationConnectorConfigInput{ |
| 41 | + Bucket: "foo", |
| 42 | + ConnectionString: "couchbase://foo", |
| 43 | + Username: "foo", |
| 44 | + Password: "foo", |
| 45 | + BatchSize: 100, |
| 46 | + }, |
| 47 | + |
| 48 | + // server responds 500 |
| 49 | + // "databricks-volume-delta-table": unstructured.DatabricksVDTDestinationConnectorConfigInput{ |
| 50 | + // ServerHostname: "foo.cloud.databricks.com", |
| 51 | + // HTTPPath: "/sql/1.0/warehouses/foo", |
| 52 | + // Token: S("foo"), |
| 53 | + // Catalog: "foo", |
| 54 | + // Volume: "foo", |
| 55 | + // }, |
| 56 | + |
| 57 | + "delta-table": unstructured.DeltaTableConnectorConfigInput{ |
| 58 | + AwsAccessKeyID: "foo", |
| 59 | + AwsSecretAccessKey: "foo", |
| 60 | + AwsRegion: "us-east-1", |
| 61 | + TableURI: "s3://foo/table", |
| 62 | + }, |
| 63 | + |
| 64 | + "elasticsearch": unstructured.ElasticsearchConnectorConfigInput{ |
| 65 | + Hosts: []string{"https://foo.elastic-cloud.com"}, |
| 66 | + IndexName: "foo", |
| 67 | + ESAPIKey: "foo", |
| 68 | + }, |
| 69 | + |
| 70 | + "gcs": unstructured.GCSDestinationConnectorConfigInput{ |
| 71 | + RemoteURL: "gs://foo", |
| 72 | + ServiceAccountKey: "foo", |
| 73 | + }, |
| 74 | + |
| 75 | + // server responds 412 asking for `bootstrap_server` instead of `bootstrap_servers` |
| 76 | + // "kafka-cloud": unstructured.KafkaCloudDestinationConnectorConfigInput{ |
| 77 | + // BootstrapServers: "foo.cloud.confluent.io", |
| 78 | + // Topic: "foo", |
| 79 | + // KafkaAPIKey: "foo", |
| 80 | + // Secret: "foo", |
| 81 | + // }, |
| 82 | + |
| 83 | + "milvus-token": unstructured.MilvusDestinationConnectorConfigInput{ |
| 84 | + URI: "https://foo.zilliz.com", |
| 85 | + CollectionName: "foo", |
| 86 | + RecordIDKey: "foo", |
| 87 | + Token: S("foo"), |
| 88 | + }, |
| 89 | + "milvus-password": unstructured.MilvusDestinationConnectorConfigInput{ |
| 90 | + URI: "https://foo.zilliz.com", |
| 91 | + CollectionName: "foo", |
| 92 | + RecordIDKey: "foo", |
| 93 | + User: S("foo"), |
| 94 | + Password: S("foo"), |
| 95 | + }, |
| 96 | + |
| 97 | + "mongo-db": unstructured.MongoDBConnectorConfigInput{ |
| 98 | + Database: "foo", |
| 99 | + Collection: "foo", |
| 100 | + URI: "mongodb://foo:27017/foo", |
| 101 | + }, |
| 102 | + |
| 103 | + // server responds 422: Destination Connector type motherduck not supported |
| 104 | + // "mother-duck": unstructured.MotherduckDestinationConnectorConfigInput{ |
| 105 | + // Account: "foo", |
| 106 | + // Role: "foo", |
| 107 | + // User: "foo", |
| 108 | + // Password: "foo", |
| 109 | + // Host: "foo.duckdb.io", |
| 110 | + // Database: "foo", |
| 111 | + // }, |
| 112 | + |
| 113 | + "neo4j": unstructured.Neo4jDestinationConnectorConfigInput{ |
| 114 | + URI: "bolt://foo:7687", |
| 115 | + Database: "foo", |
| 116 | + Username: "foo", |
| 117 | + Password: "foo", |
| 118 | + }, |
| 119 | + |
| 120 | + "one-drive": unstructured.OneDriveDestinationConnectorConfigInput{ |
| 121 | + ClientID: "foo", |
| 122 | + UserPName: "foo", |
| 123 | + Tenant: "foo", |
| 124 | + AuthorityURL: "https://login.microsoftonline.com/foo", |
| 125 | + ClientCred: "foo", |
| 126 | + RemoteURL: "onedrive://foo", |
| 127 | + }, |
| 128 | + |
| 129 | + "pinecone": unstructured.PineconeDestinationConnectorConfigInput{ |
| 130 | + IndexName: "foo", |
| 131 | + APIKey: "foo", |
| 132 | + Namespace: "foo", |
| 133 | + }, |
| 134 | + |
| 135 | + "postgres": unstructured.PostgresDestinationConnectorConfigInput{ |
| 136 | + Host: "foo.com", |
| 137 | + Database: "foo", |
| 138 | + Port: 5432, |
| 139 | + Username: "foo", |
| 140 | + Password: "foo", |
| 141 | + TableName: "foo", |
| 142 | + BatchSize: 100, |
| 143 | + }, |
| 144 | + |
| 145 | + "redis": unstructured.RedisDestinationConnectorConfigInput{ |
| 146 | + Host: "foo.com", |
| 147 | + Username: S("foo"), |
| 148 | + Password: S("foo"), |
| 149 | + }, |
| 150 | + |
| 151 | + "qdrant-cloud": unstructured.QdrantCloudDestinationConnectorConfigInput{ |
| 152 | + URL: "https://foo.qdrant.io", |
| 153 | + APIKey: "foo", |
| 154 | + CollectionName: "foo", |
| 155 | + }, |
| 156 | + |
| 157 | + "s3": unstructured.S3DestinationConnectorConfigInput{ |
| 158 | + RemoteURL: "s3://foo", |
| 159 | + Key: S("foo"), |
| 160 | + Secret: S("foo"), |
| 161 | + }, |
| 162 | + |
| 163 | + // server responds 500 |
| 164 | + // "snowflake": unstructured.SnowflakeDestinationConnectorConfigInput{ |
| 165 | + // Account: "foo", |
| 166 | + // Role: "foo", |
| 167 | + // User: "foo", |
| 168 | + // Password: "foo", |
| 169 | + // Host: "foo.snowflakecomputing.com", |
| 170 | + // Database: "foo", |
| 171 | + // }, |
| 172 | + |
| 173 | + "weaviate-cloud": unstructured.WeaviateDestinationConnectorConfigInput{ |
| 174 | + ClusterURL: "https://foo.weaviate.network", |
| 175 | + APIKey: "foo", |
| 176 | + }, |
| 177 | + |
| 178 | + "ibm-watsonx-s3": unstructured.IBMWatsonxS3DestinationConnectorConfigInput{ |
| 179 | + IAMApiKey: "foo", |
| 180 | + AccessKeyID: "foo", |
| 181 | + SecretAccessKey: "foo", |
| 182 | + IcebergEndpoint: "https://foo.iceberg.cloud.ibm.com", |
| 183 | + ObjectStorageEndpoint: "https://foo.s3.cloud.ibm.com", |
| 184 | + ObjectStorageRegion: "us-east", |
| 185 | + Catalog: "foo", |
| 186 | + Namespace: "foo", |
| 187 | + Table: "foo", |
| 188 | + }, |
| 189 | + |
| 190 | + // server responds 500 |
| 191 | + // "databricks-volumes": unstructured.DatabricksVolumesConnectorConfigInput{ |
| 192 | + // Host: "foo.cloud.databricks.com", |
| 193 | + // Catalog: "foo", |
| 194 | + // Volume: "foo", |
| 195 | + // VolumePath: "/foo", |
| 196 | + // ClientSecret: "foo", |
| 197 | + // ClientID: "foo", |
| 198 | + // }, |
| 199 | + } { |
| 200 | + t.Run(name, func(t *testing.T) { |
| 201 | + t.Parallel() |
| 202 | + |
| 203 | + destination, err := client.CreateDestination(t.Context(), unstructured.CreateDestinationRequest{ |
| 204 | + Name: fmt.Sprintf("test-%s-%s", name, rand.Text()), |
| 205 | + Config: src, |
| 206 | + }) |
| 207 | + if err != nil { |
| 208 | + t.Fatalf("failed to create destination: %v", err) |
| 209 | + } |
| 210 | + |
| 211 | + t.Cleanup(func() { _ = client.DeleteDestination(context.Background(), destination.ID) }) |
| 212 | + }) |
| 213 | + } |
| 214 | +} |
0 commit comments