From 68a01849e3dfc3c509e759427dc5a8a9791865ad Mon Sep 17 00:00:00 2001 From: "Gebal, Jacek" Date: Wed, 17 Jan 2018 17:12:02 +0000 Subject: [PATCH 1/8] Added a fix fr compatibility with v3.0.4. In 3.0.4 the annotation parsing was changed and there is dependency on migration utility. Added build matrix to run agains all existing versions of utPSLQL v3. --- .travis.yml | 10 +++++- source/install.sql | 4 +++ source/migration/ut3.ut_v2_migration.pkb | 45 +++++++++++++++++------- 3 files changed, 46 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9bc8a11..edbf614 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,13 +29,21 @@ env: ##utPLSQL variables - UTPLSQL_DIR="utPLSQL" - UTPLSQL_V2_DIR="utPLSQL_V2" + matrix: + - UTPLSQL_3_VERSION='v3.0.0' + - UTPLSQL_3_VERSION='v3.0.1' + - UTPLSQL_3_VERSION='v3.0.2' + - UTPLSQL_3_VERSION='v3.0.3' + - UTPLSQL_3_VERSION='v3.0.4' + - UTPLSQL_3_VERSION='latest' + before_install: # download travis-oracle - wget 'https://github.com/cbandy/travis-oracle/archive/v2.0.3.tar.gz' - mkdir -p .travis/oracle - tar x -C .travis/oracle --strip-components=1 -f v2.0.3.tar.gz # download latest utPLSQL release - - curl -LOk $(curl --silent https://api.github.com/repos/utPLSQL/utPLSQL/releases/latest | awk '/browser_download_url/ { print $2 }' | grep ".zip" | sed 's/"//g') + - curl -LOk $(curl --silent https://api.github.com/repos/utPLSQL/utPLSQL/releases/${UTPLSQL_3_VERSION} | awk '/browser_download_url/ { print $2 }' | grep ".zip" | sed 's/"//g') - unzip -q utPLSQL.zip # download utPLSQL v.2.3.1 release - curl -LOk $(curl --silent https://api.github.com/repos/utPLSQL/utPLSQL/releases/3608515 | awk '/browser_download_url/ { print $2 }' | grep ".zip" | sed 's/"//g') diff --git a/source/install.sql b/source/install.sql index f1a7153..4b17dfb 100644 --- a/source/install.sql +++ b/source/install.sql @@ -100,6 +100,10 @@ grant execute on utassert2 to public; grant execute on ut_v2_migration to public; set echo off +set feedback off +whenever sqlerror continue +create or replace public synonym ut_annotation_parser for &&utplsql_v3_owner..ut_annotation_parser; +create or replace public synonym ut_annotations for &&utplsql_v3_owner..ut_annotations; prompt &&sep PROMPT Installation completed successfully prompt &&sep diff --git a/source/migration/ut3.ut_v2_migration.pkb b/source/migration/ut3.ut_v2_migration.pkb index 74a5cc6..2268334 100644 --- a/source/migration/ut3.ut_v2_migration.pkb +++ b/source/migration/ut3.ut_v2_migration.pkb @@ -24,7 +24,6 @@ create or replace package body ut_v2_migration is l_setup_proc varchar2(128 char) := upper(a_package_prefix || 'setup'); l_teardown_proc varchar2(128 char) := upper(a_package_prefix || 'teardown'); l_replace_pattern varchar2(50); - l_annotations ut_annotations.typ_annotated_package; l_suite_desc varchar2(4000); l_suite_package varchar2(4000); begin @@ -36,10 +35,31 @@ create or replace package body ut_v2_migration is l_source := dbms_metadata.get_ddl('PACKAGE', l_resolved_object_name, l_resolved_owner); - l_annotations := ut_annotations.parse_package_annotations(l_source); - - if l_annotations.package_annotations.exists('suite') then - raise_application_error(-20400, 'Package '||a_packge_name||' is already version 3 compatible'); + if ut.version like '%v3.0.0%' or ut.version like '%v3.0.1%' or ut.version like '%v3.0.2%' or ut.version like '%v3.0.3%' then + execute immediate q'[ + declare + l_annotations ut_annotations.typ_annotated_package := ut_annotations.parse_package_annotations(:l_source); + begin + if l_annotations.package_annotations.exists('suite') then + raise_application_error(-20400, 'Package '||:a_packge_name||' is already version 3 compatible'); + end if; + end; + ]' using l_source, a_packge_name; + else + execute immediate q'[ + declare + l_exists integer; + begin + dbms_output.put_line('checking annotations'); + select 1 + into l_exists + from table( ut_annotation_parser.parse_object_annotations( :l_source ) ) + where name = 'suite'; + raise_application_error(-20400, 'Package '||:a_packge_name||' is already version 3 compatible'); + exception + when no_data_found then + null; + end;]' using l_source, a_packge_name; end if; if trim(a_package_desc) is not null then @@ -110,28 +130,29 @@ create or replace package body ut_v2_migration is dbms_metadata.set_transform_param(dbms_metadata.session_transform,'BODY',false); for rec in (select p.owner - ,upper(case when p.samepackage='N' then p.prefix end || p.name) as name + ,p.name ,p.description as package_desc ,nvl(p.prefix, c.prefix) prefix ,s.name suite_name ,s.description as suite_desc ,o.status - from utp.ut_package p - ,utp.ut_suite s - ,utp.ut_config c + from UTP.ut_package p + ,UTP.ut_suite s + ,UTP.ut_config c ,all_objects o where p.id in (select max(p2.id) keep(dense_rank first order by p2.suite_id desc nulls last) - from utp.ut_package p2 + from UTP.ut_package p2 group by upper(p2.owner) - ,upper(case when p2.samepackage='N' then p.prefix end || p2.name)) + ,upper(p2.name)) and p.suite_id = s.id(+) and p.owner = c.username(+) and p.owner = o.owner - and upper(case when p.samepackage='N' then p.prefix end || p.name) = o.object_name + and p.name = o.object_name and o.object_type in ('PACKAGE') and p.owner = nvl(a_owner_name, p.owner) and p.name = nvl(a_package_name, p.name) and (s.name = a_suite_name or a_suite_name is null) + and upper(p.name) like upper(nvl(p.prefix, c.prefix))||'%' ) loop begin l_items_processed := l_items_processed +1; From 606147479eda5532a2ef9120b4f03964f7523633 Mon Sep 17 00:00:00 2001 From: "Gebal, Jacek" Date: Wed, 17 Jan 2018 17:33:11 +0000 Subject: [PATCH 2/8] Fixing build matrix --- .travis.yml | 22 +++++++++++-------- .travis/maven_cfg.sh | 18 ++++++++++++++++ .travis/settings.xml | 51 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 9 deletions(-) create mode 100644 .travis/maven_cfg.sh create mode 100644 .travis/settings.xml diff --git a/.travis.yml b/.travis.yml index edbf614..772c106 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,13 +29,15 @@ env: ##utPLSQL variables - UTPLSQL_DIR="utPLSQL" - UTPLSQL_V2_DIR="utPLSQL_V2" + - MAVEN_HOME=/usr/local/maven + - MAVEN_CFG=$HOME/.m2 matrix: - - UTPLSQL_3_VERSION='v3.0.0' - - UTPLSQL_3_VERSION='v3.0.1' - - UTPLSQL_3_VERSION='v3.0.2' - - UTPLSQL_3_VERSION='v3.0.3' - - UTPLSQL_3_VERSION='v3.0.4' - - UTPLSQL_3_VERSION='latest' + - UTPLSQL_3_VERSION='v3.0.0' RELEASE_ID=6394329 + - UTPLSQL_3_VERSION='v3.0.1' RELEASE_ID=6716262 + - UTPLSQL_3_VERSION='v3.0.2' RELEASE_ID=7085296 + - UTPLSQL_3_VERSION='v3.0.3' RELEASE_ID=7293900 + - UTPLSQL_3_VERSION='v3.0.4' RELEASE_ID=8372513 + - UTPLSQL_3_VERSION='latest' RELEASE_ID='latest' before_install: # download travis-oracle @@ -43,14 +45,16 @@ before_install: - mkdir -p .travis/oracle - tar x -C .travis/oracle --strip-components=1 -f v2.0.3.tar.gz # download latest utPLSQL release - - curl -LOk $(curl --silent https://api.github.com/repos/utPLSQL/utPLSQL/releases/${UTPLSQL_3_VERSION} | awk '/browser_download_url/ { print $2 }' | grep ".zip" | sed 's/"//g') + - curl -LOk $(curl --silent https://api.github.com/repos/utPLSQL/utPLSQL/releases/${RELEASE_ID} | awk '/browser_download_url/ { print $2 }' | grep ".zip" | sed 's/"//g') - unzip -q utPLSQL.zip # download utPLSQL v.2.3.1 release - curl -LOk $(curl --silent https://api.github.com/repos/utPLSQL/utPLSQL/releases/3608515 | awk '/browser_download_url/ { print $2 }' | grep ".zip" | sed 's/"//g') - unzip -d ${UTPLSQL_V2_DIR} -q utplsql-2-3-1.zip # download utPLSQL-cli - - curl -Lk -o utPLSQL-cli.zip https://bintray.com/viniciusam/utPLSQL-cli/download_file?file_path=utPLSQL-cli-develop-201706191645.zip - - unzip -q utPLSQL-cli.zip + - curl -Lk -o utPLSQL-cli.zip https://github.com/utPLSQL/utPLSQL-cli/releases/download/v${UTPLSQL_CLI_VERSION}/utPLSQL-cli.zip + - unzip -q utPLSQL-cli.zip && chmod -R u+x utPLSQL-cli + #Download Oracle jdc via maven + - bash .travis/maven_cfg.sh # download Oracle XE installer for Travis - .travis/oracle/download.sh diff --git a/.travis/maven_cfg.sh b/.travis/maven_cfg.sh new file mode 100644 index 0000000..ef23480 --- /dev/null +++ b/.travis/maven_cfg.sh @@ -0,0 +1,18 @@ +#!/bin/bash +set -ev +cp .travis/settings.xml $MAVEN_CFG/settings.xml + +cd $(dirname $(readlink -f $0)) + +# Download wagon-http recommended by Oracle. +# On maven latest version this is not needed, but travis doesn't have it. +if [ ! -f $CACHE_DIR/wagon-http-2.8-shaded.jar ]; then + curl -L -O "http://central.maven.org/maven2/org/apache/maven/wagon/wagon-http/2.8/wagon-http-2.8-shaded.jar" + mv wagon-http-2.8-shaded.jar $CACHE_DIR/ + sudo cp $CACHE_DIR/wagon-http-2.8-shaded.jar $MAVEN_HOME/lib/ext/ +else + echo "Using cached wagon-http..." + sudo cp $CACHE_DIR/wagon-http-2.8-shaded.jar $MAVEN_HOME/lib/ext/ +fi + +mvn dependency:copy-dependencies -DoutputDirectory=../utPLSQL-cli/lib \ No newline at end of file diff --git a/.travis/settings.xml b/.travis/settings.xml new file mode 100644 index 0000000..731ef52 --- /dev/null +++ b/.travis/settings.xml @@ -0,0 +1,51 @@ + + + + + + + + + maven.oracle.com + ${env.ORACLE_OTN_USER} + ${env.ORACLE_OTN_PASSWORD} + + + ANY + ANY + OAM 11g + + + + + + http.protocol.allow-circular-redirects + %b,true + + + + + + + + + From 358c3a8ab0ef358b1c0bb071dbb79cff20412200 Mon Sep 17 00:00:00 2001 From: "Gebal, Jacek" Date: Wed, 17 Jan 2018 17:47:50 +0000 Subject: [PATCH 3/8] Fixing build matrix --- .travis.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 772c106..51503fc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,6 +31,7 @@ env: - UTPLSQL_V2_DIR="utPLSQL_V2" - MAVEN_HOME=/usr/local/maven - MAVEN_CFG=$HOME/.m2 + - UTPLSQL_CLI_VERSION="3.0.4" matrix: - UTPLSQL_3_VERSION='v3.0.0' RELEASE_ID=6394329 - UTPLSQL_3_VERSION='v3.0.1' RELEASE_ID=6716262 @@ -45,11 +46,11 @@ before_install: - mkdir -p .travis/oracle - tar x -C .travis/oracle --strip-components=1 -f v2.0.3.tar.gz # download latest utPLSQL release - - curl -LOk $(curl --silent https://api.github.com/repos/utPLSQL/utPLSQL/releases/${RELEASE_ID} | awk '/browser_download_url/ { print $2 }' | grep ".zip" | sed 's/"//g') - - unzip -q utPLSQL.zip + - curl -Lk -o utPLSQL_v3.zip $(curl --silent https://api.github.com/repos/utPLSQL/utPLSQL/releases/${RELEASE_ID} | awk '/browser_download_url/ { print $2 }' | grep ".zip" | sed 's/"//g') + - unzip -q utPLSQL_v3.zip # download utPLSQL v.2.3.1 release - - curl -LOk $(curl --silent https://api.github.com/repos/utPLSQL/utPLSQL/releases/3608515 | awk '/browser_download_url/ { print $2 }' | grep ".zip" | sed 's/"//g') - - unzip -d ${UTPLSQL_V2_DIR} -q utplsql-2-3-1.zip + - curl -Lk -o utPLSQL_v2.zip $(curl --silent https://api.github.com/repos/utPLSQL/utPLSQL/releases/3608515 | awk '/browser_download_url/ { print $2 }' | grep ".zip" | sed 's/"//g') + - unzip -d ${UTPLSQL_V2_DIR} -q utPLSQL_v2.zip # download utPLSQL-cli - curl -Lk -o utPLSQL-cli.zip https://github.com/utPLSQL/utPLSQL-cli/releases/download/v${UTPLSQL_CLI_VERSION}/utPLSQL-cli.zip - unzip -q utPLSQL-cli.zip && chmod -R u+x utPLSQL-cli From 417b4a7066fc2c7c0e81dc672ebb085756a0b9bd Mon Sep 17 00:00:00 2001 From: "Gebal, Jacek" Date: Wed, 17 Jan 2018 17:50:49 +0000 Subject: [PATCH 4/8] Fixing build matrix --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 51503fc..d3523fe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,7 @@ env: # project variables - DB_USER=ut3_demo - DB_PASS=LHZYPbWvYdu2ctp8 + - CACHE_DIR=$HOME/.cache ##utPLSQL variables - UTPLSQL_DIR="utPLSQL" - UTPLSQL_V2_DIR="utPLSQL_V2" From 9f37818466d6bf9d7717e7e7932e7b1fb85e1846 Mon Sep 17 00:00:00 2001 From: "Gebal, Jacek" Date: Wed, 17 Jan 2018 17:53:51 +0000 Subject: [PATCH 5/8] Fixing build matrix --- .travis.yml | 2 +- .travis/pom.xml | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 .travis/pom.xml diff --git a/.travis.yml b/.travis.yml index d3523fe..c2dbabb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -55,7 +55,7 @@ before_install: # download utPLSQL-cli - curl -Lk -o utPLSQL-cli.zip https://github.com/utPLSQL/utPLSQL-cli/releases/download/v${UTPLSQL_CLI_VERSION}/utPLSQL-cli.zip - unzip -q utPLSQL-cli.zip && chmod -R u+x utPLSQL-cli - #Download Oracle jdc via maven + #Download Oracle jdbc using maven - bash .travis/maven_cfg.sh # download Oracle XE installer for Travis - .travis/oracle/download.sh diff --git a/.travis/pom.xml b/.travis/pom.xml new file mode 100644 index 0000000..706bd79 --- /dev/null +++ b/.travis/pom.xml @@ -0,0 +1,62 @@ + + + 4.0.0 + org.utplsql + utplsql + 3.0.4-SNAPSHOT + jar + + utPLSQL + https://github.com/utPLSQL/utPLSQL + + + UTF-8 + + + + + com.oracle.jdbc + ojdbc8 + 12.2.0.1 + compile + + + com.oracle.jdbc + orai18n + 12.2.0.1 + compile + + + + + + maven.oracle.com + + true + + + false + + https://maven.oracle.com + default + + + + + + maven.oracle.com + https://maven.oracle.com + + + + + + + io.packagecloud.maven.wagon + maven-packagecloud-wagon + 0.0.6 + + + + From 25488ac8580dcc9ea400ebaa30498a53527de7dd Mon Sep 17 00:00:00 2001 From: "Gebal, Jacek" Date: Thu, 18 Jan 2018 13:13:41 +0000 Subject: [PATCH 6/8] Fixing build matrix --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c2dbabb..7c9309e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,7 +34,7 @@ env: - MAVEN_CFG=$HOME/.m2 - UTPLSQL_CLI_VERSION="3.0.4" matrix: - - UTPLSQL_3_VERSION='v3.0.0' RELEASE_ID=6394329 + - UTPLSQL_3_VERSION='v3.0.0' RELEASE_ID=6394329 UTPLSQL_DIR='utPLSQLv3.0.0' - UTPLSQL_3_VERSION='v3.0.1' RELEASE_ID=6716262 - UTPLSQL_3_VERSION='v3.0.2' RELEASE_ID=7085296 - UTPLSQL_3_VERSION='v3.0.3' RELEASE_ID=7293900 From 45df9969647487ce2744a12e20bf0503e3bf1a13 Mon Sep 17 00:00:00 2001 From: "Gebal, Jacek" Date: Thu, 18 Jan 2018 13:24:51 +0000 Subject: [PATCH 7/8] Fixing unit tet failures --- source/install.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/install.sql b/source/install.sql index 4b17dfb..3e694d6 100644 --- a/source/install.sql +++ b/source/install.sql @@ -103,7 +103,10 @@ set echo off set feedback off whenever sqlerror continue create or replace public synonym ut_annotation_parser for &&utplsql_v3_owner..ut_annotation_parser; +grant execute on &&utplsql_v3_owner..ut_annotation_parser to public; create or replace public synonym ut_annotations for &&utplsql_v3_owner..ut_annotations; +grant execute on &&utplsql_v3_owner..ut_annotations to public; + prompt &&sep PROMPT Installation completed successfully prompt &&sep From 2969a12bd43570ee68ed1ba16d1dbc8a7f32742e Mon Sep 17 00:00:00 2001 From: "Gebal, Jacek" Date: Thu, 18 Jan 2018 15:37:32 +0000 Subject: [PATCH 8/8] Removing dbms_output from --%beforetest suite/test setup --- test/migration_test/test_migration.pkb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/migration_test/test_migration.pkb b/test/migration_test/test_migration.pkb index 808d410..c7e90c8 100644 --- a/test/migration_test/test_migration.pkb +++ b/test/migration_test/test_migration.pkb @@ -89,6 +89,8 @@ end; end; procedure register_ut_v2_packages is + l_lines dbmsoutput_linesarray; + l_numlines integer; pragma autonomous_transaction; begin dbms_output.put_line('register_ut_v2_packages'); @@ -97,6 +99,8 @@ end; utSuite.add ('MIGRATION'); utPackage.add('MIGRATION', 'UT_BETWNSTR_NEW', samepackage_in => true); utplsql.testsuite ('MIGRATION'); + + dbms_output.get_lines ( l_lines, l_numlines ); commit; end;