Setup Semian Configuration Validation
Addressing this issue: https://github.com/Shopify/semian/issues/633
Changes
Created ConfigurationValidator class that handles all validations and constraints for the following Semian config values:
name: Must be string / symbol and cannot be a duplicate Semian name of one that exists inSemian.resources:circuit_breaker&:bulkhead: Cannot both be disabled:tickets&:quota: If bulkhead, can only have:ticketsor:quota, cannot be both:tickets: Must be between 0 andSemian::MAX_TICKETS, inclusive:quota: Must be a ratio between 0 and 1, inclusive
:success_threshold,:error_threshold&:error_timeout: If circuit breaker, validate that theserequiredparams exist.:success_threshold&:error_threshold: If circuit breaker, validate that they are positive numbers:error_timeout,:error_threshold_timeout,:half_open_resource_timeout,:lumping_interval: If circuit breaker and exists, validate that they are non-negative.
We have also added constraints to the timeout values to ensure that Semians don't end up in weird scenarios (never opens, closes, never half-opens, etc.):
lumping_interval * (error_threshold - 1) <= error_threshold_timeouthalf_open_resource_timeout <= error_timeouthalf_open_resource_timeout <= error_threshold_timeout
Finally, we added test cases to address each of the above constraints, and modified non-validation related test cases to conform to ConfigurationValidator class.
Rationale
We are looking to add validations to configuration options on Semians, to ensure that invalid or otherwise impossible Semian configuration are not created (result in an Exception raised) and do not persist in production. This will help alleviate any cases of incidents or investigations where Semians do not open due to impossible conditions.