Name: acme-freight-controller
Owner: International Business Machines
Description: null
Created: 2017-04-06 20:35:24.0
Updated: 2017-07-12 16:14:19.0
Pushed: 2017-07-10 15:54:57.0
Homepage: null
Size: 6843
Language: Python
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
| master | | | —– | —– | | dev | |
This service is part of the larger Acme Freight project.
This service acts as the main controller for interaction between the system's services.
To automatically deploy this application to Bluemix as part of the larger Acme Freight application, refer to the Bluemix DevOps toolchain on the parent repository.
If you do not already have a Bluemix account, sign up here
Download and install the Cloud Foundry CLI tool
The app depends on the ERP and Recommendation microservices. These applications are deployed automatically as part of the toolchain on the parent acme-freight
repository.
Clone the app to your local environment from your terminal using the following command:
clone https://github.com/ibm/acme-freight-controller.git
cd
into this newly created directory
Open the manifest.yml
file and change the host
value to something unique.
The host you choose will determinate the subdomain of your application's URL: <host>.mybluemix.net
Connect to Bluemix in the command line tool and follow the prompts to log in.
pi https://api.ng.bluemix.net
ogin
Push the app to Bluemix.
ush --no-start
Define the environment variable pointing to the ERP service.
et-env acme-freight-controller ERP_SERVICE <url-to-erp-service-here>
Define the OpenWhisk auth key and the package where the actions of the Recommendation service have been deployed
et-env acme-freight-controller OPENWHISK_AUTH "your-auth-key"
et-env acme-freight-controller OPENWHISK_PACKAGE lwr
Start the app.
tart acme-freight-controller
And voila! You now have your very own instance of the Acme Freight controller running on Bluemix.
If you have not already, download Python 2.7 and install it on your local machine.
Clone the app to your local environment from your terminal using the following command:
clone https://github.com/ibm/acme-freight-controller.git
cd
into this newly created directory
In order to create an isolated development environment, we will be using Python's virtualenv tool. If you do not have it installed already, run
install virtualenv
Then create a virtual environment called venv
by running
ualenv venv
Activate this new environment with
ce .env
Install module requirements
install -r requirements.dev.txt
Finally, start the app
on bin/start_web.py
To override values for your local environment variables create a file named .env.local
from the template:
template-env.local .env.local
and edit the file to match your environment.
There are series of unit tests located in the server/tests
folder. The test suites are composed using the Python unittest framework. To run the tests, execute the following command:
thon server/tests/run_unit_tests.py
Similar as the unit tests but they validate the communication between the controller and the other services, like the ERP service. These tests require a ERP service to be running.
To run the tests, execute the following command:
hon server/tests/run_integration_tests.py
One popular option for continuous integration is Travis CI. We have provided a .travis.yml
file in this repository for convenience. In order to set it up for your repository, take the following actions:
Go to your Travis CI Profile
Check the box next to your acme-freight GitHub repository and then click the settings cog
Create the following environment variables
ACME_FREIGHT_ENV
- TESTThats it! Now your future pushes to GitHub will be built and tested by Travis CI.
If you would like to perform code coverage tests as well, you can use coveralls to perform this task. If you are using Travis CI as your CI tool, simply replace python
in your test commands with coverage run
and then run coveralls
as follows:
coverage run server/tests/run_unit_tests.py
coverage --append run server/tests/run_integration_tests.py
coveralls
To determine how to run coveralls using another CI tool or for more in-depth instructions, check out the coveralls usage documentation.
Note: To pass, the integration tests require an ERP service to be running.
The API methods that this component exposes requires the discovery of dependent services, however, the API will gracefully fail when they are not available.
The API and data models are defined in this Swagger 2.0 file. You can view this file in the Swagger Editor.
Use the Postman collection to help you get started with the controller API:
The primary source of debugging information for your Bluemix app is the logs. To see them, run the following command using the Cloud Foundry CLI:
cf logs acme-freight-controller --recent
For more detailed information on troubleshooting your application, see the Troubleshooting section in the Bluemix documentation.
The acme-freight sample web application includes code to track deployments to Bluemix and other Cloud Foundry platforms. The following information is sent to a Deployment Tracker service on each deployment:
application_name
)space_id
)application_version
)application_uris
)This data is collected from the setup.py
file in the sample application and the VCAP_APPLICATION
and VCAP_SERVICES
environment variables in IBM Bluemix and other Cloud Foundry platforms. This data is used by IBM to track metrics around deployments of sample applications to IBM Bluemix to measure the usefulness of our examples, so that we can continuously improve the content we offer to you. Only deployments of sample applications that include code to ping the Deployment Tracker service will be tracked.
Deployment tracking can be disabled by removing cf_deployment_tracker.track()
from the server/web/__init__.py
file.
See LICENSE for license information.