You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by jv...@apache.org on 2017/02/27 17:16:55 UTC

[12/20] incubator-trafficcontrol git commit: test file

test file


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

Branch: refs/heads/master
Commit: c3bd29a881f9af4911aadac89490797f3d808a72
Parents: fccf664
Author: Derek Gelinas <de...@cable.comcast.com>
Authored: Thu Jan 19 14:46:15 2017 -0500
Committer: Jan van Doorn <jv...@apache.org>
Committed: Mon Feb 27 16:57:46 2017 +0000

----------------------------------------------------------------------
 .../1.2/config_files_apache_traffic_server.t    | 84 ++++++++++++++++++++
 1 file changed, 84 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/c3bd29a8/traffic_ops/app/t/api/1.2/config_files_apache_traffic_server.t
----------------------------------------------------------------------
diff --git a/traffic_ops/app/t/api/1.2/config_files_apache_traffic_server.t b/traffic_ops/app/t/api/1.2/config_files_apache_traffic_server.t
new file mode 100644
index 0000000..a27ffa2
--- /dev/null
+++ b/traffic_ops/app/t/api/1.2/config_files_apache_traffic_server.t
@@ -0,0 +1,84 @@
+package main;
+#
+#
+# Licensed 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.
+#
+use Mojo::Base -strict;
+use Test::More;
+use Test::Mojo;
+use Data::Dumper;
+use DBI;
+use JSON;
+use strict;
+use warnings;
+no warnings 'once';
+use warnings 'all';
+use Test::TestHelper;
+
+#no_transactions=>1 ==> keep fixtures after every execution, beware of duplicate data!
+#no_transactions=>0 ==> delete fixtures after every execution
+
+BEGIN { $ENV{MOJO_MODE} = "test" }
+
+my $schema = Schema->connect_to_database;
+my $dbh    = Schema->database_handle;
+my $t      = Test::Mojo->new('TrafficOps');
+
+Test::TestHelper->unload_core_data($schema);
+Test::TestHelper->load_core_data($schema);
+
+ok $t->post_ok( '/login', => form => { u => Test::TestHelper::ADMIN_USER, p => Test::TestHelper::ADMIN_USER_PASSWORD } )->status_is(302)
+	->or( sub { diag $t->tx->res->content->asset->{content}; } ), 'Should login?';
+
+# Check ATS config metadata
+ok $t->get_ok("/api/1.2/server/100/configfiles/ats")->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content} } );
+
+# Check server routes
+ok $t->get_ok("/api/1.2/server/100/configfiles/ats/12M_facts")->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content} } );
+ok $t->get_ok("/api/1.2/server/100/configfiles/ats/ip_allow.config")->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content} } );
+ok $t->get_ok("/api/1.2/server/100/configfiles/ats/crontab_root")->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content} } );
+ok $t->get_ok("/api/1.2/server/100/configfiles/ats/remap.config")->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content} } );
+ok $t->get_ok("/api/1.2/server/100/configfiles/ats/parent.config")->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content} } );
+ok $t->get_ok("/api/1.2/server/100/configfiles/ats/cache.config")->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content} } );
+ok $t->get_ok("/api/1.2/server/100/configfiles/ats/hosting.config")->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content} } );
+
+# Check CDN routes
+ok $t->get_ok("/api/1.2/cdn/cdn1/configfiles/ats/cacheurl.config")->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content} } );
+ok $t->get_ok("/api/1.2/cdn/cdn1/configfiles/ats/regex_revalidate.config")->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content} } );ok $t->get_ok("/api/1.2/cdn/cdn1/configfiles/ats/hdr_rw_cdl-c2.config")->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content} } );
+
+# Check profile routes
+ok $t->get_ok("/api/1.2/profile/100/configfiles/ats/50-ats.rules")->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content} } );
+ok $t->get_ok("/api/1.2/profile/100/configfiles/ats/drop_qstring.config")->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content} } );
+ok $t->get_ok("/api/1.2/profile/100/configfiles/ats/volume.config")->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content} } );
+ok $t->get_ok("/api/1.2/profile/100/configfiles/ats/astats.config")->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content} } );
+ok $t->get_ok("/api/1.2/profile/100/configfiles/ats/storage.config")->status_is(200)->or( sub { diag $t->tx->res->content->asset->{content} } );
+
+
+# Count the 'response number'
+my $count_response = sub {
+	my ( $t, $count ) = @_;
+	my $json = decode_json( $t->tx->res->content->asset->slurp );
+	my $r    = $json->{response};
+	return $t->success( is( scalar(@$r), $count ) );
+};
+
+$t->get_ok('/api/1.2/deliveryservices/list?logsEnabled=true')->status_is(200)->$count_response(2)
+	->or( sub { diag $t->tx->res->content->asset->{content}; } );
+
+ok $t->put_ok('/api/1.2/snapshot/cdn1')->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}; } );
+$dbh->disconnect();
+done_testing();
+
+