This is an automated email from the ASF dual-hosted git repository.

zeroshade pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-go.git


The following commit(s) were added to refs/heads/main by this push:
     new 94365c1  feat(catalog/rest): Add create view integration test (#387)
94365c1 is described below

commit 94365c121aae4299a1831179f7e3d626ebbfcba9
Author: Dao Thanh Tung <[email protected]>
AuthorDate: Fri Apr 11 18:40:19 2025 +0100

    feat(catalog/rest): Add create view integration test (#387)
    
    As mentioned in the previous comment
    https://github.com/apache/iceberg-go/pull/376#pullrequestreview-2747444932
    
    I managed to create a test bash script to run the integration test
    successfully locally. Most of it is a reference from the github action
    file
    
https://github.com/apache/iceberg-go/blob/main/.github/workflows/go-integration.yml.
    Might be worth mentioning in the CONTRIBUTING guide
    
    ```
    #!/bin/bash
    # Integration test script for iceberg-go
    
    set -e  # Exit on any error
    
    # Start docker services
    echo "Starting docker services..."
    docker compose -f dev/docker-compose.yml up -d
    
    # Wait for services to be ready
    echo "Waiting for services to start..."
    sleep 10
    
    # Provision tables in the test environment
    echo "Provisioning tables..."
    docker compose -f dev/docker-compose.yml exec -T spark-iceberg ipython 
./provision.py
    sleep 10
    
    # Get the Minio container IP for S3 endpoint
    MINIO_IP=$(docker inspect -f 
'{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' minio)
    export AWS_S3_ENDPOINT="http://${MINIO_IP}:9000";
    export AWS_REGION="us-east-1"
    
    echo "Using S3 endpoint: $AWS_S3_ENDPOINT"
    
    # Run the integration tests
    echo "Running table scanner integration tests..."
    go test -tags integration -v -run="^TestScanner" ./table
    
    echo "Running IO integration tests..."
    go test -tags integration -v ./io
    
    echo "Running REST catalog integration tests..."
    #go test -tags integration -v -run="^TestRestIntegration$" ./catalog/rest
    go test -tags integration -v -run="^TestRestIntegration/TestCreateView$" 
./catalog/rest
    
    # Cleanup
    echo "Cleaning up..."
    docker compose -f dev/docker-compose.yml down
    
    echo "Done!"
    ```
    
    Signed-off-by: dttung2905 <[email protected]>
---
 catalog/rest/rest_integration_test.go | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/catalog/rest/rest_integration_test.go 
b/catalog/rest/rest_integration_test.go
index c9b57bb..edba0d5 100644
--- a/catalog/rest/rest_integration_test.go
+++ b/catalog/rest/rest_integration_test.go
@@ -21,6 +21,7 @@ package rest_test
 
 import (
        "context"
+       "fmt"
        "net/url"
        "testing"
 
@@ -181,6 +182,39 @@ func (s *RestIntegrationSuite) TestCreateTable() {
        s.Require().NoError(s.cat.DropTable(s.ctx, 
catalog.ToIdentifier(TestNamespaceIdent, "test-table")))
 }
 
+func (s *RestIntegrationSuite) TestCreateView() {
+       s.ensureNamespace()
+
+       const location = "s3://warehouse/iceberg"
+       // create a table first
+       tbl, err := s.cat.CreateTable(s.ctx,
+               catalog.ToIdentifier(TestNamespaceIdent, "test-table"),
+               tableSchemaSimple, 
catalog.WithProperties(iceberg.Properties{"foobar": "baz"}),
+               catalog.WithLocation(location))
+       s.Require().NoError(err)
+       s.Require().NotNil(tbl)
+
+       s.Equal(location, tbl.Location())
+       s.Equal("baz", tbl.Properties()["foobar"])
+
+       exists, err := s.cat.CheckTableExists(s.ctx, 
catalog.ToIdentifier(TestNamespaceIdent, "test-table"))
+       s.Require().NoError(err)
+       s.True(exists)
+
+       // Create a view
+       viewSQL := fmt.Sprintf("SELECT * FROM  %s.%s", TestNamespaceIdent, 
"test-table")
+
+       err = s.cat.CreateView(s.ctx, catalog.ToIdentifier(TestNamespaceIdent, 
"test-view"), tableSchemaSimple, viewSQL, iceberg.Properties{"foobar": "baz"})
+       s.Require().NoError(err)
+
+       exists, err = s.cat.CheckViewExists(s.ctx, 
catalog.ToIdentifier(TestNamespaceIdent, "test-view"))
+       s.Require().NoError(err)
+       s.True(exists)
+
+       s.Require().NoError(s.cat.DropTable(s.ctx, 
catalog.ToIdentifier(TestNamespaceIdent, "test-table")))
+       s.Require().NoError(s.cat.DropView(s.ctx, 
catalog.ToIdentifier(TestNamespaceIdent, "test-view")))
+}
+
 func (s *RestIntegrationSuite) TestWriteCommitTable() {
        s.ensureNamespace()
 

Reply via email to