Skip to content

Dev Contrib: UT with AWS

Alix Lourme edited this page Jul 27, 2018 · 35 revisions

Unit Tests execution requires an Openstack endpoint platform ; Tips with Amazon EC2.

Openstack platform creation

  1. On Amazon AWS, create a Ubuntu ~t2.large instance.
  2. Install Openstack DevStack on it, using pike version (the last with keystone identity v2) ; add -b stable/pike at end of git clone command)
  3. Update Security group of instance to authorize port HTTP 80 (Openstack main endpoint) and 9696 (Openstack neutron network API)

Check if all is OK by retrieve a token through API using demo user (AWS URL & admin password should be updated):

curl --request POST --include --header "Content-Type: application/json" \
     --data '{"auth":{"identity":{"methods":["password"],"password":{"user":{"name":"demo","domain":{"name":"default"},"password":"secret"}}},"scope":{"project":{"name":"demo","domain":{"name":"default"}}}}}' \
     http://ec2-x.y.y.region.compute.amazonaws.com/identity/v3/auth/tokens

--> HTTP/1.1 201 Created

Openstack platform configuration

Public API access

By default, Openstack devstack is using eth0 ip for services URL. So this AWS private ip is in response of keystone-identity API ... and not accessible publicly. Neutron URL service API should be updated with AWS public URL.

Connect on Openstack instance though SSH and execute (AWS URL & admin password should be updated):

export OS_IDENTITY_API_VERSION=3
export OS_AUTH_URL=http://localhost/identity/v3
export OS_DEFAULT_DOMAIN=default
export OS_USERNAME=admin
export OS_PASSWORD=secret
export OS_PROJECT_NAME=admin

NEUTRON_ID=`openstack endpoint list | grep neutron | cut -d "|" -f 2 | xargs`
openstack endpoint set --url "http://ec2-x.y.y.region.compute.amazonaws.com:9696/" $NEUTRON_ID

Test datas

On Openstack dasboard:

  1. Create a keypair (ex: demo) to use in tests files
  2. Allocate some floating ip to the project (required for some unit test and good code coverage)

TeamCity Openstack plugin tests files content

In TeamCity Openstack plugin source code, create tests files in directory cloud-openstack-server/src/test/resources (AWS URL & admin password should be updated).

test.v3.properties:

test.url=httphttps://ec2-x.y.y.region.compute.amazonaws.com/identity/v3
test.identity=default:demo:default:demo
test.password=secret
test.region=RegionOne

test.v3.yml

openstack-test-teamcity-plugin:
  image: cirros-0.3.5-x86_64-disk
  flavor: m1.tiny
  network: private
  security_group: default
  key_pair: demo
  auto_floating_ip: true

test.v2.properties:

test.url=https://ec2-x.y.y.region.compute.amazonaws.com/identity/v2.0
test.identity=default:demo:default:demo
test.password=secret
test.region=RegionOne

test.v2.yml

openstack-test-teamcity-plugin:
  image: cirros-0.3.5-x86_64-disk
  flavor: m1.tiny
  network: private
  security_group: default
  key_pair: demo
Clone this wiki locally