public void UnrecognizedConfigApplicationField_ThrowException() { using var parser = new YamlParser("asdf: 123"); var exception = Assert.Throws <TyeYamlException>(() => parser.ParseConfigApplication()); Assert.Contains(CoreStrings.FormatUnrecognizedKey("asdf"), exception.Message); }
public void IngressIsSetCorrectly() { var input = @" ingress: - name: ingress bindings: - port: 8080 protocol: http name: foo rules: - path: /A service: appA - path: /B service: appB - host: a.example.com service: appA - host: b.example.com service: appB replicas: 2"; using var parser = new YamlParser(input); var actual = parser.ParseConfigApplication(); var expected = _deserializer.Deserialize <ConfigApplication>(new StringReader(input)); TyeAssert.Equal(expected, actual); }
public void VotingTest() { using var parser = new YamlParser( @"name: VotingSample registry: myregistry services: - name: vote project: vote/vote.csproj - name: redis image: redis bindings: - port: 6379 - name: worker project: worker/worker.csproj - name: postgres image: postgres env: - name: POSTGRES_PASSWORD value: ""test"" bindings: - port: 5432 - name: results project: results/results.csproj"); var app = parser.ParseConfigApplication(); }
public void IngressMustReferenceService() { var input = @" ingress: - name: ingress bindings: - port: 8080 protocol: http name: foo rules: - path: /A service: appA - path: /B service: appB - host: a.example.com service: appA - host: b.example.com service: appB replicas: 2"; using var parser = new YamlParser(input); var app = parser.ParseConfigApplication(); var exception = Assert.Throws <TyeYamlException>(() => app.Validate()); Assert.Contains(CoreStrings.IngressRuleMustReferenceService, exception.Message); }
public void ComprehensionalTest() { var input = @" name: apps-with-ingress registry: myregistry extensions: - name: dapr ingress: - name: ingress bindings: - port: 8080 protocol: http name: foo rules: - path: /A service: appA - path: /B service: appB - host: a.example.com service: appA - host: b.example.com service: appB replicas: 2 services: - name: appA project: ApplicationA/ApplicationA.csproj buildProperties: - name: Configuration - value: Debug replicas: 2 external: false image: abc build: false executable: test.exe workingDirectory: ApplicationA/ args: a b c env: - name: POSTGRES_PASSWORD value: ""test"" - name: POSTGRES_PASSWORD2 value: ""test2"" volumes: - name: volume source: /data target: /data bindings: - name: test port: 4444 connectionString: asdf containerPort: 80 host: localhost protocol: http - name: appB project: ApplicationB/ApplicationB.csproj replicas: 2"; using var parser = new YamlParser(input); var app = parser.ParseConfigApplication(); }
public void Ingress_Replicas_MustBePositive() { using var parser = new YamlParser( @"ingress: - replicas: -1"); var exception = Assert.Throws <TyeYamlException>(() => parser.ParseConfigApplication()); Assert.Contains(CoreStrings.FormatMustBePositive("replicas"), exception.Message); }
public void Ingress_MustBeMappings() { using var parser = new YamlParser( @"ingress: - name"); var exception = Assert.Throws <TyeYamlException>(() => parser.ParseConfigApplication()); Assert.Contains(CoreStrings.FormatUnexpectedType(YamlNodeType.Mapping.ToString(), YamlNodeType.Scalar.ToString()), exception.Message); }
public void Services_MustBeSequence() { using var parser = new YamlParser( @"services: a"); var exception = Assert.Throws <TyeYamlException>(() => parser.ParseConfigApplication()); Assert.Contains(CoreStrings.FormatExpectedYamlSequence("services"), exception.Message); }
public void YamlIsCaseSensitive() { using var parser = new YamlParser( @"Name: abc"); var exception = Assert.Throws <TyeYamlException>(() => parser.ParseConfigApplication()); Assert.Contains(CoreStrings.FormatUnrecognizedKey("Name"), exception.Message); }
public void Ingress_UnrecognizedKey() { using var parser = new YamlParser( @"ingress: - abc: abc"); var exception = Assert.Throws <TyeYamlException>(() => parser.ParseConfigApplication()); Assert.Contains(CoreStrings.FormatUnrecognizedKey("abc"), exception.Message); }
public void Ingress_Bindings_MustSequence() { using var parser = new YamlParser( @"ingress: - bindings: abc"); var exception = Assert.Throws <TyeYamlException>(() => parser.ParseConfigApplication()); Assert.Contains(CoreStrings.FormatExpectedYamlSequence("bindings"), exception.Message); }
public void Registry_MustBeScalar() { using var parser = new YamlParser( @"registry: - a: b"); var exception = Assert.Throws <TyeYamlException>(() => parser.ParseConfigApplication()); Assert.Contains(CoreStrings.FormatExpectedYamlScalar("registry"), exception.Message); }
public void Replicas_MustBeInteger() { using var parser = new YamlParser( @"services: - name: app replicas: asdf"); var exception = Assert.Throws <TyeYamlException>(() => parser.ParseConfigApplication()); Assert.Contains(CoreStrings.FormatMustBeAnInteger("replicas"), exception.Message); }
public void Services_UnrecognizedKey() { using var parser = new YamlParser( @"services: - name: ingress env: abc"); var exception = Assert.Throws <TyeYamlException>(() => parser.ParseConfigApplication()); Assert.Contains(CoreStrings.FormatExpectedYamlSequence("env"), exception.Message); }
public void IngressIsSetCorrectly() { var input = @" ingress: - name: ingress bindings: - port: 8080 protocol: http name: foo rules: - path: /A service: appA - path: /B service: appB - host: a.example.com service: appA - host: b.example.com service: appB replicas: 2"; using var parser = new YamlParser(input); var app = parser.ParseConfigApplication(); var expected = _deserializer.Deserialize <ConfigApplication>(new StringReader(input)); foreach (var ingress in app.Ingress) { var otherIngress = expected .Ingress .Where(o => o.Name == ingress.Name) .Single(); Assert.NotNull(otherIngress); Assert.Equal(otherIngress.Replicas, ingress.Replicas); foreach (var rule in ingress.Rules) { var otherRule = otherIngress .Rules .Where(o => o.Path == rule.Path && o.Host == rule.Host && o.Service == rule.Service) .Single(); Assert.NotNull(otherRule); } foreach (var binding in ingress.Bindings) { var otherBinding = otherIngress .Bindings .Where(o => o.Name == binding.Name && o.Port == binding.Port && o.Protocol == binding.Protocol) .Single(); Assert.NotNull(otherBinding); } } }
public void Services_Build_MustBeBool() { using var parser = new YamlParser( @"services: - name: ingress build: abc"); var exception = Assert.Throws <TyeYamlException>(() => parser.ParseConfigApplication()); Assert.Contains(CoreStrings.FormatMustBeABoolean("build"), exception.Message); }
public void Probe_ScalarFields_MustBeGreaterThanZero(string field) { using var parser = new YamlParser($@" services: - name: sample liveness: {field}: 0"); var exception = Assert.Throws <TyeYamlException>(() => parser.ParseConfigApplication()); Assert.Contains(CoreStrings.FormatMustBeGreaterThanZero(field), exception.Message); }
public void Probe_UnrecognizedKey(string probe) { using var parser = new YamlParser($@" services: - name: sample {probe}: something: something"); var exception = Assert.Throws <TyeYamlException>(() => parser.ParseConfigApplication()); Assert.Contains(CoreStrings.FormatUnrecognizedKey("something"), exception.Message); }
public void Probe_HttpProber_HeadersMustBeSequence() { using var parser = new YamlParser(@" services: - name: sample liveness: http: headers: abc"); var exception = Assert.Throws <TyeYamlException>(() => parser.ParseConfigApplication()); Assert.Contains(CoreStrings.FormatExpectedYamlSequence("headers"), exception.Message); }
public void Probe_HttpProber_PortMustBeScalar() { using var parser = new YamlParser($@" services: - name: sample liveness: http: port: 3.5"); var exception = Assert.Throws <TyeYamlException>(() => parser.ParseConfigApplication()); Assert.Contains(CoreStrings.FormatMustBeAnInteger("port"), exception.Message); }
public void Ingress_Bindings_Port_MustBeInteger() { using var parser = new YamlParser( @"ingress: - name: ingress bindings: - port: abc protocol: http name: foo"); var exception = Assert.Throws <TyeYamlException>(() => parser.ParseConfigApplication()); Assert.Contains(CoreStrings.FormatMustBeAnInteger("port"), exception.Message); }
public void ServicesSetCorrectly() { var input = @" services: - name: appA project: ApplicationA/ApplicationA.csproj replicas: 2 tags: - A - B external: false image: abc build: false executable: test.exe workingDirectory: ApplicationA/ args: a b c env: - name: POSTGRES_PASSWORD value: ""test"" - name: POSTGRES_PASSWORD2 value: ""test2"" volumes: - name: volume source: /data target: /data bindings: - name: test port: 4444 connectionString: asdf containerPort: 80 host: localhost protocol: http routes: - /swagger - /graphql - name: appB project: ApplicationB/ApplicationB.csproj replicas: 2 tags: - tC - tD"; using var parser = new YamlParser(input); var actual = parser.ParseConfigApplication(); var expected = _deserializer.Deserialize <ConfigApplication>(new StringReader(input)); TyeAssert.Equal(expected, actual); }
public void Probe_HttpProber_Headers_UnrecognizedKey() { using var parser = new YamlParser(@" services: - name: sample liveness: http: headers: - name: header1 something: something"); var exception = Assert.Throws <TyeYamlException>(() => parser.ParseConfigApplication()); Assert.Contains(CoreStrings.FormatUnrecognizedKey("something"), exception.Message); }
public void NetworkTest() { var input = @" network: test-network"; using var parser = new YamlParser(input); var app = parser.ParseConfigApplication(); Assert.Equal("test-network", app.Network); var expected = _deserializer.Deserialize <ConfigApplication>(new StringReader(input)); Assert.Equal(expected.Network, app.Network); }
public void IngressProtocolsShouldBeHttpOrHttps() { var input = @" ingress: - name: ingress bindings: - port: 8080 protocol: tls name: a"; using var parser = new YamlParser(input); var app = parser.ParseConfigApplication(); var exception = Assert.Throws <TyeYamlException>(() => app.Validate()); Assert.Contains(CoreStrings.IngressBindingMustBeHttpOrHttps, exception.Message); }
public void ServicesMustHaveUniqueNonNullPorts() { var input = @" services: - name: app bindings: - protocol: http name: a - protocol: https name: b"; using var parser = new YamlParser(input); var app = parser.ParseConfigApplication(); app.Validate(); }
public void ExtensionsTest() { var input = @" extensions: - name: dapr"; using var parser = new YamlParser(input); var app = parser.ParseConfigApplication(); Assert.Equal("dapr", app.Extensions.Single()["name"]); var expected = _deserializer.Deserialize <ConfigApplication>(new StringReader(input)); Assert.Equal(expected.Extensions.Count, app.Extensions.Count); }
public void MultipleIngressBindingsMustHaveNames() { var input = @" ingress: - name: ingress bindings: - port: 8080 protocol: http - port: 8080 protocol: http"; using var parser = new YamlParser(input); var app = parser.ParseConfigApplication(); var exception = Assert.Throws <TyeYamlException>(() => app.Validate()); Assert.Contains(CoreStrings.FormatMultipleBindingWithoutName("ingress"), exception.Message); }
public void Services_Tags_SetCorrectly() { var input = @" services: - name: ingress tags: - tagA - with space - ""C.X"" "; using var parser = new YamlParser(input); var actual = parser.ParseConfigApplication(); var expected = _deserializer.Deserialize <ConfigApplication>(new StringReader(input)); TyeAssert.Equal(expected, actual); }
public void MultipleServicesBindingsMustUniqueNames() { var input = @" services: - name: app bindings: - port: 8080 protocol: http name: a - port: 8080 protocol: http name: a"; using var parser = new YamlParser(input); var app = parser.ParseConfigApplication(); var exception = Assert.Throws <TyeYamlException>(() => app.Validate()); Assert.Contains(CoreStrings.FormatMultipleBindingWithSameName("service"), exception.Message); }