Skip to content

Commit

Permalink
Merge pull request #1 from garcanam/fix
Browse files Browse the repository at this point in the history
  • Loading branch information
garcanam authored Nov 22, 2022
2 parents 06e4cd6 + 8b44026 commit c396c5d
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 146 deletions.
50 changes: 29 additions & 21 deletions server/CIService/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="CIService.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Tricentis.TCCore.BusinessObjects.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
Expand All @@ -12,33 +13,35 @@
<appSettings>
<add key="listenPort" value="8080" />
<add key="maxSubsetSize" value="1368709120" />
<add key="ffmpegArgs" value="-f gdigrab -framerate 15 -i desktop -c:v libx264 -pix_fmt yuv420p -vprofile high -level 4.0 -preset slow -b 300k -y"/>
<add key="ffmpegArgs" value="-f gdigrab -framerate 15 -i desktop -c:v libx264 -pix_fmt yuv420p -vprofile high -level 4.0 -preset slow -b 300k -y" />
<add key="SQLServer" value="localhost" />
<add key="SQLSchema" value="SQLEXPRESS" />
<add key="SQLServerUsername" value="" />
<add key="SQLServerUsername" value="" />
<add key="SQLServerPassword" value="" />
<add key="ClientSettingsProvider.ServiceUri" value="" />
</appSettings>
<log4net>
<appender name="ConsoleAppender" type="log4net.Appender.ColoredConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date| %level | %message%newline" />
</layout>
</appender>
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
<file value="CIService.log" />
<appendToFile value="true" />
<rollingStyle value="Date" />
<datePattern value="yyyyMMdd-HHmm" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %level %message%newline" />
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="ConsoleAppender" />
<appender-ref ref="RollingFile" />
</root>
<root>
<level value="ALL" />
<appender-ref ref="ConsoleAppender" />
<appender-ref ref="RollingFile" />
</root>
<appender name="ConsoleAppender" type="log4net.Appender.ColoredConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date| %level | %message%newline" />
</layout>
</appender>
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
<file value="CIService.log" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="20" />
<maximumFileSize value="200KB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>
</appender>
</log4net>
<system.web>
<membership defaultProvider="ClientAuthenticationMembershipProvider">
Expand All @@ -58,5 +61,10 @@
<value>settingval</value>
</setting>
</CIService.Properties.Settings>
<Tricentis.TCCore.BusinessObjects.Properties.Settings>
<setting name="ShowAllFoldersInExecutionLogs" serializeAs="String">
<value>True</value>
</setting>
</Tricentis.TCCore.BusinessObjects.Properties.Settings>
</userSettings>
</configuration>
12 changes: 0 additions & 12 deletions server/CIService/Contract/ExecutionTracking.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ public class ExecutionTracking
public string workspaceID { get; set; }
public string workspaceDirectory { get; set; }

internal Thread thread { get; set; }

internal Boolean cancel { get; set; } = false;
public List<TestSuiteExecution> executions { get; set; }

Expand All @@ -35,16 +33,6 @@ public class ExecutionTracking
public ExecutionStatus status { get; set; }
public Exception error { get; set; }

public void Cancel()
{
cancel = true;
foreach(var execution in executions)
{
execution.Cancel();
}
thread.Join();
}

public ExecutionTracking(string id, ExecutionRequest request)
{
this.id = id;
Expand Down
4 changes: 3 additions & 1 deletion server/CIService/Contract/TestSuiteExecution.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ namespace CIService.Contract
{
public class TestSuiteExecution
{
public string executionListName { get; set; }
public string executionListName{ get; set; }

public string executionListNameWithoutSpaces { get; set; }

public string executionPath { get; set; }

Expand Down
3 changes: 1 addition & 2 deletions server/CIService/Controllers/ExecutionController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using CIService.Contract;
using CIService.Enum;
using CIService.Service;
using log4net;
using log4net;
using Newtonsoft.Json;

// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
Expand All @@ -31,7 +31,6 @@ public HttpResponseMessage CancelExecution(string id)
{
return CreateErrorResponseMessage(HttpStatusCode.NotFound, $"The execution \"{id}\" was not found on the machine!");
}
executionTrack.Cancel();
return new HttpResponseMessage()
{
StatusCode = HttpStatusCode.OK
Expand Down
18 changes: 9 additions & 9 deletions server/CIService/Controllers/ExecutionListController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
using CIService.Service;
using CIService.Tosca;
using CIService.Helper;
using log4net;

using log4net;

namespace CIService.Controllers
{
[RoutePrefix("api/v2/execution")]
public class ExecutionListController : ApiController
{
{
private static readonly ILog log = LogManager.GetLogger(typeof(ExecutionListController));

[HttpPost]
Expand All @@ -29,8 +29,8 @@ public HttpResponseMessage CreateExecution([FromBody] ExecutionRequest request)
{
log.InfoFormat("Request Test Execution on workspace session {0}", request.sessionID);
List<ExecutionTracking> runningExecutions = ExecutionTrackerService.HaveExecutionRunning();
if (runningExecutions.Count()>0)
{
if (runningExecutions != null && runningExecutions.Count()>0)
{
log.WarnFormat("Execution Request on workspace {0} can not be placed because an execution is already running ", request.sessionID);
return CreateErrorResponseMessage(HttpStatusCode.Conflict,$"Could not create a new execution since the following execution(s) are still running: {String.Join(",",runningExecutions.Select(x => x.status.ToString()))}");
}
Expand All @@ -40,7 +40,7 @@ public HttpResponseMessage CreateExecution([FromBody] ExecutionRequest request)
{
//Check Execution Lists exists and are not empty
var executionLists = session.SearchForExecutionList(request.ExecutionFilter);
if (executionLists.Count() == 0)
if (executionLists == null || !executionLists.Any())
{
log.WarnFormat("No execution Lists founds, criteria {0}", request.ExecutionFilter);
return CreateErrorResponseMessage(HttpStatusCode.BadRequest, "NO execution Lists found");
Expand All @@ -50,10 +50,10 @@ public HttpResponseMessage CreateExecution([FromBody] ExecutionRequest request)
var resExecutionList = new ExecutionList();
resExecutionList.name = executionList.DisplayedName;
var executionEntries = executionList.Search($"=>SUBPARTS:ExecutionEntry");
if (executionEntries.Count() == 0)
if (executionEntries == null || !executionEntries.Any())
{
log.WarnFormat("execution List {0} no Test Cases found", executionList);
return CreateErrorResponseMessage(HttpStatusCode.BadRequest, String.Format("Execution List {0} is empty", executionList.DisplayedName));
log.WarnFormat("Execution List {0} no Test Cases found", executionList);
return CreateErrorResponseMessage(HttpStatusCode.BadRequest, string.Format("Execution List {0} is empty", executionList.DisplayedName));
}
resExecutionList.entries = executionEntries.Select(t => t.DisplayedName).ToList();
responseExecutionList.Add(resExecutionList);
Expand Down
46 changes: 27 additions & 19 deletions server/CIService/Controllers/WorkspaceController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public class WorkspaceController : ApiController
createProject.templateConnectionString = provider.FormData.Get("templateConnectionString");
createProject.templateConnectionWorkspaceUsername = provider.FormData.Get("templateConnectionWorkspaceUsername");
createProject.templateConnectionWorkspacePassword = provider.FormData.Get("templateConnectionWorkspacePassword");




createProject.dbType = EnumHelper.getDBTypeFromString(provider.FormData.Get("dbType"));
createProject.connectionString = provider.FormData.Get("connectionString");

Expand All @@ -65,11 +65,19 @@ public class WorkspaceController : ApiController
foreach (MultipartFileData file in provider.FileData)
{
var cleanFileName = file.Headers.ContentDisposition.FileName.Replace("\"", "");
if (cleanFileName == "") { continue; }
if(!cleanFileName.EndsWith(".tsu") && !cleanFileName.EndsWith(".tpr")) {
return CreateErrorResponseMessage("Only Subset(.tsu) or Project Definition(.tpr) import files are allowed.", HttpStatusCode.BadRequest);
if (cleanFileName == "")
{
continue;
}

if (!cleanFileName.EndsWith(".tsu") && !cleanFileName.EndsWith(".tpr"))
{
return CreateErrorResponseMessage(
"Only Subset(.tsu) or Project Definition(.tpr) import files are allowed.",
HttpStatusCode.BadRequest);
}
var destPath = Path.Combine(Path.GetDirectoryName(file.LocalFileName), cleanFileName);

var destPath = Path.Combine(Path.GetDirectoryName(file.LocalFileName), cleanFileName);
if (cleanFileName.EndsWith(".tsu"))
{
subsetFiles.Add(destPath);
Expand Down Expand Up @@ -108,23 +116,23 @@ public HttpResponseMessage DeleteWorkspace(string workspaceID)
{
log.InfoFormat("Deleting workspace {0}", workspaceID);
List<ExecutionTracking> runningExecution = ExecutionTrackerService.HaveExecutionRunning(workspaceID);
if (runningExecution.Count() > 0)
if (runningExecution != null && runningExecution.Any())
{
return CreateErrorResponseMessage("Can not be deleted because running executions", HttpStatusCode.Conflict);
}
try {
try {
List<ExecutionTracking> executions = ExecutionTrackerService.GetExecutionsByWorkspace(workspaceID);
foreach (ExecutionTracking execution in executions)
{
if (!execution.request.PreserveWorkspaces)
{
log.InfoFormat("Deleting workspace directory {0}", execution.workspaceDirectory);
//WorkspaceService.DeleteWorkspace(workspaceID);
}
else
{
log.InfoFormat("Preserving workspace directory {0}", execution.workspaceDirectory);
}
foreach (ExecutionTracking execution in executions)
{
if (!execution.request.PreserveWorkspaces)
{
log.InfoFormat("Deleting workspace directory {0}", execution.workspaceDirectory);
//WorkspaceService.DeleteWorkspace(workspaceID);
}
else
{
log.InfoFormat("Preserving workspace directory {0}", execution.workspaceDirectory);
}
}

ExecutionTrackerService.CleanExecutionsByWorkspace(workspaceID);
Expand Down
Loading

0 comments on commit c396c5d

Please sign in to comment.