You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by da...@apache.org on 2016/11/14 17:07:17 UTC
[14/53] [abbrv] incubator-trafficcontrol git commit: updating test
helpers.
updating test helpers.
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/16843c64
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/16843c64
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/16843c64
Branch: refs/heads/psql-rebase
Commit: 16843c649e8e5e01a139354f127a270a10c92cc4
Parents: 9135384
Author: Jackie Heitzer <ja...@cable.comcast.com>
Authored: Thu Aug 4 10:52:08 2016 -0600
Committer: Dan Kirkwood <da...@gmail.com>
Committed: Fri Nov 11 13:26:35 2016 -0700
----------------------------------------------------------------------
.../app/lib/Test/IntegrationTestHelper.pm | 41 +++++++-------------
traffic_ops/app/lib/Test/TestHelper.pm | 40 +++++++------------
2 files changed, 26 insertions(+), 55 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/16843c64/traffic_ops/app/lib/Test/IntegrationTestHelper.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Test/IntegrationTestHelper.pm b/traffic_ops/app/lib/Test/IntegrationTestHelper.pm
index 7bfd023..f0c1eef 100644
--- a/traffic_ops/app/lib/Test/IntegrationTestHelper.pm
+++ b/traffic_ops/app/lib/Test/IntegrationTestHelper.pm
@@ -106,38 +106,23 @@ sub teardown {
$schema->resultset($table_name)->delete_all;
}
+## For PSQL sequence to work correctly we cannot hard code
+## the id number for an entry in the DB. So we need to
+## reset all primary keys (id) to 1 for consistency in the
+## test cases.
sub reset_sequence_id {
my $self = shift;
my $dbh = Schema->database_handle;
- my @table_names = qw(
- asn
- cachegroup
- cdn
- deliveryservice
- division
- federation
- federation_resolver
- hwinfo
- job_agent
- job_status
- log
- parameter
- phys_location
- profile
- regex
- region
- role
- server
- staticdnsentry
- stats_summary
- status
- tm_user
- to_extension
- type );
- foreach my $name (@table_names) {
- my $p = $dbh->prepare("ALTER SEQUENCE " . $name . "_id_seq RESTART WITH 1");
- $p->execute();
+ my $p = $dbh->prepare( "SELECT * FROM pg_class WHERE relkind = 'S';" );
+ $p->execute();
+ my $foo = $p->fetchall_arrayref( {} );
+ $p->finish();
+
+
+ for my $table ( @$foo ) {
+ my $x = $dbh->prepare("ALTER SEQUENCE " . $table->{'relname'} . " RESTART WITH 1");
+ $x->execute();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/16843c64/traffic_ops/app/lib/Test/TestHelper.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Test/TestHelper.pm b/traffic_ops/app/lib/Test/TestHelper.pm
index b2c914a..f5d5756 100644
--- a/traffic_ops/app/lib/Test/TestHelper.pm
+++ b/traffic_ops/app/lib/Test/TestHelper.pm
@@ -76,37 +76,23 @@ sub load_all_fixtures {
}
}
+## For PSQL sequence to work correctly we cannot hard code
+## the id number for an entry in the DB. So we need to
+## reset all primary keys (id) to 1 for consistency in the
+## test cases.
sub reset_sequence_id {
my $self = shift;
my $dbh = Schema->database_handle;
- my @table_names = qw(
- asn
- cachegroup
- cdn
- deliveryservice
- division
- federation
- federation_resolver
- hwinfo
- job_agent
- job_status
- log
- parameter
- phys_location
- profile
- regex
- region
- role
- server
- staticdnsentry
- stats_summary
- status
- tm_user
- type );
- foreach my $name (@table_names) {
- my $p = $dbh->prepare("ALTER SEQUENCE " . $name . "_id_seq RESTART WITH 1");
- $p->execute();
+ my $p = $dbh->prepare( "SELECT * FROM pg_class WHERE relkind = 'S';" );
+ $p->execute();
+ my $foo = $p->fetchall_arrayref( {} );
+ $p->finish();
+
+
+ for my $table ( @$foo ) {
+ my $x = $dbh->prepare("ALTER SEQUENCE " . $table->{'relname'} . " RESTART WITH 1");
+ $x->execute();
}
}