~ubuntu-branches/ubuntu/precise/keystone/precise-security

« back to all changes in this revision

Viewing changes to docs/source/developing.rst

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-03-09 12:26:12 UTC
  • mto: (25.1.1 precise-proposed)
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: package-import@ubuntu.com-20120309122612-t4zqpaytkiptezsa
Tags: upstream-2012.1~rc1~20120308.2103
Import upstream version 2012.1~rc1~20120308.2103

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
..
2
 
      Copyright 2011-2012 OpenStack, LLC
3
 
      All Rights Reserved.
4
 
 
5
 
      Licensed under the Apache License, Version 2.0 (the "License"); you may
6
 
      not use this file except in compliance with the License. You may obtain
7
 
      a copy of the License at
8
 
 
9
 
          http://www.apache.org/licenses/LICENSE-2.0
10
 
 
11
 
      Unless required by applicable law or agreed to in writing, software
12
 
      distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
 
      WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
 
      License for the specific language governing permissions and limitations
15
 
      under the License.
16
 
 
17
 
========================
18
 
Developing with Keystone
19
 
========================
20
 
 
21
 
Contributing Code
22
 
=================
23
 
 
24
 
To contribute code, sign up for a Launchpad account and sign a contributor
25
 
license agreement, available on the `<http://wiki.openstack.org/CLA>`_. Once
26
 
the CLA is signed you can contribute code through the Gerrit version control
27
 
system which is related to your Launchpad account.
28
 
 
29
 
 
30
 
To contribute tests, docs, code, etc, refer to our `Gerrit-Jenkins-Github Workflow`_.
31
 
 
32
 
.. _`Gerrit-Jenkins-Github Workflow`: http://wiki.openstack.org/GerritJenkinsGithub
33
 
 
34
 
Setup
35
 
-----
36
 
 
37
 
Get your development environment set up according to :doc:`setup`. The
38
 
instructions from here will assume that you have installed keystone into a
39
 
virtualenv. If you chose not to, simply exclude "tools/with_venv.sh" from the
40
 
example commands below.
41
 
 
42
 
 
43
 
Running Keystone
44
 
----------------
45
 
 
46
 
To run the keystone Admin and API server instances, use::
47
 
 
48
 
    $ tools/with_venv.sh bin/keystone-all
49
 
 
50
 
this runs keystone with the configuration the etc/ directory of the project.
51
 
See :doc:`configuration` for details on how Keystone is configured. By default,
52
 
keystone is configured with KVS backends, so any data entered into keystone run
53
 
in this fashion will not persist across restarts.
54
 
 
55
 
 
56
 
Interacting with Keystone
57
 
-------------------------
58
 
 
59
 
You can interact with Keystone through the command line using
60
 
:doc:`man/keystone-manage` which allows you to establish tenants, users, etc.
61
 
 
62
 
 
63
 
You can also interact with Keystone through it's REST API. There is a python
64
 
keystone client library `python-keystoneclient`_ which interacts exclusively
65
 
through the REST API, and which keystone itself uses to provide it's
66
 
command-line interface.
67
 
 
68
 
When initially getting set up, after you've configured which databases to use,
69
 
you're probably going to need to run the following to your database schema in
70
 
place::
71
 
 
72
 
    $ bin/keystone-manage db_sync
73
 
 
74
 
.. _`python-keystoneclient`: https://github.com/openstack/python-keystoneclient
75
 
 
76
 
Running Tests
77
 
=============
78
 
 
79
 
To run the full suites of tests maintained within Keystone, run::
80
 
 
81
 
    $ ./run_tests.sh
82
 
 
83
 
This shows realtime feedback during test execution, iterates over
84
 
multiple configuration variations, and uses external projects to do
85
 
light integration testing to verify the keystone API against other projects.
86
 
 
87
 
Test Structure
88
 
--------------
89
 
 
90
 
``./run_test.sh`` uses its python cohort (``run_tests.py``) to iterate
91
 
through the ``tests`` directory, using Nosetest to collect the tests and
92
 
invoke them using an OpenStack custom test running that displays the tests
93
 
as well as the time taken to
94
 
run those tests.
95
 
 
96
 
Within the tests directory, the general structure of the tests is a basic
97
 
set of tests represented under a test class, and then subclasses of those
98
 
tests under other classes with different configurations to drive different
99
 
backends through the APIs.
100
 
 
101
 
For example, ``test_backend.py`` has a sequence of tests under the class
102
 
``IdentityTests`` that will work with the default drivers as configured in
103
 
this projects etc/ directory. ``test_backend_sql.py`` subclasses those tests,
104
 
changing the configuration by overriding with configuration files stored in
105
 
the tests directory aimed at enabling the SQL backend for the Identity module.
106
 
 
107
 
Likewise, ``test_cli.py`` takes advantage of the tests written aainst
108
 
``test_keystoneclient`` to verify the same tests function through different
109
 
drivers.
110
 
 
111
 
Testing Schema Migrations
112
 
-------------------------
113
 
 
114
 
The application of schema migrations can be tested using SQLAlchemy Migrate’s
115
 
built-in test runner, one migration at a time.
116
 
 
117
 
.. WARNING::
118
 
 
119
 
    This may leave your database in an inconsistent state; attempt this in non-production environments only!
120
 
 
121
 
This is useful for testing the *next* migration in sequence (both forward &
122
 
backward) in a database under version control::
123
 
 
124
 
 
125
 
    python keystone/common/sql/migrate_repo/manage.py test \
126
 
    --url=sqlite:///test.db \
127
 
    --repository=keystone/common/sql/migrate_repo/
128
 
 
129
 
This command references to a SQLite database (test.db) to be used. Depending on
130
 
the migration, this command alone does not make assertions as to the integrity
131
 
of your data during migration.
132
 
 
133
 
 
134
 
Writing Tests
135
 
-------------
136
 
 
137
 
To add tests covering all drivers, update the base test class
138
 
(``test_backend.py``, ``test_legacy_compat.py``, and
139
 
``test_keystoneclient.py``).
140
 
 
141
 
To add new drivers, subclass the ``test_backend.py`` (look towards
142
 
``test_backend_sql.py`` or ``test_backend_kvs.py`` for examples) and update the
143
 
configuration of the test class in ``setUp()``.
144
 
 
145
 
 
146
 
Further Testing
147
 
---------------
148
 
 
149
 
devstack_ is the *best* way to quickly deploy keystone with the rest of the
150
 
OpenStack universe and should be critical step in your development workflow!
151
 
 
152
 
You may also be interested in either the
153
 
`OpenStack Continuous Integration Project`_ or the
154
 
`OpenStack Integration Testing Project`_.
155
 
 
156
 
.. _devstack: http://devstack.org/
157
 
.. _OpenStack Continuous Integration Project: https://github.com/openstack/openstack-ci
158
 
.. _OpenStack Integration Testing Project: https://github.com/openstack/tempest
159
 
 
160
 
Building the Documentation
161
 
==========================
162
 
 
163
 
The documentation is all generated with Sphinx from within the docs directory.
164
 
To generate the full set of HTML documentation:
165
 
 
166
 
    cd docs
167
 
    make autodoc
168
 
    make html
169
 
    make man
170
 
 
171
 
the results are in the docs/build/html and docs/build/man directories
172
 
respectively.