Skip to content

Commit

Permalink
Merge pull request #7 from utPLSQL/feature/v3.0.4_compatibility
Browse files Browse the repository at this point in the history
Feature/v3.0.4 compatibility
  • Loading branch information
jgebal authored Jan 18, 2018
2 parents 86d3fed + 2969a12 commit e1dd902
Show file tree
Hide file tree
Showing 7 changed files with 195 additions and 18 deletions.
26 changes: 20 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,37 @@ env:
# project variables
- DB_USER=ut3_demo
- DB_PASS=LHZYPbWvYdu2ctp8
- CACHE_DIR=$HOME/.cache
##utPLSQL variables
- UTPLSQL_DIR="utPLSQL"
- 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_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
- UTPLSQL_3_VERSION='v3.0.4' RELEASE_ID=8372513
- UTPLSQL_3_VERSION='latest' RELEASE_ID='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')
- 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://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 jdbc using maven
- bash .travis/maven_cfg.sh
# download Oracle XE installer for Travis
- .travis/oracle/download.sh

Expand Down
18 changes: 18 additions & 0 deletions .travis/maven_cfg.sh
Original file line number Diff line number Diff line change
@@ -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
62 changes: 62 additions & 0 deletions .travis/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<!--Used to obtain ojdbc8 and orai18n files that are needed for client-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.utplsql</groupId>
<artifactId>utplsql</artifactId>
<version>3.0.4-SNAPSHOT</version>
<packaging>jar</packaging>

<name>utPLSQL</name>
<url>https://github.com/utPLSQL/utPLSQL</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>com.oracle.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>12.2.0.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.oracle.jdbc</groupId>
<artifactId>orai18n</artifactId>
<version>12.2.0.1</version>
<scope>compile</scope>
</dependency>
</dependencies>

<repositories>
<repository>
<id>maven.oracle.com</id>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<url>https://maven.oracle.com</url>
<layout>default</layout>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>maven.oracle.com</id>
<url>https://maven.oracle.com</url>
</pluginRepository>
</pluginRepositories>

<build>
<extensions>
<extension>
<groupId>io.packagecloud.maven.wagon</groupId>
<artifactId>maven-packagecloud-wagon</artifactId>
<version>0.0.6</version>
</extension>
</extensions>
</build>
</project>
51 changes: 51 additions & 0 deletions .travis/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

<servers>
<server>
<id>maven.oracle.com</id>
<username>${env.ORACLE_OTN_USER}</username>
<password>${env.ORACLE_OTN_PASSWORD}</password>
<configuration>
<basicAuthScope>
<host>ANY</host>
<port>ANY</port>
<realm>OAM 11g</realm>
</basicAuthScope>
<httpConfiguration>
<all>
<params>
<property>
<name>http.protocol.allow-circular-redirects</name>
<value>%b,true</value>
</property>
</params>
</all>
</httpConfiguration>
</configuration>
</server>
</servers>

</settings>
7 changes: 7 additions & 0 deletions source/install.sql
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ 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;
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
Expand Down
45 changes: 33 additions & 12 deletions source/migration/ut3.ut_v2_migration.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions test/migration_test/test_migration.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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;

Expand Down

0 comments on commit e1dd902

Please sign in to comment.