You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@trafficserver.apache.org by ffcai <gi...@git.apache.org> on 2015/03/04 11:37:28 UTC

[GitHub] trafficserver pull request: add initial remap tests

GitHub user ffcai opened a pull request:

    https://github.com/apache/trafficserver/pull/176

    add initial remap tests

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/ffcai/trafficserver master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/trafficserver/pull/176.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #176
    
----
commit b30a1595d1c164abd021e2654ff2e6700ed56d48
Author: Feifei Cai <ff...@yahoo-inc.com>
Date:   2015-03-04T10:35:10Z

    add initial remap tests

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver pull request: add initial remap tests

Posted by ffcai <gi...@git.apache.org>.
Github user ffcai commented on the pull request:

    https://github.com/apache/trafficserver/pull/176#issuecomment-77134583
  
    I use httpbin as origin server. It's simple and useful. I does not Popen it in the test case. Maybe we can do this in tsqa.
    
    https://github.com/Runscope/httpbin#installing-and-running-from-pypi


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver pull request: add initial remap tests

Posted by jacksontj <gi...@git.apache.org>.
Github user jacksontj commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/176#discussion_r27270042
  
    --- Diff: ci/new_tsqa/tests/test_remap.py ---
    @@ -0,0 +1,125 @@
    +#  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.
    +
    +import os
    +import requests
    +import time
    +import logging
    +
    +import helpers
    +
    +import tsqa.test_cases
    +import tsqa.utils
    +import tsqa.endpoint
    +
    +log = logging.getLogger(__name__)
    +
    +class TestRemapHTTP(tsqa.test_cases.DynamicHTTPEndpointCase, helpers.EnvironmentCase):
    +    @classmethod
    +    def setUpEnv(cls, env):
    +        cls.configs['records.config']['CONFIG'].update({
    +            'proxy.config.diags.debug.enabled': 1,
    +            'proxy.config.diags.debug.tags': 'url.*',
    +        })
    +
    +        cls.configs['remap.config'].add_line(
    +            'map http://www.example.com http://127.0.0.1:{0}'.format(cls.http_endpoint.address[1]));
    +        cls.configs['remap.config'].add_line(
    +            'map http://www.example.com:8080 http://127.0.0.1:{0}'.format(cls.http_endpoint.address[1]));
    +
    +        def hello(request):
    +            return 'hello'
    +        cls.http_endpoint.add_handler('/', hello)
    +
    +    def test_remap_http(self):
    +        s = requests.Session()
    +        http_port = self.configs['records.config']['CONFIG']['proxy.config.http.server_ports']
    +        url = 'http://127.0.0.1:{0}/'.format(http_port)
    +
    +        ret = s.get(url)
    +        self.assertEqual(ret.status_code, 404)
    +
    +        s.headers.update({'Host': 'www.example.com'})
    +        ret = s.get(url)
    +        self.assertEqual(ret.status_code, 200)
    +
    +        s.headers.update({'Host': 'www.example.com:80'})
    +        ret = s.get(url)
    +        self.assertEqual(ret.status_code, 200)
    +
    +        s.headers.update({'Host': 'www.example.com:8080'})
    +        ret = s.get(url)
    +        self.assertEqual(ret.status_code, 200)
    +
    +        s.headers.update({'Host': 'www.test.com'})
    +        ret = s.get(url)
    +        self.assertEqual(ret.status_code, 404)
    +
    +        s.headers.update({'Host': 'www.example.com:1234'})
    +        ret = s.get(url)
    +        self.assertEqual(ret.status_code, 404)
    +
    +class TestRemapHTTPS(tsqa.test_cases.DynamicHTTPEndpointCase, helpers.EnvironmentCase):
    +    @classmethod
    +    def setUpEnv(cls, env):
    +        # set an SSL port to ATS
    +        cls.ssl_port = tsqa.utils.bind_unused_port()[1]
    +        cls.configs['records.config']['CONFIG']['proxy.config.http.server_ports'] += ' {0}:ssl'.format(cls.ssl_port)
    +        cls.configs['records.config']['CONFIG'].update({
    +            'proxy.config.diags.debug.enabled': 1,
    +            'proxy.config.diags.debug.tags': 'url.*'
    +        })
    +
    +        cls.configs['remap.config'].add_line(
    +                'map https://www.example.com http://127.0.0.1:{0}'.format(cls.http_endpoint.address[1]));
    +        cls.configs['remap.config'].add_line(
    +                'map https://www.example.com:4443 http://127.0.0.1:{0}'.format(cls.http_endpoint.address[1]));
    +        # configure SSL multicert
    +        cls.configs['ssl_multicert.config'].add_line(
    +                'dest_ip=* ssl_cert_name={0}'.format(helpers.tests_file_path('rsa_keys/www.example.com.pem')))
    +
    +        def hello(request):
    +            return 'hello'
    +        cls.http_endpoint.add_handler('/', hello)
    +
    +    def test_remap_https(self):
    +        s = requests.Session()
    +        url = 'https://127.0.0.1:{0}/'.format(self.ssl_port)
    +
    +        # We lack of SNI support in requests module, so we do not verify SSL certificate here.
    --- End diff --
    
    We also have separate tests for certificate validation. If you are interested you could call that function-- but since its tested there its not necessary to test here IMO


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver pull request: add initial remap tests

Posted by jacksontj <gi...@git.apache.org>.
Github user jacksontj commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/176#discussion_r25991315
  
    --- Diff: ci/new_tsqa/tests/test_remap.py ---
    @@ -0,0 +1,119 @@
    +#  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.
    +
    +import os
    +import requests
    +import time
    +import logging
    +
    +import helpers
    +
    +import tsqa.test_cases
    +import tsqa.utils
    +import tsqa.endpoint
    +
    +log = logging.getLogger(__name__)
    +
    +unittest = tsqa.utils.import_unittest()
    +
    +class TestRemapHTTP(helpers.EnvironmentCase):
    +    @classmethod
    +    def setUpEnv(cls, env):
    +        cls.configs['records.config']['CONFIG'].update({
    +            'proxy.config.diags.debug.enabled': 1,
    +            'proxy.config.diags.debug.tags': 'url.*',
    +        })
    +
    +        # test with a httpbin running on localhost and port 8000
    +        cls.configs['remap.config'].add_line('map http://www.example.com http://127.0.0.1:8000/\n');
    --- End diff --
    
    I'd recommend using the dynamic endpoint test case (https://github.com/apache/trafficserver-qa/blob/master/examples/endpoint_cases.py) as the origin-- to keep it contained within the framework.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver pull request: add initial remap tests

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/trafficserver/pull/176


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver pull request: add initial remap tests

Posted by jacksontj <gi...@git.apache.org>.
Github user jacksontj commented on the pull request:

    https://github.com/apache/trafficserver/pull/176#issuecomment-86777477
  
    Merged :)
    
    On Thu, Mar 26, 2015 at 3:02 AM, Cai Feifei <no...@github.com>
    wrote:
    
    > Hi @jacksontj <https://github.com/jacksontj> ,
    > Could you please help review my new commit?
    >
    > —
    > Reply to this email directly or view it on GitHub
    > <https://github.com/apache/trafficserver/pull/176#issuecomment-86432234>.
    >



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver pull request: add initial remap tests

Posted by jacksontj <gi...@git.apache.org>.
Github user jacksontj commented on the pull request:

    https://github.com/apache/trafficserver/pull/176#issuecomment-77666262
  
    Besides the origin server used, the tests seem sane :)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver pull request: add initial remap tests

Posted by ffcai <gi...@git.apache.org>.
Github user ffcai commented on the pull request:

    https://github.com/apache/trafficserver/pull/176#issuecomment-86432234
  
    Hi @jacksontj ,
    Could you please help review my new commit?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---