ввел состояние пакета тестирования - выполнен с ошибками.

This commit is contained in:
2024-09-25 01:27:02 +03:00
parent bb671c5166
commit 679e46499e
12 changed files with 75 additions and 40 deletions

View File

@@ -30,12 +30,14 @@ public enum TasksPackageState implements StatusEnum {
//-
Done,
Aborted,
ConnectionError
ConnectionError,
DoneWithErrors
;
public boolean isActive() {
switch (this) {
case Inactive:
case Done:
case DoneWithErrors:
case Aborted:
case Draft:
case ConnectionError:
@@ -44,6 +46,16 @@ public enum TasksPackageState implements StatusEnum {
return true;
}
}
public boolean isDone() {
switch (this) {
case Done:
case DoneWithErrors:
return true;
default:
return false;
}
}
@Override
public VisualiserFonts getFont() {
switch (this) {
@@ -56,6 +68,8 @@ public enum TasksPackageState implements StatusEnum {
return VisualiserFonts.ProgressState;
case Done:
return VisualiserFonts.GoodState;
case DoneWithErrors:
return VisualiserFonts.BadState;
default:
return StatusEnum.super.getFont();
}
@@ -97,6 +111,8 @@ public enum TasksPackageState implements StatusEnum {
return "завершен";
case ConnectionError:
return "сбой связи";
case DoneWithErrors:
return "завершен с ошибками";
default:
return StatusEnum.super.getDescription();
}

View File

@@ -27,12 +27,13 @@ public abstract class TestingPlanner<P extends TestingPackage> extends Repositor
protected Machine machine = null;
protected User user = null;
//----
void UpdatePackageState(TasksPackageState state_in) throws Exception {
protected void UpdatePackageState(TasksPackageState state_in) throws Exception {
testingPackage.state = state_in;
testingPackage.ChangeDate = new Date().getTime();
ServerCommand(ServerCode.EditObject, testingPackage);
switch (testingPackage.state) {
case Done:
case DoneWithErrors:
case Aborted:
case CompilationExecution:
case RunningExecution:
@@ -61,7 +62,9 @@ public abstract class TestingPlanner<P extends TestingPackage> extends Repositor
}
protected abstract void TestsSynchronize() throws Exception;
protected abstract void PackageWorkspaceCreation() throws Exception;
protected abstract void AnalyseResults() throws Exception;
protected void AnalyseResults() throws Exception {
UpdatePackageState(TasksPackageState.Done);
};
protected abstract void PackageStart() throws Exception;
protected abstract boolean CheckNextState() throws Exception;
protected abstract void DownloadResults() throws Exception;
@@ -86,8 +89,7 @@ public abstract class TestingPlanner<P extends TestingPackage> extends Repositor
//--
InitSessionCredentials();
if (testingPackage.state.equals(TasksPackageState.Analysis)) {
AnalyseResults();
UpdatePackageState(TasksPackageState.Done);
AnalyseResults(); //todo ввести состояние DoneWithErrors
} else {
try {
if (Connect()) {

View File

@@ -7,6 +7,7 @@ import Common.Utils.Utils;
import GlobalData.Account.Account;
import ProjectData.LanguageName;
import Repository.Component.Sapfor.Sapfor;
import Repository.EmailMessage;
import Repository.RepositoryRefuseException;
import Repository.RepositoryServer;
import Repository.Server.ServerCode;
@@ -55,8 +56,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
+ "\nТест будет удален"
);
}
}
else if (object instanceof DVMPackage) {
} else if (object instanceof DVMPackage) {
DVMPackage dvmPackage = (DVMPackage) object;
//--
Utils.CheckAndCleanDirectory(dvmPackage.getLocalWorkspace());
@@ -64,8 +64,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
dvmPackage.saveJson();
dvmPackage.package_json = null; // объект больше не нужен.
//--
}
else if (object instanceof SapforPackage) {
} else if (object instanceof SapforPackage) {
((SapforPackage) object).init();
}
}
@@ -175,16 +174,13 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
TextLog Log = new TextLog();
tryAutoSapforTesting(Log);
response = new ServerExchangeUnit_2021(ServerCode.OK);
if (!Log.isEmpty()){
/*
Vector<String> targets = new Vector<>(Arrays.asList(Global.admins_mails));
if (!Log.isEmpty()) {
EmailMessage message = new EmailMessage(
"Выполнена сборка системы SAPFOR",
"Версия: " + version_s + "\n" + "Статус: " + status,
targets
);
Email(message);
*/
"Не удалось запустить автоматическое тестирование системы SAPFOR",
Log.toString(),
new Vector<>()
);
Email(message);
}
break;
case DownloadTest:
@@ -611,22 +607,22 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
void tryAutoSapforTesting(TextLog Log) throws Exception {
//--
Account account = new Account();
account.name= "server";
account.email= Constants.MailAddress;
account.name = "server";
account.email = Constants.MailAddress;
//-
int sapforId = Integer.parseInt(request.arg);
if (!db.serverSapfors.containsKey(sapforId)){
Log.Writeln_("Версия SAPFOR "+sapforId+" не существует.");
if (!db.serverSapfors.containsKey(sapforId)) {
Log.Writeln_("Версия SAPFOR " + sapforId + " не существует.");
return;
}
ServerSapfor sapfor = db.serverSapfors.get(sapforId);
if (!sapfor.state.equals(ServerSapforState.Done)){
Log.Writeln_("Выбранная версия SAPFOR "+sapforId+" не собрана!");
if (!sapfor.state.equals(ServerSapforState.Done)) {
Log.Writeln_("Выбранная версия SAPFOR " + sapforId + " не собрана!");
return;
}
Vector<SapforConfiguration> configurations= db.sapforConfigurations.getAutoConfigurations();
if (configurations.isEmpty()){
Log.Writeln_("Не найдено конфигурация для автоматического тестирования!");
Vector<SapforConfiguration> configurations = db.sapforConfigurations.getAutoConfigurations();
if (configurations.isEmpty()) {
Log.Writeln_("Не найдено конфигураций для автоматического тестирования!");
return;
}
SapforPackage target = new SapforPackage(account,
@@ -635,6 +631,10 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
1,
Log);
//-
if (target.tasksCount == 0) {
Log.Writeln_("Не сформировано ни одной новой задачи.");
return;
}
beforePublishAction(target);
db.InsertS(target);
afterPublishAction(target);

View File

@@ -80,6 +80,7 @@ public class TestsDatabase extends SQLiteDatabase {
case Aborted:
case Draft:
case ConnectionError:
case DoneWithErrors:
break;
default:
packages.add(p);
@@ -117,6 +118,7 @@ public class TestsDatabase extends SQLiteDatabase {
for (DVMPackage dvmPackage : dvmPackages.Data.values()) {
switch (dvmPackage.state) {
case Done:
case DoneWithErrors:
case Aborted:
case Draft:
case ConnectionError:
@@ -237,6 +239,7 @@ public class TestsDatabase extends SQLiteDatabase {
for (DVMPackage dvmPackage : dvmPackages.Data.values()) {
switch (dvmPackage.state) {
case Done:
case DoneWithErrors:
case Aborted:
case Draft:
case ConnectionError:

View File

@@ -155,6 +155,7 @@ public class RemoteDVMTestingPlanner extends DVMTestingPlanner {
testingPackage.progress = 100;
testingPackage.saveJson(); //запись обновленных результатов пакета в json!
Print("analysis done, ct_count=" + ct_count + " rt count=" + rt_count);
UpdatePackageState(TasksPackageState.Done);
}
@Override
protected void PackageStart() throws Exception {

View File

@@ -1,5 +1,6 @@
package TestingSystem.SAPFOR.Json;
import GlobalData.Tasks.TaskState;
import TestingSystem.Common.TasksPackageState;
import TestingSystem.SAPFOR.SapforPackage.SapforPackage;
import TestingSystem.SAPFOR.SapforTask.ComparisonState;
import TestingSystem.SAPFOR.SapforTask.SapforTask;
@@ -184,4 +185,10 @@ public class SapforPackage_json implements Serializable {
});
return names;
}
public TasksPackageState getState(){
for (SapforTask task: tasks)
if (!task.state.equals(TaskState.Done))
return TasksPackageState.DoneWithErrors;
return TasksPackageState.Done;
}
}

View File

@@ -146,6 +146,8 @@ public class SapforTestingPlanner extends TestingPlanner<SapforPackage> {
protected void AnalyseResults() throws Exception {
//не требуется.
testingPackage.progress = 100;
testingPackage.readJson();
UpdatePackageState(testingPackage.package_json.getState());
}
@Override
protected void Kill() throws Exception {

View File

@@ -25,6 +25,7 @@ public abstract class AbortTestingPackage extends TestingSystemPass<TestingPacka
switch (target.state) {
case Done:
case Aborted:
case DoneWithErrors:
Log.Writeln_("Пакет уже завершен.");
break;
case Inactive:

View File

@@ -19,7 +19,9 @@ public class DownloadDVMPackage extends DownloadDVMPackages {
//--
dvmPackage = Current.getDVMPackage();
//--
if (!dvmPackage.state.equals(TasksPackageState.Done)) {
if (!dvmPackage.state.isDone()
) {
Log.Writeln_("Возможно скачать и отобразить задачи только завершённого пакета!");
return false;
}

View File

@@ -23,7 +23,7 @@ public class DownloadSapforPackage extends Pass_2021<SapforPackage> {
@Override
protected boolean canStart(Object... args) throws Exception {
target = (SapforPackage) args[0];
if (!target.state.equals(TasksPackageState.Done)){
if (!target.state.isDone()){
Log.Writeln_("Возможно загрузить только завершенный пакет.");
return false;
}

View File

@@ -68,7 +68,8 @@ public class ExportDVMPackageToExcel extends Pass_2021<Vector<DVMPackage>> {
}
Vector<Integer> packagesToDownload = new Vector<>();
for (DVMPackage dvmPackage : target) {
if (!dvmPackage.state.equals(TasksPackageState.Done)) {
if (!dvmPackage.state.isDone())
{
Log.Writeln_("Пакет " + dvmPackage.id + " не завершен.");
} else {
if (!new File(dvmPackage.getLocalWorkspace(), Constants.LOADED).exists()){