public void WasabiRulesEngine_AddDuplicateRule() { var rule1 = new WasabiWebRule("tom", 3, 3); var rule2 = new WasabiWebRule("tom", 3, 3); var engine = new WasabiWebRulesEngine("mysite", 3); engine.AddRule(rule1); engine.AddRule(rule2); }
public void WasabiRulesEngine_CreateManyWithAnd_ScaleUp() { // arrange - tom is 5 and bob is 9 var rule1 = new WasabiWebRule("tom", 4, 2); var rule2 = new WasabiWebRule("bob", 8, 2); var engine = new WasabiWebRulesEngine("mysite", 3); engine.AddRule(rule1); engine.AddRule(rule2); // act var response = engine.Scale(WasabiWebLogicalOperation.And, AddSecondMetric()); // assert response.Should().Be(WasabiWebState.ScaleUp); }
public void WasabiRulesEngine_CreateManyWithAnd_ScaleDown3() { // arrange - tom is 5 and bob is 9 bill is 11 var rule1 = new WasabiWebRule("tom", 14, 6); // scale down var rule2 = new WasabiWebRule("bob", 8, 6); // scale up var rule3 = new WasabiWebRule("bill", 17, 12); // scale down var engine = new WasabiWebRulesEngine("mysite", 3); engine.AddRule(rule1); engine.AddRule(rule2); engine.AddRule(rule3); // act var response = engine.Scale(WasabiWebLogicalOperation.And, AddThirdMetric()); // assert response.Should().Be(WasabiWebState.LeaveUnchanged); }
public void WasabiRulesEngine_CreateManyWithOr_Unchanged() { // arrange - tom is 5 and bob is 9 bill is var rule1 = new WasabiWebRule("tom", 14, 6); var rule2 = new WasabiWebRule("bob", 8, 6); var engine = new WasabiWebRulesEngine("mysite", 3); engine.AddRule(rule1); engine.AddRule(rule2); // act var response = engine.Scale(WasabiWebLogicalOperation.Or, AddSecondMetric()); // assert response.Should().Be(WasabiWebState.LeaveUnchanged); }
public void WasabiRulesEngine_CreateManyWithAnd_ScaleDown() { // arrange - tom is 5 and bob is 9 var rule1 = new WasabiWebRule("tom", 14, 6); var rule2 = new WasabiWebRule("bob", 18, 10); var engine = new WasabiWebRulesEngine("mysite", 3); engine.AddRule(rule1); engine.AddRule(rule2); // act var response = engine.Scale(WasabiWebLogicalOperation.And, AddSecondMetric()); // assert response.Should().Be(WasabiWebState.ScaleDown); }
public void Execute() { //System.Console.WriteLine("reading website"); //System.Console.WriteLine("================"); //var client = new WebsiteClient(_subscriptionId, _certificate); //var list = client.List(); //list.ForEach(a => System.Console.WriteLine("Website hosts: " + String.Join(", ", a.Hostname.ToArray()))); //var client3 = new WebsiteClient(_subscriptionId, _certificate, "ukwaug"); //System.Console.WriteLine(client3.WebsiteProperties.Config.DetailedErrorLoggingEnabled); //var metrics = client3.GetWebsiteMetricsPerInterval(TimeSpan.FromMinutes(600)); //metrics.ForEach(a => System.Console.WriteLine("Name: {0}, Value: {1} {2}", a.Name, a.Total, a.Units)); //var engine = new WasabiWebRulesEngine("ukwaug", 5); //engine.AddRule(new WasabiWebRule(MetricsConstants.BytesReceived, 10000000, 10000000)); //engine.AddRule(new WasabiWebRule(MetricsConstants.CpuTime, 560000, 5600000)); //var connector = new WebsiteManagementConnector(engine, _subscriptionId, WasabiWebLogicalOperation.Or) // { // ManagementCertificate = _certificate // }; //connector.ScaleUpdate += (state, count) => System.Console.WriteLine("State: {0}, Scale: {1}", state, count); //connector.MonitorAndScale(); var client3 = new WebsiteClient(_subscriptionId, _certificate, "fluentwebtest38"); client3.Stop(); client3.Restart(); var engineAlert = new WasabiWebRulesEngine("fluentwebtest38", 200); engineAlert.AddRule(new WasabiWebRule(MetricsConstants.Http2xx, 3)); var connector2 = new WebsiteManagementConnector(engineAlert, _subscriptionId, WasabiWebLogicalOperation.Or) { ManagementCertificate = _certificate }; //connector2.SubscribeAlerts += // (metric, rule) => // System.Console.WriteLine("Name: {0}, value: {1} {2}", metric.Name, metric.Total, metric.Units); //connector2.MonitorAndAlert(); //connector2.SubscribeAlerts += // (metric, rule) => // System.Console.WriteLine("Name: {0}, value: {1} {2}", metric.Name, metric.Total, metric.Units); //connector2.MonitorAndAlert(); connector2.ScaleUpdate += (state, count) => System.Console.WriteLine("State: {0}, Scale: {1}", state, count); connector2.MonitorAndScale(); }
public void WasabiRulesEngine_CreateSingle_ScaleDown() { // arrange var rule = new WasabiWebRule("tom", 9, 6); var engine = new WasabiWebRulesEngine("mysite", 3); engine.AddRule(rule); // act var response = engine.Scale(WasabiWebLogicalOperation.And, GetInitialMetric()); // assert response.Should().Be(WasabiWebState.ScaleDown); }
public void WasabiRulesEngine_CreateSingle_Unchanged() { // arrange var rule = new WasabiWebRule("tom", 9, 6); var engine = new WasabiWebRulesEngine("mysite", 3); engine.AddRule(rule); // act var response = engine.Scale(WasabiWebLogicalOperation.And, GetInitialMetric()); // assert response.Should().Be(WasabiWebState.ScaleDown); }