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:31 UTC

[28/53] [abbrv] incubator-trafficcontrol git commit: Fix tests and fixtures for pg. Update schema for tinyint to smallint mapping

Fix tests and fixtures for pg. Update schema for tinyint to smallint mapping


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/47589cc2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/47589cc2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/47589cc2

Branch: refs/heads/psql-rebase
Commit: 47589cc2e20bd02e9527b3fa356abe418b7d8281
Parents: 831ba45
Author: Jan van Doorn <ja...@cable.comcast.com>
Authored: Sat Sep 24 16:54:48 2016 -0600
Committer: Dan Kirkwood <da...@gmail.com>
Committed: Fri Nov 11 14:02:04 2016 -0700

----------------------------------------------------------------------
 traffic_ops/app/lib/UI/Server.pm           |  7 ++-
 traffic_ops/app/lib/UI/Topology.pm         |  3 +-
 traffic_ops/app/lib/UI/UploadHandlerCsv.pm |  2 +-
 traffic_ops/app/t/deliveryservice.t        |  2 +-
 traffic_ops/app/t_integration/server.t     | 73 ++++++++++++++++++++++++-
 5 files changed, 81 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/47589cc2/traffic_ops/app/lib/UI/Server.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/UI/Server.pm b/traffic_ops/app/lib/UI/Server.pm
index 3e6f779..5ff0daa 100644
--- a/traffic_ops/app/lib/UI/Server.pm
+++ b/traffic_ops/app/lib/UI/Server.pm
@@ -460,7 +460,12 @@ sub update {
 	#===
 
 
-	my $server_status = $self->db->resultset('Status')->search( { id => $self->param('status') } )->get_column('name')->single();
+	my $server_status;
+	if  ( $self->param('status') =~ /\d+/ ) {
+		$server_status = $self->db->resultset('Status')->search( { id => $self->param('status') } )->get_column('name')->single();
+	} else {
+		$server_status = $self->param('status');
+	}
 	my $offline_reason = &cgi_params_to_param_hash_ref($self)->{'offline_reason'};
 
 	if ($server_status ne "OFFLINE" && $server_status ne "ADMIN_DOWN") {

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/47589cc2/traffic_ops/app/lib/UI/Topology.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/UI/Topology.pm b/traffic_ops/app/lib/UI/Topology.pm
index 4b5211a..02b6ff4 100644
--- a/traffic_ops/app/lib/UI/Topology.pm
+++ b/traffic_ops/app/lib/UI/Topology.pm
@@ -71,7 +71,8 @@ sub gen_crconfig_json {
             select => [ 'cdn.id', 'me.profile', 'me.type', 'profile.id', 'type.id' ],
             join   => 'cdn',
             prefetch => [ 'profile', 'type' ],
-            distinct => 1
+            distinct => 1,
+            group_by => [ 'type.name', 'cdn.id', 'me.profile', 'me.type', 'profile.id', 'type.id'],
         }
     );
 

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/47589cc2/traffic_ops/app/lib/UI/UploadHandlerCsv.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/UI/UploadHandlerCsv.pm b/traffic_ops/app/lib/UI/UploadHandlerCsv.pm
index e8cc10e..7921eb1 100644
--- a/traffic_ops/app/lib/UI/UploadHandlerCsv.pm
+++ b/traffic_ops/app/lib/UI/UploadHandlerCsv.pm
@@ -270,7 +270,7 @@ sub checkNamedValues {
 			.= $errorLineDelim . "[LINE #:" . $lineNumber . "]<span style='color:blue;'>TYPE NOT VALID[" . $enteredType . "] CASE SENSITIVE.</span>";
 	}
 
-	if ( !exists $profileHashRef->{$enteredProfile} ) {
+	if ( !exists $profileHashRef->{$enteredProfile} && $enteredProfile !~ /\d+/) {
 		$processCSVErrors
 			.= $errorLineDelim . "[LINE #:" . $lineNumber . "]<span style='color:blue;'>PROFILE NOT VALID[" . $enteredProfile . "] CASE SENSITIVE.</span>";
 	}

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/47589cc2/traffic_ops/app/t/deliveryservice.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/deliveryservice.t b/traffic_ops/app/t/deliveryservice.t
index 63e5994..48939ca 100644
--- a/traffic_ops/app/t/deliveryservice.t
+++ b/traffic_ops/app/t/deliveryservice.t
@@ -240,7 +240,7 @@ ok $t->post_ok(
 		'ds.dns_bypass_cname'            => 'updateby.knutsel.com',
 		'ds.dns_bypass_ttl'              => '31',
 		'ds.dscp'                        => '41',
-		'ds.geo_limit'                   => '2',
+		'ds.geo_limit'                   => '1',
 		'ds.geo_limit_countries'         => '',
 		'ds.geo_provider'                => '1',
 		'ds.global_max_mbps'             => '4T',

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/47589cc2/traffic_ops/app/t_integration/server.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t_integration/server.t b/traffic_ops/app/t_integration/server.t
index d67df45..9f79d38 100644
--- a/traffic_ops/app/t_integration/server.t
+++ b/traffic_ops/app/t_integration/server.t
@@ -74,7 +74,7 @@ foreach my $server ( @{ $servers->{response} } ) {
 
 	if ( !$type_done{ $server->{type} } ) {
 
-		# diag Dumper($server);
+		#diag Dumper($server);
 		diag "Testing type " . $server->{type} . " with " . $server->{hostName};
 
 		# these are optional, show up as undef in json and '' in html
@@ -113,7 +113,7 @@ foreach my $server ( @{ $servers->{response} } ) {
 			->or( sub { diag $t->tx->res->content->asset->{content}; } );
 
 		$server->{router_host_name} = "UPDATED";
-		diag '/server/' . $server->{id};
+		#diag '/server/' . $server->{id};
 		$t->post_ok(
 			      '/server/'
 				. $server->{id}
@@ -141,6 +141,8 @@ foreach my $server ( @{ $servers->{response} } ) {
 				ilo_password     => $server->{iloPassword},
 				router_host_name => $server->{routerHostName},
 				router_port_name => $server->{routerPortName},
+				https_port       => $server->{httpsPort},
+				status           => $server->{status},
 				}
 		)->status_is(302)->or( sub { diag $t->tx->res->content->asset->{content}; } );
 
@@ -148,5 +150,72 @@ foreach my $server ( @{ $servers->{response} } ) {
 	}
 }
 
+sub build_tmpfile {
+	my ($contents) = @_;
+	unlink TEST_FILE;
+	write_file( TEST_FILE, $contents );
+}
+
+# Header
+my $header =
+	"host,domain,int,ip4,subnet,gw,ip6,gw6,mtu,cdn,cachegroup,phys_loc,rack,type,prof,port,1g_ip,1g_subnet,1g_gw,ilo_ip,ilo_subnet,ilo_gw,ilo_user,ilo_pwd,r_host,r_port,https_port,offline_reason";
+
+#----------------------------
+# Good Test
+my $content = join( "\n",
+	$header,
+	"good-host,chi.kabletown.net,bond0,10.10.2.200,255.255.255.0,10.10.2.254,2033:D0D0:3300::2:1A/64,2033:D0D0:3300::2:1,9000,cdn_number_1,us-il-chicago,plocation-chi-1,rack33,EDGE,1,80,10.10.33.1,255.255.255.0,10.10.33.44,10.254.254.12,255.255.255.0,10.254.254.1,user,passwd,router_33,port_66,443,N/A\n"
+);
+
+&build_tmpfile($content);
+my $asset = Mojo::Asset::File->new( path => TEST_FILE );
+
+$t->post_ok(
+	'/uploadhandlercsv' => form => { 'file-0' => { name => 'file-0', asset => $asset, filename => basename(TEST_FILE), content => $asset->slurp } } )
+	->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } );
+
+#----------------------------
+# Bad 'Type' look for -BAD
+$content = join( "\n",
+	$header,
+	"atsec-chi-09,chi.kabletown.net,bond0,10.10.2.200,255.255.255.0,10.10.2.254,2033:D0D0:3300::2:1A/64,2033:D0D0:3300::2:1,9000,cdn_number_1,us-il-chicago,plocation-chi-1,rack33,EDGE-BAD,1,80,10.10.33.1,255.255.255.0,10.10.33.44,10.254.254.12,255.255.255.0,10.254.254.1,user,passwd,router_33,port_66\n"
+);
+
+&build_tmpfile($content);
+$t->post_ok(
+	'/uploadhandlercsv' => form => { 'file-0' => { name => 'file-0', asset => $asset, filename => basename(TEST_FILE), content => $asset->slurp } } )
+	->json_has("[EXCEPTION_ERROR]")->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } );
+
+#----------------------------
+# Bad 'Profile' look for -BAD
+$content = join( "\n",
+	$header,
+	"atsec-chi-09,chi.kabletown.net,bond0,10.10.2.200,255.255.255.0,10.10.2.254,2033:D0D0:3300::2:1A/64,2033:D0D0:3300::2:1,9000,cdn_number_2,us-il-chicago,plocation-chi-1,rack33,EDGE,1-BAD,80,10.10.33.1,255.255.255.0,10.10.33.44,10.254.254.12,255.255.255.0,10.254.254.1,user,passwd,router_33,port_66\n"
+);
+
+&build_tmpfile($content);
+$t->post_ok(
+	'/uploadhandlercsv' => form => { 'file-0' => { name => 'file-0', asset => $asset, filename => basename(TEST_FILE), content => $asset->slurp } } )
+	->json_has("[EXCEPTION_ERROR]")->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } );
+
+#----------------------------
+# Bad 'Cache Group' look for -BAD
+$content = join( "\n",
+	$header,
+	"atsec-chi-09,chi.kabletown.net,bond0,10.10.2.200,255.255.255.0,10.10.2.254,2033:D0D0:3300::2:1A/64,2033:D0D0:3300::2:1,9000,cdn_number_2,us-il-chicago-BAD,plocation-chi-1,rack33,EDGE,1,80,10.10.33.1,255.255.255.0,10.10.33.44,10.254.254.12,255.255.255.0,10.254.254.1,user,passwd,router_33,port_66\n"
+);
+
+#----------------------------
+# Bad 'Physical Location' look for -BAD
+$content = join( "\n",
+	$header,
+	"atsec-chi-09,chi.kabletown.net,bond0,10.10.2.200,255.255.255.0,10.10.2.254,2033:D0D0:3300::2:1A/64,2033:D0D0:3300::2:1,9000,cdn_number_1,us-il-chicago,plocation-chi-1-BAD,rack33,EDGE,1,80,10.10.33.1,255.255.255.0,10.10.33.44,10.254.254.12,255.255.255.0,10.254.254.1,user,passwd,router_33,port_66\n"
+);
+
+&build_tmpfile($content);
+$t->post_ok(
+	'/uploadhandlercsv' => form => { 'file-0' => { name => 'file-0', asset => $asset, filename => basename(TEST_FILE), content => $asset->slurp } } )
+	->json_has("[EXCEPTION_ERROR]")->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content}; } );
+
 ok $t->get_ok('/logout')->status_is(302)->or( sub { diag $t->tx->res->content->asset->{content}; } );
 done_testing();