Skip to content

Commit

Permalink
fix(bigquery): remove cloud run service deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarowolfx committed Sep 22, 2022
1 parent af6a651 commit bc7c995
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 65 deletions.
1 change: 0 additions & 1 deletion bigquery/go.mod
Expand Up @@ -6,7 +6,6 @@ require (
cloud.google.com/go v0.104.0
cloud.google.com/go/datacatalog v1.5.0
cloud.google.com/go/iam v0.3.0
cloud.google.com/go/run v0.1.2
cloud.google.com/go/storage v1.23.0
github.com/google/go-cmp v0.5.8
github.com/googleapis/gax-go/v2 v2.5.1
Expand Down
2 changes: 0 additions & 2 deletions bigquery/go.sum
Expand Up @@ -94,8 +94,6 @@ cloud.google.com/go/recommendationengine v0.5.0/go.mod h1:E5756pJcVFeVgaQv3WNpIm
cloud.google.com/go/recommender v1.5.0/go.mod h1:jdoeiBIVrJe9gQjwd759ecLJbxCDED4A6p+mqoqDvTg=
cloud.google.com/go/redis v1.7.0/go.mod h1:V3x5Jq1jzUcg+UNsRvdmsfuFnit1cfe3Z/PGyq/lm4Y=
cloud.google.com/go/retail v1.8.0/go.mod h1:QblKS8waDmNUhghY2TI9O3JLlFk8jybHeV4BF19FrE4=
cloud.google.com/go/run v0.1.2 h1:Fah1y/Q1U8YclV6p2rte/b5JNBUbhBnQifO7k4eznRg=
cloud.google.com/go/run v0.1.2/go.mod h1:BWliZqXKsaBc+qFx5G13Mk4uQ02bX6ye8PDkiW4qyYo=
cloud.google.com/go/scheduler v1.4.0/go.mod h1:drcJBmxF3aqZJRhmkHQ9b3uSSpQoltBPGPxGAWROx6s=
cloud.google.com/go/secretmanager v1.6.0/go.mod h1:awVa/OXF6IiyaU1wQ34inzQNc4ISIDIrId8qE5QGgKA=
cloud.google.com/go/security v1.5.0/go.mod h1:lgxGdyOKKjHL4YG3/YwIL2zLqMFCKs0UbQwgyZmfJl4=
Expand Down
11 changes: 0 additions & 11 deletions bigquery/integration_test.go
Expand Up @@ -37,7 +37,6 @@ import (
"cloud.google.com/go/internal/pretty"
"cloud.google.com/go/internal/testutil"
"cloud.google.com/go/internal/uid"
run "cloud.google.com/go/run/apiv2"
"cloud.google.com/go/storage"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
Expand All @@ -56,7 +55,6 @@ var record = flag.Bool("record", false, "record RPCs")
var (
client *Client
storageClient *storage.Client
functionsClient *run.ServicesClient
connectionsClient *connection.Client
policyTagManagerClient *datacatalog.PolicyTagManagerClient
dataset *Dataset
Expand Down Expand Up @@ -127,10 +125,6 @@ func initIntegrationTest() func() {
if err != nil {
log.Fatal(err)
}
functionsClient, err = run.NewServicesClient(ctx, option.WithHTTPClient(hc))
if err != nil {
log.Fatal(err)
}
connectionsClient, err = connection.NewClient(ctx, option.WithHTTPClient(hc))
if err != nil {
log.Fatal(err)
Expand All @@ -152,7 +146,6 @@ func initIntegrationTest() func() {
}
client = nil
storageClient = nil
functionsClient = nil
connectionsClient = nil
return func() {}

Expand Down Expand Up @@ -217,10 +210,6 @@ func initIntegrationTest() func() {
if err != nil {
log.Fatalf("datacatalog.NewPolicyTagManagerClient: %v", err)
}
functionsClient, err = run.NewServicesClient(ctx, sOpts...)
if err != nil {
log.Fatalf("run.NewService: %v", err)
}
connectionsClient, err = connection.NewClient(ctx, sOpts...)
if err != nil {
log.Fatalf("connection.NewService: %v", err)
Expand Down
52 changes: 1 addition & 51 deletions bigquery/routine_integration_test.go
Expand Up @@ -17,13 +17,11 @@ package bigquery
import (
"context"
"fmt"
"strings"
"testing"

"cloud.google.com/go/internal/testutil"
"google.golang.org/api/iterator"
"google.golang.org/genproto/googleapis/cloud/bigquery/connection/v1"
"google.golang.org/genproto/googleapis/cloud/run/v2"
)

func TestIntegration_RoutineScalarUDF(t *testing.T) {
Expand Down Expand Up @@ -97,16 +95,9 @@ func TestIntegration_RoutineRemoteUDF(t *testing.T) {
}
ctx := context.Background()

functionLocation := fmt.Sprintf("projects/%s/locations/%s", dataset.ProjectID, "us-central1")
routineID := routineIDs.New()
routine := dataset.Routine(routineID)

functionName := fmt.Sprintf("udf-func-%s", strings.ReplaceAll(routineID, "_", "-"))
cleanupFunction, uri, err := createCloudFunction(ctx, t, functionLocation, functionName)
if err != nil {
t.Fatal(err)
}
defer cleanupFunction()
uri := "https://aaabbbccc-uc.a.run.app"

connectionLocation := fmt.Sprintf("projects/%s/locations/%s", dataset.ProjectID, "us")
connectionName := fmt.Sprintf("udf_conn%s", routineID)
Expand Down Expand Up @@ -144,47 +135,6 @@ func TestIntegration_RoutineRemoteUDF(t *testing.T) {
}
}

func createCloudFunction(ctx context.Context, t *testing.T, parent, functionName string) (cleanup func(), uri string, err error) {
fullname := fmt.Sprintf("%s/services/%s", parent, functionName)
createOps, err := functionsClient.CreateService(ctx, &run.CreateServiceRequest{
Parent: parent,
ServiceId: functionName,
Service: &run.Service{
Template: &run.RevisionTemplate{
Containers: []*run.Container{
{
Name: "hello",
Image: "gcr.io/cloudrun/hello",
},
},
},
},
})
if err != nil {
return
}
_, err = createOps.Wait(ctx)
if err != nil {
return
}
service, err := functionsClient.GetService(ctx, &run.GetServiceRequest{
Name: fullname,
})
if err != nil {
return
}
cleanup = func() {
_, err := functionsClient.DeleteService(ctx, &run.DeleteServiceRequest{
Name: fullname,
})
if err != nil {
t.Logf("could not delete cloud run service: %s", fullname)
}
}
uri = service.GetUri()
return
}

func createConnection(ctx context.Context, t *testing.T, parent, name string) (cleanup func(), connectionID string, err error) {
fullname := fmt.Sprintf("%s/connections/%s", parent, name)
conn, err := connectionsClient.CreateConnection(ctx, &connection.CreateConnectionRequest{
Expand Down

0 comments on commit bc7c995

Please sign in to comment.