public async Task <ApiResult> SaveFlow([FromBody] JObject config) { try { RolesCheck.EnsureWriter(Request, _isLocal); Ensure.NotNull(config, "config"); var inputJson = JsonConfig.From(config.ToString()); var result = await _flowOperation.SaveFlowConfig(FlowGuiConfig.From(inputJson)); Ensure.IsSuccessResult(result); if (result.Properties != null && result.Properties.TryGetValue(FlowOperation.FlowConfigPropertyName, out object flowConfig)) { return(ApiResult.CreateSuccess(JToken.FromObject(flowConfig))); } else { return(ApiResult.CreateSuccess(JToken.FromObject(string.Empty))); } } catch (Exception e) { _logger.LogError(e, e.Message); return(ApiResult.CreateError(e.Message)); } }
public async Task TestEndToEnd() { string flowName = "localconfiggentest"; // Point these two settings to your filesystem locations InitialConfiguration.Set(LocalSparkClient.ConfigSettingName_SparkHomeFolder, @"<LOCAL SPARK HOME FOLDER>"); InitialConfiguration.Set(Constants.ConfigSettingName_LocalRoot, @"<LOCAL ROOT>"); var input = await File.ReadAllTextAsync(@"Resource\guiInputLocal.json"); var inputJson = JsonConfig.From(input); var result = await this.FlowOperation.SaveFlowConfig(FlowGuiConfig.From(inputJson)); Assert.IsTrue(result.IsSuccess, result.Message); var result2 = await this.RuntimeConfigGeneration.GenerateRuntimeConfigs(flowName); var runtimeConfigFolderUri = result2.Properties?.GetValueOrDefault(PrepareJobConfigVariables.ResultPropertyName_RuntimeConfigFolder, null); _runtimeConfigFolder = new System.Uri(runtimeConfigFolderUri.ToString()).AbsolutePath; var jobResult1 = await JobOperation.StartJob(flowName); Assert.IsTrue(jobResult1.IsSuccess); // Wait for few seconds for the job to do some work System.Threading.Thread.Sleep(5000); var jobResult2 = await JobOperation.StopJob(flowName); Assert.IsTrue(jobResult2.IsSuccess); }
public void TestDeserializedFlowGuiConfig() { var jsonString = File.ReadAllText(@"Resource\guiInput.json"); var json = JsonConfig.From(jsonString); var instance = FlowGuiConfig.From(json); Assert.AreEqual(expected: "configgentest", actual: instance.Name); Assert.AreEqual(expected: "configgentest", actual: instance.DisplayName); Assert.AreEqual(expected: "iothub", actual: instance.Input.InputType); Assert.AreEqual(expected: "8000", actual: instance.Process.JobConfig.JobExecutorMemory); }
public async Task TestConfigSaved() { string flowName = "localconfiggentest"; var input = await File.ReadAllTextAsync(@"Resource\guiInput.json"); var inputJson = JsonConfig.From(input); var result = await this.FlowOperation.SaveFlowConfig(FlowGuiConfig.From(inputJson)); Assert.IsTrue(result.IsSuccess, result.Message); var actualJson = await this.FlowOperation.GetFlowByName(flowName); var expectedJson = FlowConfig.From(await File.ReadAllTextAsync(@"Resource\flowSaved.json")); foreach (var match in EntityConfig.Match(expectedJson, actualJson)) { Assert.AreEqual(expected: match.Item2, actual: match.Item3, message: $"path:{match.Item1}"); } }
public async Task TestConfigSaved() { await CommonData.Add(FlowDataManager.CommonDataName_DefaultFlowConfig, @"Resource\flowDefault.json"); var input = await File.ReadAllTextAsync(@"Resource\guiInput.json"); var inputJson = JsonConfig.From(input); var result = await this.FlowOperation.SaveFlowConfig(FlowGuiConfig.From(inputJson)); Assert.IsTrue(result.IsSuccess, result.Message); var actualJson = await this.FlowOperation.GetFlowByName("configgentest"); var expectedJson = FlowConfig.From(await File.ReadAllTextAsync(@"Resource\flowSaved.json")); foreach (var match in EntityConfig.Match(expectedJson, actualJson)) { Assert.AreEqual(expected: match.Item2, actual: match.Item3, message: $"path:{match.Item1}"); } Cleanup(); }