Package yakumo :: Package smoketests :: Module st13_v3_service_endpoint_admin
[hide private]
[frames] | no frames]

Source Code for Module yakumo.smoketests.st13_v3_service_endpoint_admin

  1  #!/usr/bin/env python 
  2  # 
  3  # Copyright 2014-2017 by Akira Yoshiyama <akirayoshiyama@gmail.com>. 
  4  # All Rights Reserved. 
  5  # 
  6  #    Licensed under the Apache License, Version 2.0 (the "License"); you may 
  7  #    not use this file except in compliance with the License. You may obtain 
  8  #    a copy of the License at 
  9  # 
 10  #         http://www.apache.org/licenses/LICENSE-2.0 
 11  # 
 12  #    Unless required by applicable law or agreed to in writing, software 
 13  #    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
 14  #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 
 15  #    License for the specific language governing permissions and limitations 
 16  #    under the License. 
 17  """Identity API v3 Test (Services/Endpoints)""" 
 18   
 19   
 20  import hashlib 
 21  import os 
 22  import sys 
 23  import tempfile 
 24   
 25  from yakumo.smoketest import * 
 26  from yakumo import utils 
 27   
 28   
29 -def main(c):
30 31 # check Identity API version 32 if c._session.config[u'identity_api_version'] != '3': 33 return 34 35 LOG.info("Create Service #1") 36 name = get_random_str('service') 37 with c.service.create(name=name, 38 type='type1', 39 description='service 1', 40 is_enabled=False) as s: 41 42 test("Service #1: name is %s" % name, s.name == name) 43 test("Service #1: type is 'type1'", s.type == 'type1') 44 test("Service #1: description is 'service 1'", 45 s.description == 'service 1') 46 test("Service #1: is disabled", not s.is_enabled) 47 48 LOG.info("Update service properties") 49 name = get_random_str('service') 50 s.update(name=name, type='type2', description='service 2', 51 is_enabled=True) 52 53 test("Service #1: name is %s" % name, s.name == name) 54 test("Service #1: type is 'type1'", s.type == 'type2') 55 test("Service #1: description is 'service 2'", 56 s.description == 'service 2') 57 test("Service #1: is enabled", s.is_enabled) 58 59 LOG.info("Create Region #1") 60 region_id = get_random_str('region') 61 with c.region.create(id=region_id, description='region 1') as r: 62 63 test("Region #1: id is %s" % region_id, r.id == region_id) 64 test("Region #1: description is 'region 1'", 65 r.description == 'region 1') 66 67 LOG.info("Update region properties") 68 r.update(description='region 2') 69 70 test("Region #1: description is 'region 2'", 71 r.description == 'region 2') 72 73 LOG.info("Create Endpoints") 74 name = get_random_str('endpoint') 75 url = 'http://%s/v1/public' % name 76 with c.endpoint.create(url=url, 77 interface='public', 78 region=r, 79 service=s) as e: 80 81 test("Endpoints #1: service is %s" % s.name, e.service == s) 82 test("Endpoints #1: region is %s" % r.id, e.region == r) 83 test("Endpoints #1: url is %s" % url, e.url == url) 84 test("Endpoints #1: interface is public", 85 e.interface == 'public') 86 87 LOG.info("Update endpoint properties") 88 name = get_random_str('endpoint') 89 url = 'http://%s/v1/internal' % name 90 e.update(url=url, interface='internal') 91 92 test("Endpoints #1: url is %s" % url, e.url == url) 93 test("Endpoints #1: interface is internal", 94 e.interface == 'internal')
95 96 97 if __name__ == '__main__': 98 c = utils.get_client() 99 if c._session.config[u'identity_api_version'] != '3': 100 sys.exit(0) 101 102 LOG.debug("list services: %s", [_.name for _ in c.service.list()]) 103 LOG.debug("list endpoints: %s", c.endpoint.list()) 104 main(c) 105 LOG.debug("list service: %s", [_.name for _ in c.service.list()]) 106 LOG.debug("list endpoints: %s", c.endpoint.list()) 107 108 show_test_summary() 109