Esempio n. 1
0
        public void TestThatPropertiesAreParsed()
        {
            AppDeploymentConfig config = _deploymentConfig.GetApplicationConfig(new AppIdentity("app2", "1.0.0"));

            Assert.True(config.Properties.ContainsKey("NodeType"));
            Assert.Equal("PROD", config.Properties["NodeType"]);
        }
Esempio n. 2
0
        protected bool Equals(AppDeploymentConfig other)
        {
            bool res = Equals(AppIdentity, other.AppIdentity) &&
                       Properties.SequenceEqual(other.Properties);

            return(res);
        }
Esempio n. 3
0
        public void TestSetApplicationConfig()
        {
            AppIdentity         appIdentity = new AppIdentity("newApp", "1.0.0");
            AppDeploymentConfig config      = new AppDeploymentConfig(appIdentity, new [] { "clusterId1" });

            config = config.AddProperty("Foo", "Bar");
            var deploymentConfig = _deploymentConfig.SetApplicationConfig(config);

            Assert.Equal("Bar", deploymentConfig.GetApplicationConfig(appIdentity).Properties["Foo"]);
        }
        string GetBinariesPath(AppDeploymentConfig app)
        {
            if (app.Properties.TryGetValue(LocalExePath, out var exePath))
            {
                return(exePath);
            }

            else
            {
                throw new BinariesNotFoundException($"{app.AppIdentity.Id} needs an '{LocalExePath}' property");
            }
        }
Esempio n. 5
0
 public bool IsMatch(AppDeploymentConfig appDeploymentConfig)
 {
     foreach (var kvp in _matchProperties)
     {
         string value;
         if (appDeploymentConfig.Properties.TryGetValue(kvp.Key, out value))
         {
             if (value != kvp.Value)
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Esempio n. 6
0
        public void TestThatSetApplicationConfigOverwritesExisting()
        {
            AppIdentity         appIdentity = new AppIdentity("app1", "1.0.0");
            AppDeploymentConfig config      = _deploymentConfig.GetApplicationConfig(appIdentity);

            config = config.AddProperty("key1", "value1");
            var deploymentConfig = _deploymentConfig.SetApplicationConfig(config);

            Assert.Equal("value1", deploymentConfig.GetApplicationConfig(appIdentity).Properties["key1"]);

            config           = config.AddProperty("key2", "value2");
            deploymentConfig = deploymentConfig.SetApplicationConfig(config);
            Assert.Equal("value1", deploymentConfig.GetApplicationConfig(appIdentity).Properties["key1"]);
            Assert.Equal("value2", deploymentConfig.GetApplicationConfig(appIdentity).Properties["key2"]);
        }
Esempio n. 7
0
        public async Task TestParseApplicationConfig()
        {
            string       path       = Path.Combine(Directory.GetCurrentDirectory(), "Data\\ApplicationConfigParser\\AppConfig.json");
            const string clusterId  = "clusterid1";
            const string instanceId = "instanceid1";

            AppIdentity identity = new AppIdentity("HelloApp", new SemVersion(1, 0, 0));
            Dictionary <string, string> properties = new Dictionary <string, string> {
                ["NodeType"] = "PROD"
            };
            AppDeploymentConfig appDeploymentConfig = new AppDeploymentConfig(identity, new [] { clusterId }, properties);
            ApplicationConfig   appConfig           = await new ApplicationConfigParser(new ApplicationConfigSymbolResolver(clusterId, instanceId),
                                                                                        new JsonSerializer(new DiagnosticsTraceWriter())).ParseFile(path, appDeploymentConfig);

            Assert.Equal(identity, appConfig.Identity);
            Assert.Equal("HelloApp.exe", appConfig.ExeName);
            Assert.Equal("HelloApp_1.0_instanceid1 foo bar=HelloApp_1.0_clusterid1 nodeType=PROD", appConfig.ExeArgs);
        }
Esempio n. 8
0
 public bool IsMatch(AppDeploymentConfig appDeploymentConfig)
 {
     return(_matchers.All(matcher => matcher.IsMatch(appDeploymentConfig)));
 }
Esempio n. 9
0
 public bool IsMatch(AppDeploymentConfig appDeploymentConfig)
 {
     return(appDeploymentConfig.TargetClusters.Contains(_clusterId));
 }