PoC for testing the approach of n-version programming
- Python 43.5%
- Rust 41.8%
- Shell 10.3%
- Dockerfile 4.4%
| n-versions | Adapting python api for current test setup | |
| orchestrator | Improve documentation and example usage of the PoC | |
| Postman | Improve documentation and example usage of the PoC | |
| .gitignore | Improve documentation and example usage of the PoC | |
| docker-compose.yml | Remove ports used for testing | |
| generateApis.sh | Adding generated python api for testing specific types | |
| LICENSE | Initial commit | |
| openApi_spec.yml | Adding generated python api for testing specific types | |
| README.md | Improve documentation and example usage of the PoC | |
n-version-programming
PoC for testing the approach of n-version programming.
Usage
- Build and start the docker images using
docker compose up -din the base directory. - Optional: Follow the orchestrator's logs using
docker logs -f orchestrator. - Send a request to the orchestrator and check the results. Use e.g. curl or Postman:
- Use the address localhost:3000 or change the mapping in the compose file.
- Currently, the implementation of the n-versions only support GET requests using the paths /bool and /int.
- /bool returns a random boolean, /int a random integer between 0 and 9. The orchestrator compares the results of the n-versions and returns it in case of a match. This means the chance of a result is better when using /bool.
Components
This prototype is composed of the following components:
- Versions. The individual versions are implemented in different programming languages to follow the idea of n-version programming. They can be found in their individual directories in here.
- Orchestrator. The orchestrator serves as entrypoint for requests from clients. Incoming requests are distributed over all available instances and their responses are consolidated and compared before sending a reply to the client. While proxys like nginx can mirror requests and therefore implement the first step, the responses are ignored. Therefore this feature is not helpful. Similar story with Traefik. While requests can be mirrored, only a defined primary instance can respond back to the clients as is elaborated here. To implement the workflow myself, Rocket was chosen as a framework for its simplicity and type safety. The resulting code and its documentation can be found here.
- (Client. tbd, use Postman or curl for the moment)
OpenAPI
N-version programming requires the versions to be based on the same specification. This way, any mismatch in the behavior of the versions needs to be rooted in its implementations or technologies used. To archive this, one central OpenAPI specification is used to generate the versions API routes.
References
- Swagger Spec
- Swagger Editor
- Inspiration for the orchestrator implementation
- Technical documentation for Rocket
Open ToDos
- Add additional n-versions leveraging different programming languages and frameworks. At the moment, only Python is used for the PoC.
- Use the orchestrator for some third-party API. Adapt the comparision algorithm to deal with all the missing data structures (like JSON).
- Write software tests.