Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test #19

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
14 changes: 8 additions & 6 deletions .github/workflows/integration-tests-against-emulator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,14 @@ jobs:
- name: Install sqlplus required for loading .sql files
run: |
sudo apt-get update
sudo apt install alien libaio1
curl -O https://download.oracle.com/otn_software/linux/instantclient/215000/oracle-instantclient-basic-21.5.0.0.0-1.x86_64.rpm
curl -O https://download.oracle.com/otn_software/linux/instantclient/215000/oracle-instantclient-sqlplus-21.5.0.0.0-1.x86_64.rpm
sudo alien -i oracle-instantclient-basic-21.5.0.0.0-1.x86_64.rpm
sudo alien -i oracle-instantclient-sqlplus-21.5.0.0.0-1.x86_64.rpm
sudo sh -c 'echo /usr/lib/oracle/21.5/client64/lib/ > /etc/ld.so.conf.d/oracle.conf'
sudo apt-get install -y libaio1 rpm2cpio cpio
curl -O https://download.oracle.com/otn_software/linux/instantclient/2340000/oracle-instantclient-basic-23.4.0.24.05-1.el9.x86_64.rpm
curl -O https://download.oracle.com/otn_software/linux/instantclient/2340000/oracle-instantclient-sqlplus-23.4.0.24.05-1.el9.x86_64.rpm
rpm2cpio oracle-instantclient-basic-23.4.0.24.05-1.el9.x86_64.rpm | sudo cpio -idmv
sudo cp -r usr/* /usr/
rpm2cpio oracle-instantclient-sqlplus-23.4.0.24.05-1.el9.x86_64.rpm | sudo cpio -idmv
sudo cp -r usr/* /usr/
sudo sh -c 'echo /usr/lib/oracle/23/client64/lib/ > /etc/ld.so.conf.d/oracle.conf'
sudo ldconfig
- run: sqlplus SYS/[email protected]:1521/xe as sysdba @test_data/oracle.test.out
# create a spanner instance
Expand Down
29 changes: 15 additions & 14 deletions cmd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

sp "cloud.google.com/go/spanner"
database "cloud.google.com/go/spanner/admin/database/apiv1"
"github.com/GoogleCloudPlatform/spanner-migration-tool/accessors/clients/datastream"
datastreamclient "github.com/GoogleCloudPlatform/spanner-migration-tool/accessors/clients/datastream"
spanneradmin "github.com/GoogleCloudPlatform/spanner-migration-tool/accessors/clients/spanner/admin"
spinstanceadmin "github.com/GoogleCloudPlatform/spanner-migration-tool/accessors/clients/spanner/instanceadmin"
storageclient "github.com/GoogleCloudPlatform/spanner-migration-tool/accessors/clients/storage"
Expand Down Expand Up @@ -161,19 +161,19 @@ func MigrateDatabase(ctx context.Context, migrationProjectId string, targetProfi

func migrateSchema(ctx context.Context, targetProfile profiles.TargetProfile, sourceProfile profiles.SourceProfile,
ioHelper *utils.IOStreams, conv *internal.Conv, dbURI string, adminClient *database.DatabaseAdminClient) error {
spA := spanneraccessor.SpannerAccessorImpl{}
adminClientImpl, err := spanneradmin.NewAdminClientImpl(ctx)
if err != nil {
return err
}
err = spA.CreateOrUpdateDatabase(ctx, adminClientImpl, dbURI, sourceProfile.Driver, conv, sourceProfile.Config.ConfigType)
if err != nil {
err = fmt.Errorf("can't create/update database: %v", err)
return err
}
metricsPopulation(ctx, sourceProfile.Driver, conv)
conv.Audit.Progress.UpdateProgress("Schema migration complete.", completionPercentage, internal.SchemaMigrationComplete)
return nil
spA := spanneraccessor.SpannerAccessorImpl{}
adminClientImpl, err := spanneradmin.NewAdminClientImpl(ctx)
if err != nil {
return err
}
err = spA.CreateOrUpdateDatabase(ctx, adminClientImpl, dbURI, sourceProfile.Driver, conv, sourceProfile.Config.ConfigType)
if err != nil {
err = fmt.Errorf("can't create/update database: %v", err)
return err
}
metricsPopulation(ctx, sourceProfile.Driver, conv)
conv.Audit.Progress.UpdateProgress("Schema migration complete.", completionPercentage, internal.SchemaMigrationComplete)
return nil
}

func migrateData(ctx context.Context, migrationProjectId string, targetProfile profiles.TargetProfile, sourceProfile profiles.SourceProfile,
Expand Down Expand Up @@ -253,6 +253,7 @@ func migrateSchemaAndData(ctx context.Context, migrationProjectId string, target
if !cmd.SkipForeignKeys {
spA.UpdateDDLForeignKeys(ctx, adminClientImpl, dbURI, conv, sourceProfile.Driver, sourceProfile.Config.ConfigType)
}

return bw, nil
}

Expand Down
Loading