Package: chaostoolkit-service-fabric
Chaos Toolkit Extension for Service FabricThis project is a collection ofactionsandprobes, gathered as an
extension to theChaos Toolkit. It targets theMicrosoft Service Fabricplatform.InstallThis package requires Python 3.5+To be used from your experiment, this package must be installed in the Python
environment wherechaostoolkitalready lives.$ pip install -U chaostoolkit-service-fabricUsageTo use the probes and actions from this package, add the following to your
experiment file:{"type":"action","name":"start-service-factory-chaos","provider":{"type":"python","module":"chaosservicefabric.factory.actions","func":"start_chaos","secrets":["azure"],"arguments":{"parameters":{"TimeToRunInSeconds":45}}}},{"type":"action","name":"stop-service-factory-chaos","provider":{"type":"python","module":"chaosservicefabric.factory.actions","func":"stop_chaos","secrets":["azure"]}}The parameters are straight from theService Fabric API.That's it!Please explore the code to see existing probes and actions.ConfigurationCredentialsThis extension uses therequestslibrary under the hood. The requests library
expects that you have a PFX certificate, converted as to the PEM format, that allows you to
authenticate with theService Factoryendpoint.Generally speaking, there are two ways of doing this:you havecreateda configuration file where you will run the
experiment from (so with a~/.sfctl/configfile)you explicitly pass the correct environment variables to the experiment
definition as follows:Configuration section:{"endpoint":"https://XYZ.westus.cloudapp.azure.com:19080","verify_tls":false,"use_ca":false}Secrets section:{"azure":{"security":"pem","pem_path":"./cluster-client-cert.pem"}}The PEM can also be passed as an environment variable:{"azure":{"security":"pem","pem_content":{"type":"env","key":"AZURE_PEM"}}}The environment variable name can be anything.Putting it all togetherHere is a full example:{"version":"1.0.0","title":"...","description":"...","configuration":{"endpoint":"https://XYZ.westus.cloudapp.azure.com:19080","verify_tls":false,"use_ca":false},"secrets":{"azure":{"security":"pem","pem_path":"./cluster-client-cert.pem"}},"steady-state-hypothesis":{"title":"Services is healthy","probes":[{"type":"probe","name":"application-must-respond","tolerance":200,"provider":{"type":"http","verify_tls":false,"url":"https://some-url-in-cluster/"}}]},"method":[{"type":"action","name":"start-service-factory-chaos","provider":{"type":"python","module":"chaosservicefabric.factory.actions","func":"start_chaos","secrets":["azure"],"arguments":{"parameters":{"TimeToRunInSeconds":45}}},"pauses":{"after":30}},{"type":"probe","ref":"application-must-respond"},{"type":"action","name":"stop-service-factory-chaos","provider":{"type":"python","module":"chaosservicefabric.factory.actions","func":"stop_chaos","secrets":["azure"]},"pauses":{"after":5}},{"type":"probe","name":"get-service-factory-chaos-report","provider":{"type":"python","module":"chaosservicefabric.factory.probes","func":"chaos_report","secrets":["azure"],"arguments":{"start_time_utc":"1 minute ago","end_time_utc":"now"}}}]}ContributeIf you wish to contribute more functions to this package, you are more than
welcome to do so. Please, fork this project, make your changes following the
usualPEP 8code style, sprinkling with tests and submit a PR for
review.The Chaos Toolkit projects require all contributors must sign aDeveloper Certificate of Originon each commit they would like to merge
into the master branch of the repository. Please, make sure you can abide by
the rules of the DCO before submitting a PR.DevelopIf you wish to develop on this project, make sure to install the development
dependencies. But first,create a virtual environmentand then install
those dependencies.$pipinstall-rrequirements-dev.txt-rrequirements.txtThen, point your environment to this directory:$pythonsetup.pydevelopNow, you can edit the files and they will be automatically be seen by your
environment, even when running from thechaoscommand locally.TestTo run the tests for the project execute the following:$ pytest