Cloud Integration Testing Framework (citest) is a python package to facilitate
writing integration tests against the REST style APIs typically used by
cloud services.
The gist is to allow tests to be written using a literary programming style
where the core framework accommodates for asynchronous calls and even retries
if appropriate.
Integration tests are written against services by sending an operation to
the service then observing the effects of that operation and verifying them
against expectations.
citest introduces a BaseAgent class for adapting external services
to the framework where the agent is responsible for understanding the
transport and protocol for exchanging messages with the service. It introduces
some basic concrete types such as HttpAgent and CliAgent where the primary
means is HTTP messaging or running a command-line program. Specific systems
may need to further specialize these to understand any additional application
protocols added, such as status responses for asynchronous HTTP messaging.
BaseAgent also acts as an AgentOperation factory where the operations
provide a means to wrap these service calls as first-class objects understood
by the core citest framework. This allows citest to invoke (or reinvoke)
the operation when it is appropriate to do so, rather than when the static code
is specifying what the test will be. When executed, the AgentOperation will
create an OperationStatus allowing citest to track its progress and
eventual result.
In order to verify the operation, citest uses Contract objects. A contract
is a collection of ContractClause where each clause can look for different
effects. A ContractClause is typically composed of an observation on the
effects and an assertion about what is expected to be observed. The observation
is made by an Observer that collects data in an Observation by working with
a BaseAgent to collect the data (e.g. an HTTP GET on some
JSON resource). The assertion is made by looking for expected values and
patterns in the collected resources. Each clause can collect different
resources.
The assertions are written using specialized ValuePredicate objects, which
are python callable classes that take the object value to be validate and return
a PredicateResult containing the conclusion and justification for it.
When a test is run, it will provide a trace of the operations performed,
data collected and justifications as to why it thinks the collected data
meets or does not meet expectations, ultimately passing or failing the test.
Physical Organization
SubPackage
Purpose
base
Introduces some classes and utilities that support other packages.
json_contract
Introduces a means to specify observers to collect JSON documents, and to define contracts specifying expectations of the collected JSON content.
json_predicate
Introduces a means to locate and attributes within JSON objects, and compare their values. These are used as the basis of json_contract.
service_testing
Introduces the core framework, base classes, and generic utilities.
aws_testing
Specializations and extensions to support testing on Amazon Web Services (AWS)
gcp_testing
Specializations and extensions to support testing on Google Cloud Platform (GCP)
openstack_testing
Specializations and extensions to support testing on OpenStack
azure_testing
Specializations and extensions to support testing on Microsoft Azure (AZ)
Summary
Cloud Integration Testing Framework (citest) is a python package to facilitate writing integration tests against the REST style APIs typically used by cloud services.
The gist is to allow tests to be written using a literary programming style where the core framework accommodates for asynchronous calls and even retries if appropriate.
Setup
Example
A test case might look something like this:
Where the test can be executed like this:
Overview
Abstract Model
Integration tests are written against services by sending an operation to the service then observing the effects of that operation and verifying them against expectations.
citestintroduces aBaseAgentclass for adapting external services to the framework where the agent is responsible for understanding the transport and protocol for exchanging messages with the service. It introduces some basic concrete types such asHttpAgentandCliAgentwhere the primary means is HTTP messaging or running a command-line program. Specific systems may need to further specialize these to understand any additional application protocols added, such as status responses for asynchronous HTTP messaging.BaseAgentalso acts as anAgentOperationfactory where the operations provide a means to wrap these service calls as first-class objects understood by the corecitestframework. This allowscitestto invoke (or reinvoke) the operation when it is appropriate to do so, rather than when the static code is specifying what the test will be. When executed, theAgentOperationwill create anOperationStatusallowingcitestto track its progress and eventual result.In order to verify the operation,
citestusesContractobjects. A contract is a collection ofContractClausewhere each clause can look for different effects. AContractClauseis typically composed of an observation on the effects and an assertion about what is expected to be observed. The observation is made by anObserverthat collects data in anObservationby working with aBaseAgentto collect the data (e.g. an HTTP GET on some JSON resource). The assertion is made by looking for expected values and patterns in the collected resources. Each clause can collect different resources.The assertions are written using specialized
ValuePredicateobjects, which are python callable classes that take the object value to be validate and return aPredicateResultcontaining the conclusion and justification for it.When a test is run, it will provide a trace of the operations performed, data collected and justifications as to why it thinks the collected data meets or does not meet expectations, ultimately passing or failing the test.
Physical Organization
More Examples
For more examples, see:
Documentation
The Usage Overview Document provides some instructions and examples to guide basic usage.
Contributing
See the CONTRIBUTING file for more information.
License
See the LICENSE file for more information.
The package is composed of several subpackages of individual modules.
Contact Info
For more information, problems, or interest, contact ewiseblatt@google.com.