Revert "упорядочил папки с кодом."

This reverts commit 44c6daffa3.
This commit is contained in:
2023-11-19 02:12:44 +03:00
parent 44c6daffa3
commit 28908bcfac
596 changed files with 1569 additions and 2140 deletions

View File

@@ -0,0 +1,116 @@
package TestingSystem.Common.Group;
import Common.Current;
import Common.Database.DBObject;
import Common.Database.riDBObject;
import Common.Global;
import Common.UI.UI;
import Common.Utils.Utils;
import ProjectData.Files.DBProjectFile;
import ProjectData.LanguageName;
import ProjectData.Project.db_project_info;
import TestingSystem.Common.Test.TestType;
import com.sun.org.glassfish.gmbal.Description;
import java.util.LinkedHashMap;
import java.util.Vector;
public class Group extends riDBObject {
@Description("DEFAULT 'Default'")
public TestType type = TestType.Default;
@Description("DEFAULT 'fortran'")
public LanguageName language = LanguageName.fortran;
//--
@Override
public boolean isVisible() {
return (!GroupsDBTable.filterMyOnly || Current.getAccount().email.equals(sender_address)) &&
Global.testingServer.db.groups.applyFilters(this);
}
public String getSummary() {
return description + " " + language.getDescription();
}
//-
@Override
public void SynchronizeFields(DBObject src) {
super.SynchronizeFields(src);
Group g = (Group) src;
type = g.type;
language = g.language;
}
public Group(Group group) {
this.SynchronizeFields(group);
}
public Group() {
}
@Override
public void select(boolean flag) {
super.select(flag);
if (Current.hasUI())
UI.getMainWindow().ShowCheckedTestsCount();
}
//--
//-
public static void generateForLanguage(
String dvm_drv,
LinkedHashMap<LanguageName, Vector<DBProjectFile>> programs,
LanguageName language,
Vector<String> titles,
Vector<String> objects,
Vector<String> bodies,
String flags_in
) {
if (!programs.get(language).isEmpty()) {
String LANG_ = language.toString().toUpperCase() + "_";
Vector<String> module_objects = new Vector<>();
String module_body = "";
int i = 1;
for (DBProjectFile program : programs.get(language)) {
//--
program.last_assembly_name = language + "_" + i + ".o";
String object = Utils.DQuotes(program.last_assembly_name);
module_objects.add(object);
module_body +=
object + ":\n" +
"\t" +
String.join(" ",
Utils.MFVar(LANG_ + "COMMAND"),
Utils.MFVar(LANG_ + "FLAGS"),
program.getStyleOptions(),
"-c",
program.getQSourceName(),
"-o",
object + "\n\n"
);
++i;
}
titles.add(String.join("\n",
LANG_ + "COMMAND=" + Utils.DQuotes(dvm_drv) + " " +
language.getDVMCompile(),
LANG_ + "FLAGS=" + flags_in,
LANG_ + "OBJECTS=" + String.join(" ", module_objects),
""
));
objects.add(Utils.MFVar(LANG_ + "OBJECTS"));
bodies.add(module_body);
}
}
public String GenerateMakefile(db_project_info project, String dvm_drv, String flags_in) {
//----->>
LinkedHashMap<LanguageName, Vector<DBProjectFile>> programs = project.getPrograms();
Vector<String> titles = new Vector<>();
Vector<String> objects = new Vector<>();
Vector<String> bodies = new Vector<>();
String binary = Utils.DQuotes("0");
//----->>
generateForLanguage(dvm_drv, programs, language, titles, objects, bodies, flags_in);
//----->>
return String.join("\n",
"LINK_COMMAND=" + Utils.DQuotes(dvm_drv) + " " +
language.getDVMLink(),
"LINK_FLAGS=" + flags_in + "\n",
String.join("\n", titles),
"all: " + binary,
binary + " : " + String.join(" ", objects),
"\t" + Utils.MFVar("LINK_COMMAND") + " " + Utils.MFVar("LINK_FLAGS") + " " + String.join(" ", objects) + " -o " + binary,
String.join(" ", bodies));
}
}

View File

@@ -0,0 +1,186 @@
package TestingSystem.Common.Group;
import Common.Current;
import Common.Database.*;
import Common.UI.DataSetControlForm;
import Common.UI.Menus_2023.GroupsMenuBar.GroupsMenuBar;
import Common.UI.Menus_2023.VisualiserMenu;
import Common.UI.UI;
import Common.UI.Windows.Dialog.DBObjectDialog;
import ProjectData.LanguageName;
import TestingSystem.Common.Group.UI.GroupFields;
import TestingSystem.Common.Test.Test;
import TestingSystem.Common.Test.TestType;
import javax.swing.*;
import java.util.LinkedHashMap;
import java.util.Vector;
//-
public class GroupsDBTable extends iDBTable<Group> {
public static boolean filterMyOnly = false;
public Vector<TableFilter<Group>> typeFilters;
public Vector<TableFilter<Group>> languageFilters;
//------------------------------------------------>>>
public GroupsDBTable() {
super(Group.class);
if (Current.hasUI()) {
//--
typeFilters = new Vector<>();
languageFilters = new Vector<>();
//--
for (TestType type : TestType.values()) {
typeFilters.add(
new TableFilter<Group>(this, type.getDescription()) {
@Override
protected boolean validate(Group object) {
return object.type.equals(type);
}
});
}
//--
for (LanguageName languageName : LanguageName.values()) {
languageFilters.add(new TableFilter<Group>(this, languageName.getDescription()) {
@Override
protected boolean validate(Group object) {
return object.language.equals(languageName);
}
});
}
}
}
@Override
public void mountUI(JPanel content_in) {
super.mountUI(content_in);
//---
GroupsMenuBar menuBar = (GroupsMenuBar) UI.menuBars.get(getClass());
menuBar.DropFilters();
//----
menuBar.addFilters(
new VisualiserMenu("Тип", "/icons/Filter.png", true) {
{
for (TableFilter filter : typeFilters)
add(filter.menuItem);
}
},
new VisualiserMenu("Язык", "/icons/Filter.png", true) {
{
for (TableFilter filter : languageFilters)
add(filter.menuItem);
}
}
);
}
public void ResetFiltersCount() {
for (TableFilter filter : typeFilters)
filter.count = 0;
for (TableFilter filter : languageFilters)
filter.count = 0;
}
public void ShowFiltersCount() {
for (TableFilter filter : typeFilters)
filter.ShowDescriptionAndCount();
for (TableFilter filter : languageFilters)
filter.ShowDescriptionAndCount();
}
public boolean applyFilters(Group object) {
for (TableFilter filter : typeFilters)
if (!filter.Validate(object)) return false;
for (TableFilter filter : languageFilters)
if (!filter.Validate(object)) return false;
return true;
}
@Override
public void ShowUI() {
ResetFiltersCount();
super.ShowUI();
ShowFiltersCount();
}
@Override
public void ShowUI(Object key) {
ResetFiltersCount();
super.ShowUI(key);
ShowFiltersCount();
}
@Override
public String getSingleDescription() {
return "группа тестов";
}
@Override
public String getPluralDescription() {
return "группы";
}
@Override
public LinkedHashMap<Class<? extends DBObject>, FKBehaviour> getFKDependencies() {
LinkedHashMap<Class<? extends DBObject>, FKBehaviour> res = new LinkedHashMap<>();
res.put(Test.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
return res;
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this) {
@Override
public boolean hasCheckBox() {
return true;
}
@Override
protected void AdditionalInitColumns() {
//columns.get(0).setVisible(false);
}
};
}
@Override
public String[] getUIColumnNames() {
return new String[]{
"имя",
"автор",
"тип",
"язык"
};
}
@Override
public Object getFieldAt(Group object, int columnIndex) {
switch (columnIndex) {
case 2:
return object.description;
case 3:
return object.sender_name;
case 4:
return object.type.getDescription();
case 5:
return object.language.getDescription();
default:
return null;
}
}
@Override
public Current CurrentName() {
return Current.Group;
}
@Override
public DBObjectDialog<Group, GroupFields> getDialog() {
return new DBObjectDialog<Group, GroupFields>(GroupFields.class) {
@Override
public int getDefaultHeight() {
return 250;
}
@Override
public int getDefaultWidth() {
return 400;
}
@Override
public void validateFields() {
}
@Override
public void fillFields() {
fields.tfName.setText(Result.description);
UI.TrySelect(fields.cbType, Result.type);
UI.TrySelect(fields.cbLanguage, Result.language);
}
@Override
public void ProcessResult() {
Result.description = fields.tfName.getText();
Result.type = (TestType) fields.cbType.getSelectedItem();
Result.language = (LanguageName) fields.cbLanguage.getSelectedItem();
}
};
}
}

View File

@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="TestingSystem.Common.Group.UI.GroupFields">
<grid id="27dc6" binding="content" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="385" height="181"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="a979" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="d80" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="название"/>
</properties>
</component>
<component id="f2392" class="javax.swing.JTextField" binding="tfName" custom-create="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<minimum-size width="200" height="30"/>
<preferred-size width="238" height="30"/>
<maximum-size width="200" height="30"/>
</grid>
</constraints>
<properties/>
</component>
<component id="c5591" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="тип"/>
</properties>
</component>
<component id="a5bbe" class="javax.swing.JComboBox" binding="cbType" custom-create="true">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false">
<minimum-size width="200" height="30"/>
<preferred-size width="238" height="30"/>
<maximum-size width="200" height="30"/>
</grid>
</constraints>
<properties/>
</component>
<component id="8a5e9" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="язык сборки"/>
</properties>
</component>
<component id="c8d4e" class="javax.swing.JComboBox" binding="cbLanguage" custom-create="true">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false">
<minimum-size width="200" height="30"/>
<preferred-size width="238" height="30"/>
<maximum-size width="200" height="30"/>
</grid>
</constraints>
<properties/>
</component>
</children>
</grid>
</children>
</grid>
</form>

View File

@@ -0,0 +1,32 @@
package TestingSystem.Common.Group.UI;
import Common.UI.TextField.StyledTextField;
import Common.UI.Windows.Dialog.DialogFields;
import ProjectData.LanguageName;
import TestingSystem.Common.Test.TestType;
import javax.swing.*;
import java.awt.*;
public class GroupFields implements DialogFields {
public JPanel content;
public JTextField tfName;
public JComboBox<TestType> cbType;
public JComboBox<LanguageName> cbLanguage;
@Override
public Component getContent() {
return content;
}
private void createUIComponents() {
// TODO: place custom component creation code here
tfName = new StyledTextField();
//-
cbType = new JComboBox<>();
cbType.addItem(TestType.Default);
cbType.addItem(TestType.Performance);
cbType.addItem(TestType.Correctness);
cbType.addItem(TestType.SAPFOR);
//-
cbLanguage = new JComboBox<>();
cbLanguage.addItem(LanguageName.fortran);
cbLanguage.addItem(LanguageName.c);
}
}

View File

@@ -0,0 +1,35 @@
package TestingSystem.Common.TSetting;
import Common.Database.DBObject;
import GlobalData.Settings.SettingName;
import com.sun.org.glassfish.gmbal.Description;
public class TSetting extends DBObject {
@Description("PRIMARY KEY,UNIQUE")
public SettingName Name;
public long value;
@Override
public Object getPK() {
return Name;
}
public TSetting(SettingName name_in, long value_in) {
Name = name_in;
value = value_in;
}
public TSetting(SettingName name_in, boolean value_in) {
this(name_in, value_in ? 1 : 0);
}
public TSetting() {
}
@Override
public void SynchronizeFields(DBObject src) {
super.SynchronizeFields(src);
TSetting t = (TSetting) src;
Name = t.Name;
value = t.value;
}
public TSetting(TSetting src) {
this.SynchronizeFields(src);
}
public boolean toBoolean(){
return value==1;
}
}

View File

@@ -0,0 +1,7 @@
package TestingSystem.Common.TSetting;
import Common.Database.DBTable;
public class TSettingsDBTable extends DBTable<String, TSetting> {
public TSettingsDBTable() {
super(String.class, TSetting.class);
}
}

View File

@@ -0,0 +1,22 @@
package TestingSystem.Common;
import TestingSystem.SAPFOR.Json.SapforConfiguration_json;
import TestingSystem.SAPFOR.PerformSapforTask;
import TestingSystem.SAPFOR.SapforTask.SapforTask;
import java.io.File;
public class TaskThread extends Thread {
public SapforTask task = null;
public TaskThread(SapforTask task_, File sapfor_drv, SapforConfiguration_json sapforConfiguration_json) {
super(() -> {
while (!task_.state.isComplete()) {
task_.Reset();
new PerformSapforTask().Do(
sapfor_drv,
sapforConfiguration_json,
task_
);
}
});
task = task_;
}
}

View File

@@ -0,0 +1,210 @@
package TestingSystem.Common;
import Common.Constants;
import Common.Database.SQLITE.SQLiteDatabase;
import Common.Global;
import GlobalData.Settings.SettingName;
import TestingSystem.SAPFOR.SapforTask.SapforTasksDBTable;
import TestingSystem.SAPFOR.SapforTasksPackage.SapforTasksPackage;
import TestingSystem.SAPFOR.SapforTasksPackage.SapforTasksPackagesDBTable;
import TestingSystem.Common.TSetting.TSetting;
import TestingSystem.Common.TSetting.TSettingsDBTable;
import TestingSystem.DVM.Tasks.TestCompilationTask;
import TestingSystem.DVM.Tasks.TestCompilationTasksDBTable;
import TestingSystem.DVM.Tasks.TestRunTask;
import TestingSystem.DVM.Tasks.TestRunTasksDBTable;
import TestingSystem.DVM.TasksPackage.TasksPackage;
import TestingSystem.DVM.TasksPackage.TasksPackageDBTable;
import TestingSystem.DVM.TasksPackage.TasksPackageState;
import TestingSystem.Common.TasksPackageToKill.TasksPackageToKillDBTable;
import Visual_DVM_2021.Passes.PassCode_2021;
import javafx.util.Pair;
import java.io.File;
import java.nio.file.Paths;
import java.sql.PreparedStatement;
import java.util.LinkedHashMap;
import java.util.Vector;
public class TasksDatabase extends SQLiteDatabase {
public TSettingsDBTable settings;
public TasksPackageDBTable packages;
public TasksPackageToKillDBTable packagesToKill;
public TestCompilationTasksDBTable testCompilationTasks;
public TestRunTasksDBTable testRunTasks;
PreparedStatement selectPackageRunTasks = null;
//----------
public SapforTasksPackagesDBTable sapforTasksPackages;
public SapforTasksDBTable sapforTasks;
//---------
public TasksDatabase(String email) {
super(Paths.get(Global.DataDirectory.getAbsolutePath(), email + "_" + Constants.tests_db_name + ".sqlite").toFile());
}
public TasksDatabase(File file_in) {
super(file_in);
}
public void setFile(String email) {
file = Paths.get(Global.DataDirectory.getAbsolutePath(), email + "_" + Constants.tests_db_name + ".sqlite").toFile();
}
@Override
protected void initAllTables() throws Exception {
addTable(settings = new TSettingsDBTable());
addTable(packages = new TasksPackageDBTable());
addTable(testCompilationTasks = new TestCompilationTasksDBTable());
addTable(testRunTasks = new TestRunTasksDBTable());
addTable(packagesToKill = new TasksPackageToKillDBTable());
//-----------
addTable(sapforTasksPackages = new SapforTasksPackagesDBTable());
addTable(sapforTasks = new SapforTasksDBTable());
}
@Override
public void Init() throws Exception {
if (!settings.containsKey(SettingName.Email))
Insert(new TSetting(SettingName.Email, 0));
if (!settings.containsKey(SettingName.Pause))
Insert(new TSetting(SettingName.Pause, 0));
if (!settings.containsKey(SettingName.Queue))
Insert(new TSetting(SettingName.Queue, 0));
}
@Override
public PassCode_2021 getSynchronizePassCode() {
return PassCode_2021.SynchronizeTestsTasks;
}
@Override
public void prepareTablesStatements() throws Exception {
super.prepareTablesStatements();
selectPackageRunTasks = conn.prepareStatement("SELECT * FROM TestRunTask WHERE taskspackage_id = ?");
}
@Override
protected void disconnect() throws Exception {
if (selectPackageRunTasks != null) {
selectPackageRunTasks.close();
selectPackageRunTasks = null;
}
super.disconnect();
}
public LinkedHashMap<Long, TestRunTask> getPackageRunTasks(String package_id) throws Exception {
LinkedHashMap<Long, TestRunTask> res = new LinkedHashMap<>();
selectPackageRunTasks.setString(1, package_id);
resSet = selectPackageRunTasks.executeQuery();
while (resSet.next()) {
Pair<Long, TestRunTask> record = readRecord(testRunTasks);
res.put(record.getKey(), record.getValue());
}
return res;
}
//------
public TasksPackage getFirstActivePackage() {
TasksPackage first_active = null;
TasksPackage first_queued = null;
if (!packages.Data.isEmpty()) {
for (TasksPackage p : packages.Data.values()) {
switch (p.state) {
case Done:
case Aborted:
break;
case Queued:
if (first_queued == null) first_queued = p;
break;
default:
if (first_active == null) first_active = p; //это и будет первый активный.
break;
}
}
if (first_active != null) return first_active;
if (first_queued != null) {
first_queued.state = TasksPackageState.TestsSynchronize;
try {
Update(first_queued);
} catch (Exception ex) {
ex.printStackTrace();
}
}
return first_queued;
}
return null;
}
public LinkedHashMap<Long, TestCompilationTask> getPackageCompilationTasks(TasksPackage tasksPackage) {
if (tasksPackage == null) return null;
LinkedHashMap<Long, TestCompilationTask> res = new LinkedHashMap<>();
for (TestCompilationTask srcCompilationTask : testCompilationTasks.Data.values()) {
if (srcCompilationTask.taskspackage_id.equals(tasksPackage.id)) {
TestCompilationTask dstCompilationTask = new TestCompilationTask(srcCompilationTask);
dstCompilationTask.runTasks = new Vector<>();
for (TestRunTask testRunTask : testRunTasks.Data.values())
if (testRunTask.testcompilationtask_id == srcCompilationTask.id)
dstCompilationTask.runTasks.add(new TestRunTask(testRunTask));
res.put(dstCompilationTask.id, dstCompilationTask);
}
}
return res;
}
public long getQueueSize(long date) throws Exception {
long sum = 0L;
for (TasksPackage tasksPackage : packages.Data.values()) {
if (tasksPackage.StartDate < date) {
Vector<TestRunTask> tasks = new Vector<>(getPackageRunTasks(tasksPackage.id).values());
for (TestRunTask testRunTask : tasks)
if (testRunTask.compilation_state.isActive() || testRunTask.state.isActive())
sum++;
}
}
return sum;
}
//--
/*
public Vector<TasksPackage> getActivePackages() {
Vector<TasksPackage> res = new Vector<>();
for (TasksPackage p : packages.Data.values())
if (!p.state.equals(TasksPackageState.Done))
res.add(p);
return res;
}
public Vector<SapforTasksPackage> getActiveSapforPackages() {
Vector<SapforTasksPackage> res = new Vector<>();
for (SapforTasksPackage p : sapforTasksPackages.Data.values())
if (!p.state.equals(TasksPackageState.Done))
res.add(p);
return res;
}
*/
public SapforTasksPackage getFirstActiveSapforPackage() {
SapforTasksPackage first_active = null;
SapforTasksPackage first_queued = null;
if (!sapforTasksPackages.Data.isEmpty()) {
for (SapforTasksPackage p : sapforTasksPackages.Data.values()) {
switch (p.state) {
case Done:
case Aborted:
break;
case Queued:
if (first_queued == null) first_queued = p;
break;
default:
if (first_active == null) first_active = p; //это и будет первый активный.
break;
}
}
if (first_active != null) return first_active;
if (first_queued != null) {
first_queued.state = TasksPackageState.TestsSynchronize;
try {
Update(first_queued);
} catch (Exception ex) {
ex.printStackTrace();
}
}
return first_queued;
}
return null;
}
public boolean hasActivePackages() {
for (TasksPackage tasksPackage : packages.Data.values()) {
if (tasksPackage.state.isActive())
return true;
}
for (SapforTasksPackage sapforTasksPackage : sapforTasksPackages.Data.values()) {
if (sapforTasksPackage.state.isActive())
return true;
}
return false;
}
}

View File

@@ -0,0 +1,5 @@
package TestingSystem.Common.TasksPackageToKill;
import Common.Database.iDBObject;
public class TasksPackageToKill extends iDBObject {
public String packageName = "";
}

View File

@@ -0,0 +1,7 @@
package TestingSystem.Common.TasksPackageToKill;
import Common.Database.iDBTable;
public class TasksPackageToKillDBTable extends iDBTable<TasksPackageToKill> {
public TasksPackageToKillDBTable() {
super(TasksPackageToKill.class);
}
}

View File

@@ -0,0 +1,10 @@
package TestingSystem.Common.Test;
import ProjectData.Files.DBProjectFile;
import com.google.gson.annotations.Expose;
import java.util.List;
import java.util.Vector;
public class ProjectFiles_json {
@Expose
public List<DBProjectFile> files = new Vector<>();
}

View File

@@ -0,0 +1,53 @@
package TestingSystem.Common.Test;
import Common.Constants;
import Common.Current;
import Common.Database.DBObject;
import Common.Database.riDBObject;
import Common.Global;
import Common.UI.UI;
import com.sun.org.glassfish.gmbal.Description;
import java.io.File;
public class Test extends riDBObject {
@Description("DEFAULT 1")
public int dim = 1; //размерность теста. для удобства пусть будет и внешним полем.
@Description("DEFAULT ''")
public String args = ""; //аргументы командной строки. на всякий случай поле зарезервирую. пусть будут.
@Description("DEFAULT -1")
public int group_id = Constants.Nan;
@Override
public void SynchronizeFields(DBObject src) {
super.SynchronizeFields(src);
Test t = (Test) src;
dim = t.dim;
args = t.args;
group_id = t.group_id;
}
public Test(Test test) {
this.SynchronizeFields(test);
}
public Test() {
}
@Override
public void select(boolean flag) {
super.select(flag);
if (Current.hasUI())
UI.getMainWindow().ShowCheckedTestsCount();
}
//---
@Override
public boolean isVisible() {
return Current.HasGroup() && (Current.getGroup().id == group_id);
}
//-
public File getArchive() {
return new File(Global.TestsDirectory, id + ".zip");
}
//-
public File getServerPath() {
return new File(Global.TestsDirectory, String.valueOf(id));
}
public File getHomePath() {
return new File(Global.visualiser.getWorkspace(), String.valueOf(id));
}
}

View File

@@ -0,0 +1,86 @@
package TestingSystem.Common.Test;
import Common.Current;
import Common.Database.iDBTable;
import Common.UI.DataSetControlForm;
import Common.UI.Windows.Dialog.DBObjectDialog;
import TestingSystem.Common.Test.UI.TestFields;
public class TestDBTable extends iDBTable<Test> {
public TestDBTable() {
super(Test.class);
}
@Override
public String getSingleDescription() {
return "тест DVM";
}
@Override
public String getPluralDescription() {
return "тесты";
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this) {
@Override
protected void AdditionalInitColumns() {
//columns.get(0).setVisible(false);
}
@Override
public boolean hasCheckBox() {
return true;
}
};
}
@Override
public Object getFieldAt(Test object, int columnIndex) {
switch (columnIndex) {
case 2:
return object.description;
case 3:
return object.dim;
default:
return null;
}
}
@Override
public String[] getUIColumnNames() {
return new String[]{
"имя", "размерность"};
}
@Override
public Current CurrentName() {
return Current.Test;
}
@Override
public DBObjectDialog<Test, TestFields> getDialog() {
return new DBObjectDialog<Test, TestFields>(TestFields.class) {
@Override
public int getDefaultHeight() {
return 200;
}
@Override
public int getDefaultWidth() {
return 400;
}
@Override
public void validateFields() {
if (!edit) {
if (!Current.getGroup().language.equals(Current.getProject().languageName))
Log.Writeln_("В текущую группу могут войти только тесты на языке " + Current.getGroup().language);
}
}
@Override
public void fillFields() {
fields.tfName.setText(Result.description);
fields.sDim.setValue(Result.dim);
}
@Override
public void ProcessResult() {
Result.description = fields.tfName.getText();
Result.dim = (int) fields.sDim.getValue();
if (!edit) {
Result.sender_name = Current.getAccount().name;
Result.sender_address = Current.getAccount().email;
}
}
};
}
}

View File

@@ -0,0 +1,22 @@
package TestingSystem.Common.Test;
public enum TestType {
Default,
Correctness,
Performance,
SAPFOR,
;
public String getDescription(){
switch (this){
case Correctness:
return "Корректность";
case Performance:
return "Производительность";
case Default:
return "Без типа";
case SAPFOR:
return "SAPFOR";
default:
return "?";
}
}
}

View File

@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="TestingSystem.Common.Test.UI.TestFields">
<grid id="27dc6" binding="content" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="e9479" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="название"/>
</properties>
</component>
<vspacer id="9a439">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="ddf02" class="javax.swing.JTextField" binding="tfName" custom-create="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<enabled value="true"/>
</properties>
</component>
<component id="fbef6" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="размерность"/>
</properties>
</component>
<component id="2b54" class="javax.swing.JSpinner" binding="sDim">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="50" height="-1"/>
<maximum-size width="50" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
</children>
</grid>
</form>

View File

@@ -0,0 +1,22 @@
package TestingSystem.Common.Test.UI;
import Common.UI.TextField.StyledTextField;
import Common.UI.Windows.Dialog.DialogFields;
import javax.swing.*;
import java.awt.*;
public class TestFields implements DialogFields {
public JTextField tfName;
private JPanel content;
public JSpinner sDim;
@Override
public Component getContent() {
return content;
}
private void createUIComponents() {
// TODO: place custom component creation code here
tfName = new StyledTextField();
}
public TestFields(){
sDim.setModel(new SpinnerNumberModel(1, 0, 16,1));
}
}

View File

@@ -0,0 +1,235 @@
package TestingSystem.Common;
import Common.Global;
import Common.Utils.Utils;
import GlobalData.Machine.Machine;
import GlobalData.User.User;
import Repository.EmailMessage;
import Repository.Server.ServerCode;
import Repository.Server.ServerExchangeUnit_2021;
import TestingSystem.DVM.UserConnection;
import TestingSystem.SAPFOR.SapforTasksPackage.SapforTasksPackage;
import TestingSystem.SAPFOR.SapforTasksPackageSupervisor.SapforTasksPackageSupervisor;
import TestingSystem.DVM.Tasks.TestCompilationTask;
import TestingSystem.DVM.Tasks.TestTask;
import TestingSystem.DVM.TasksPackage.TasksPackage;
import TestingSystem.DVM.TasksPackage.TasksPackageState;
import TestingSystem.DVM.TestsSupervisor_2022;
import Visual_DVM_2021.Passes.PassException;
import Visual_DVM_2021.Passes.SSH.ConnectionPass;
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
import javafx.util.Pair;
import java.io.File;
import java.io.FileWriter;
import java.io.Serializable;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Vector;
import static Common.Constants.tests_db_name;
public class TestingPlanner {
public String email;
TasksPackage tasksPackage;
TestsSupervisor_2022 supervisor;
LinkedHashMap<String, Machine> machines = new LinkedHashMap<>();
LinkedHashMap<String, User> users = new LinkedHashMap<>();
protected Machine machine = null;
protected User user = null;
public LinkedHashMap<Long, TestCompilationTask> packageTasks = new LinkedHashMap<>();
//----------
SapforTasksPackage sapforTasksPackage = null;
//----------
public void UpdateTask(TestTask task_in) throws Exception {
task_in.ChangeDate = new Date().getTime();
ServerCommand(ServerCode.EditAccountObject, task_in);
}
public void UpdatePackage() throws Exception {
tasksPackage.ChangeDate = new Date().getTime();
ServerCommand(ServerCode.EditAccountObject, tasksPackage);
//---------------
if ((tasksPackage.needsEmail == 1) &&
(tasksPackage.state.equals(TasksPackageState.PackageStart) ||
(tasksPackage.state.equals(TasksPackageState.Done)) ||
(tasksPackage.state.equals(TasksPackageState.Aborted))
)) {
EmailMessage message = new EmailMessage();
message.subject = "Состояние пакета задач " + Utils.Brackets(tasksPackage.id) + " изменилось на " + Utils.Brackets(tasksPackage.state.getDescription());
message.text = tasksPackage.summary;
message.targets.add(email);
ServerCommand(ServerCode.Email, message);
}
}
//-
public Object ServerCommand(ServerCode code_in, String arg, Serializable object_in) throws Exception {
TestingSystemPass<Object> pass = new TestingSystemPass<Object>() {
@Override
public String getDescription() {
return "";
}
@Override
protected void ServerAction() throws Exception {
Command(new ServerExchangeUnit_2021(code_in, arg, object_in));
target = response.object;
}
};
if (!pass.Do()) throw new PassException("Ошибка взаимодействия с сервером " + code_in);
return pass.target;
}
public Object ServerCommand(ServerCode code_in, Serializable object_in) throws Exception {
return ServerCommand(code_in, email, object_in);
}
Object ServerCommand(ServerCode code_in) throws Exception {
return ServerCommand(code_in, email, null);
}
//-
boolean isPrintOn() {
return true;
}
public void Print(String message) {
try {
FileWriter testLog = new FileWriter(getClass().getSimpleName() + "_Log.txt", true);
String dmessage = Utils.Brackets(new Date()) + " " + message;
if (isPrintOn())
System.out.println(dmessage);
testLog.write(dmessage + "\n");
testLog.close();
} catch (Exception ex) {
ex.printStackTrace();
}
}
boolean CheckConnection(Machine machine, User user) {
//каждый раз соединяемся по новой. из за проблем с Exists.
// к тому же, теперь задачи гоняет модуль, тут только проверка
//так что время на разрыв уже не критично.
try {
user.connection = null;
user.connection = new UserConnection(machine, user);
Print("Соединение c " + machine.getURL() + " " + user.login + " успешно установлено.");
user.connection.ShellCommand("ulimit -s unlimited"); // нужно, для запуска сишной части.
} catch (Exception ex) {
Global.Log.PrintException(ex);
user.connection = null;
Print("Не удалось установить соединение.");
}
return user.connection != null;
}
//-
public void Perform() {
Vector<String> emails = new Vector<>();
while (true) {
emails.clear();
try {
File[] accountsBases_ = Global.DataDirectory.listFiles(pathname ->
pathname.isFile() &&
Utils.getExtension(pathname).equals("sqlite") &&
!Utils.getNameWithoutExtension(pathname.getName()).isEmpty() &&
!pathname.getName().equals(tests_db_name + ".sqlite")
);
if (accountsBases_ != null) {
for (File accountBase : accountsBases_) {
String fileName = accountBase.getName();
String account_email = accountBase.getName().substring(0, fileName.lastIndexOf('_'));
emails.add(account_email);
}
for (String current_email : emails)
emailPass(current_email);
}
} catch (Exception ex) {
ex.printStackTrace();
} finally {
try {
Utils.sleep(getSleepMillis());
} catch (Exception ignored) {
}
}
}
}
protected int getSleepMillis() {
return 2000;
}
void emailPass(String email_in) {
email = email_in;
try {
// System.out.println(email+" testing planner starts...");
Pair<TasksPackage, LinkedHashMap<Long, TestCompilationTask>> p = (Pair<TasksPackage, LinkedHashMap<Long, TestCompilationTask>>) ServerCommand(ServerCode.GetFirstActiveAccountPackage);
sapforTasksPackage = (SapforTasksPackage) ServerCommand(ServerCode.GetFirstActiveSapforTasksPackage);
tasksPackage = null;
packageTasks = null;
tasksPackage = p.getKey();
packageTasks = p.getValue();
if (tasksPackage != null) {
// System.out.println("found dvm package: "+sapforTasksPackage.id);
String machine_url = tasksPackage.machine_address + ":" + tasksPackage.machine_port;
if (!machines.containsKey(machine_url))
machines.put(machine_url, new Machine(
tasksPackage.machine_name,
tasksPackage.machine_address,
tasksPackage.machine_port,
tasksPackage.machine_type));
if (!users.containsKey(tasksPackage.user_name))
users.put(tasksPackage.user_name,
new User(tasksPackage.user_name, tasksPackage.user_password, tasksPackage.user_workspace));
machine = machines.get(machine_url);
//-->>
user = users.get(tasksPackage.user_name);
if (CheckConnection(machine, user)) {
try {
supervisor = new TestsSupervisor_2022(this, user.connection, tasksPackage, new Vector<>(packageTasks.values()));
supervisor.Perform();
} catch (Exception ex) {
Print("Ошибка сеанса, соединение будет разорвано.");
Print(ex.getMessage());
if (user.connection != null) {
user.connection.Disconnect();
user.connection = null;
}
}
}
}
if (sapforTasksPackage != null) {
System.out.println("found sapfor package: " + sapforTasksPackage.id + " state = " + sapforTasksPackage.state);
try {
(new SapforTasksPackageSupervisor(this, sapforTasksPackage)).Perform();
} catch (Exception ex) {
Print("Исключение при тестировании SAPROR");
Print(ex.getMessage());
}
}
} catch (Exception ex) {
Global.Log.PrintException(ex);
}
}
public String getStarter() {
return String.join("/", user.workspace, ConnectionPass.modules, ConnectionPass.starter);
}
public String getLauncher() {
return String.join("/", user.workspace, ConnectionPass.modules, ConnectionPass.launcher);
}
public String getPlanner() {
return String.join("/", user.workspace, ConnectionPass.modules, ConnectionPass.planner);
}
//--
public void UpdateSapforPackage() throws Exception {
sapforTasksPackage.ChangeDate = new Date().getTime();
EmailMessage message = null;
ServerCommand(ServerCode.EditAccountObject, sapforTasksPackage);
if (sapforTasksPackage.needsEmail == 1) {
switch (sapforTasksPackage.state) {
case RunningExecution:
case Aborted:
case Done:
//результаты.
message = new EmailMessage();
message.subject = "Состояние пакета задач SAPFOR" + Utils.Brackets(sapforTasksPackage.id) + " изменилось на " + Utils.Brackets(sapforTasksPackage.state.getDescription());
message.text = sapforTasksPackage.summary;
break;
default:
break;
}
}
if (message != null) {
message.targets.add(email);
ServerCommand(ServerCode.Email, message);
}
}
}

View File

@@ -0,0 +1,596 @@
package TestingSystem.Common;
import Common.Constants;
import Common.Database.DBObject;
import Common.Global;
import Common.Utils.Utils;
import GlobalData.Account.Account;
import GlobalData.Machine.Machine;
import GlobalData.RemoteFile.RemoteFile;
import GlobalData.Tasks.TaskState;
import GlobalData.User.User;
import ProjectData.LanguageName;
import ProjectData.Project.db_project_info;
import Repository.EmailMessage;
import Repository.RepositoryRefuseException;
import Repository.RepositoryServer;
import Repository.Server.ServerCode;
import Repository.Server.ServerExchangeUnit_2021;
import TestingSystem.Common.Group.Group;
import TestingSystem.Common.TasksPackageToKill.TasksPackageToKill;
import TestingSystem.Common.Test.Test;
import TestingSystem.Common.Test.TestType;
import TestingSystem.DVM.Tasks.TestCompilationTask;
import TestingSystem.DVM.Tasks.TestRunTask;
import TestingSystem.DVM.Tasks.TestTask;
import TestingSystem.DVM.TasksPackage.TasksPackage;
import TestingSystem.DVM.UserConnection;
import TestingSystem.SAPFOR.SapforTask.SapforTask;
import TestingSystem.SAPFOR.SapforTasksPackage.SapforPackageData;
import TestingSystem.SAPFOR.SapforTasksPackage.SapforTasksPackage;
import TestingSystem.SAPFOR.ServerSapfor.ServerSapfor;
import Visual_DVM_2021.Passes.All.DownloadRepository;
import Visual_DVM_2021.Passes.All.UnzipFolderPass;
import Visual_DVM_2021.Passes.All.ZipFolderPass;
import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.Pass_2021;
import javafx.util.Pair;
import org.apache.commons.io.FileUtils;
import javax.swing.*;
import java.io.File;
import java.io.Serializable;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.Vector;
import static Common.Constants.tests_db_name;
public class TestingServer extends RepositoryServer<TestsDatabase> {
LinkedHashMap<String, TasksDatabase> accountsBases = new LinkedHashMap<>();
//--------------------------------->>>
public TestingServer() {
super(TestsDatabase.class);
}
//основа
@Override
public int getPort() {
return 7998;
}
//---
public TasksDatabase account_db = null;
public void SetCurrentAccountDB(String email) {
if (accountsBases.containsKey(email)) {
account_db = accountsBases.get(email);
} else {
account_db = new TasksDatabase(email.equals("?") ? "undefined" : email);
accountsBases.put(email, account_db);
try {
account_db.Connect();
account_db.CreateAllTables();
account_db.prepareTablesStatements();
account_db.Synchronize();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
@Override
public void PublishAction(DBObject object) throws Exception {
if (object instanceof TasksPackage) {
//объект уже вставлен.
TasksPackage tasksPackage = (TasksPackage) object;
//-
for (int group_id : tasksPackage.sorted_tasks.keySet()) {
if (db.groups.containsKey(group_id)) {
Group group = db.groups.get(group_id);
LinkedHashMap<Integer, Vector<TestCompilationTask>> group_tasks = tasksPackage.sorted_tasks.get((group_id));
for (int test_id : group_tasks.keySet()) {
if (db.tests.containsKey(test_id)) {
Test test = db.tests.get(test_id);
db_project_info project = new db_project_info(test);//Открытие бд проекта и ее синхронизация. неизбежно.
//---
for (TestCompilationTask task : group_tasks.get(test_id)) {
Print("принять задачу на компиляцию " + group_id + ":" + test_id + ":" + task.flags);
//Теперь эту задачу надо поставить в очередь. и вернуть пользователю, уже с id
task.state = TaskState.Waiting;
task.id = db.IncMaxTaskId();
task.taskspackage_id = tasksPackage.id;
task.makefile_text = group.GenerateMakefile(project, tasksPackage.dvm_drv, task.flags);
task.test_home = tasksPackage.user_workspace + "/projects/" + test_id;
//-->>
task.remote_workspace =
new RemoteFile(
tasksPackage.user_workspace + "/tests/" + tasksPackage.id,
String.valueOf(task.id), true).full_name;
account_db.Insert(task);
if (task.runTasks != null) {
for (TestRunTask rt : task.runTasks) {
rt.id = db.IncMaxTaskId();
rt.taskspackage_id = tasksPackage.id;
rt.testcompilationtask_id = task.id;
rt.remote_workspace =
new RemoteFile(
tasksPackage.user_workspace + "/tests/" + tasksPackage.id,
String.valueOf(rt.id), true).full_name;
rt.binary_name = "spf_" + rt.id + "_" + rt.matrix.replace(" ", "_");
account_db.Insert(rt);
}
}
}
}
}
}
}
}
}
@Override
public void DeleteAction(DBObject object) throws Exception {
if (object instanceof Test) {
Test test = (Test) object;
Utils.forceDeleteWithCheck(test.getArchive());
Utils.forceDeleteWithCheck(test.getServerPath());
} else if (object instanceof Group) {
Group group = (Group) object;
Vector<Test> tests = new Vector<>();
for (Test group_test : db.tests.Data.values()) {
if (group_test.group_id == group.id) // todo group_name -> group_id
tests.add(group_test);
}
for (Test group_test : tests) {
db.Delete(group_test);
Utils.forceDeleteWithCheck(group_test.getArchive());
Utils.forceDeleteWithCheck(group_test.getServerPath());
}
} else if (object instanceof ServerSapfor) {
Utils.forceDeleteWithCheck(
new File(
((ServerSapfor) object).home_path
)
);
} else if (object instanceof SapforTasksPackage) {
SapforTasksPackage sapforTasksPackage = (SapforTasksPackage) object;
File workspace = new File(
sapforTasksPackage.workspace
);
System.out.println(Utils.Brackets(workspace.getAbsolutePath()));
Utils.forceDeleteWithCheck(workspace);
Utils.forceDeleteWithCheck(sapforTasksPackage.getArchive());
//внешние ключи не работают
Vector<SapforTask> tasks = new Vector<>();
for (SapforTask task : account_db.sapforTasks.Data.values()) {
if (task.sapfortaskspackage_id == sapforTasksPackage.id) // todo group_name -> group_id
tasks.add(task);
}
for (SapforTask task : tasks) {
account_db.Delete(task);
}
}
}
@Override
public boolean canDelete(DBObject object) throws Exception {
if (object instanceof TestTask) {
return !((TestTask) object).state.equals(TaskState.Running);
} else
return super.canDelete(object);
}
public void TestsSynchronize(String userWorkspace, Vector<Object> args) throws Exception {
Machine machine = (Machine) args.get(0);
User user = (User) args.get(1);
Vector<String> test_ids = (Vector<String>) args.get(2);
//---->>>
UserConnection connection = new UserConnection(machine, user);
for (String test_id : test_ids) {
File test_src = Paths.get(Global.TestsDirectory.getAbsolutePath(), test_id).toFile();
RemoteFile test_dst = new RemoteFile(userWorkspace + "/projects/" + test_id, true);
connection.MKDIR(test_dst);
connection.SynchronizeSubDirsR(test_src, test_dst);
}
//---->>>
connection.Disconnect();
}
//--->>
@Override
protected void startAdditionalThreads() {
testingThread.start();
}
protected TestingPlanner testingPlanner = new TestingPlanner();
protected Thread testingThread = new Thread(() -> testingPlanner.Perform());
//------>>>
public static Timer checkTimer = null;
public static void TimerOn() {
System.out.println("timer on");
checkTimer = new Timer(Global.properties.CheckTestingIntervalSeconds * 1000, e -> {
Pass_2021.passes.get(PassCode_2021.SynchronizeTestsTasks).Do();
});
checkTimer.start();
}
public static void TimerOff() {
System.out.println("timer off");
if (checkTimer != null)
checkTimer.stop();
}
public static void ResetTimer() {
TimerOff();
TimerOn();
}
@Override
protected void Session() throws Exception {
DBObject dbObject;
Test test;
int test_id;
switch (code) {
case PublishTestProject:
Print("Прикрепить проект к тесту " + request.arg);
System.out.println("Прикрепить проект к тесту " + request.arg);
test_id = Integer.parseInt(request.arg);
if (db.tests.containsKey(test_id)) {
test = db.tests.get(test_id);
Utils.unpackFile((byte[]) request.object, test.getArchive());
UnzipFolderPass unzipFolderPass = new UnzipFolderPass();
if (!unzipFolderPass.Do(
test.getArchive().getAbsolutePath(),
Global.TestsDirectory.getAbsolutePath())) {
db.Delete(test);
throw new RepositoryRefuseException(
"Не удалось прикрепить проект к тесту с id " + test.id
+ "\nТест будет удален"
);
}
} else {
throw new RepositoryRefuseException("Не существует теста с ключом " + Utils.Brackets(request.arg));
}
response = new ServerExchangeUnit_2021(ServerCode.OK);
break;
case EmailSapforAssembly:
Print("Сообщить о сборке SAPFOR для пользователя " + request.arg);
Vector<String> assembly_info = (Vector<String>) request.object;
File out = Paths.get(Global.RepoDirectory.getAbsolutePath(), Constants.SAPFOR_REPOSITORY_BIN, Constants.out_file).toFile();
File err = Paths.get(Global.RepoDirectory.getAbsolutePath(), Constants.SAPFOR_REPOSITORY_BIN, Constants.err_file).toFile();
Vector<String> targets = new Vector<>();//Arrays.asList(Global.admins_mails));
targets.add("vmk-post@yandex.ru");
EmailMessage message = new EmailMessage(
"Выполнена сборка системы SAPFOR",
"Версия: " + assembly_info.get(0) + "\n" + "Статус: " + assembly_info.get(1),
targets
);
Email(message, out, err);
response = new ServerExchangeUnit_2021(ServerCode.OK);
break;
case PublishSapforPackageTasks:
Print("Опубликовать задачи SAPFOR для пользователя " + request.arg);
SetCurrentAccountDB(request.arg);
Vector<Object> tasks = (Vector<Object>) request.object;
account_db.BeginTransaction();
for (Object object : tasks) {
SapforTask task = (SapforTask) object;
task.id = db.IncMaxTaskId();
if (account_db.InsertWithCheck_(task) != null)
PublishAction(task);
}
account_db.Commit();
response = new ServerExchangeUnit_2021(ServerCode.OK);
break;
case DownloadSapforTasksPackage:
Print("Загрузить пакет тестов SAPFOR " + request.object + " для пользователя " + request.arg);
SetCurrentAccountDB(request.arg);
response = new ServerExchangeUnit_2021(ServerCode.OK);
//---
if (!account_db.sapforTasksPackages.containsKey(request.object))
throw new RepositoryRefuseException("Не существует пакета с ключом " + Utils.Brackets(request.object));
//--
SapforTasksPackage sapforTasksPackage = account_db.sapforTasksPackages.get(request.object);
//---
//1 - архивировать пакет.
File packageArchive = sapforTasksPackage.getArchive();
Utils.forceDeleteWithCheck(packageArchive);
System.out.println("src = " + Utils.Brackets(sapforTasksPackage.workspace));
System.out.println("dst=" + Utils.Brackets(packageArchive.getAbsolutePath()));
//---
ZipFolderPass zip = new ZipFolderPass();
if (zip.Do(sapforTasksPackage.workspace, packageArchive.getAbsolutePath())) {
response.object = Utils.packFile(packageArchive);
Print("Архив успешно запакован");
} else throw new RepositoryRefuseException("Не удалось запаковать архив пакета");
//---
break;
case SynchronizeTests:
//временный проход. синхронизирует тесты на заданной машине, с сервера.
Print("Синхронизация тестов");
TestsSynchronize(request.arg, (Vector<Object>) request.object);
//------------->>
response = new ServerExchangeUnit_2021(ServerCode.OK);
break;
case CheckPackageToKill:
SetCurrentAccountDB(request.arg);
String packageName = (String) request.object;
response = new ServerExchangeUnit_2021(ServerCode.OK);
boolean res_ = false;
for (TasksPackageToKill tasksPackageToKill : account_db.packagesToKill.Data.values()) {
if (tasksPackageToKill.packageName.equals(packageName)) {
res_ = true;
break;
}
}
response.object = res_;
break;
case EditAccountObject:
SetCurrentAccountDB(request.arg);
DBObject new_object = (DBObject) request.object;
Print("Редактировать объект " + new_object.getPK() + " для пользователя " + request.arg);
account_db.UpdateWithCheck(new_object);
response = new ServerExchangeUnit_2021(ServerCode.OK);
break;
case GetAccountObjectCopyByPK:
SetCurrentAccountDB(request.arg);
Pair<Class, Object> p = (Pair<Class, Object>) request.object;
Print("Получить для пользователя " + request.arg + " копию объекта класса " + p.getKey().toString() + " по ключу " + p.getValue());
dbObject = account_db.getObjectCopyByPK(p.getKey(), p.getValue());
response = new ServerExchangeUnit_2021(ServerCode.OK);
response.object = dbObject;
break;
case PublishAccountObjects:
Print("Опубликовать объекты для пользователя " + request.arg);
SetCurrentAccountDB(request.arg);
Vector<Object> objects__ = (Vector<Object>) request.object;
account_db.BeginTransaction();
for (Object object : objects__)
if (account_db.InsertWithCheck_((DBObject) object) != null)
PublishAction((DBObject) object);
account_db.Commit();
response = new ServerExchangeUnit_2021(ServerCode.OK);
break;
case CheckAccountObjectExistense:
SetCurrentAccountDB(request.arg);
p = (Pair<Class, Object>) request.object;
Print("Проверить существование объекта класса для пользователя " + request.arg + " " + p.getKey().toString() + " с ключом " + p.getValue());
response = new ServerExchangeUnit_2021(ServerCode.OK);
response.object = account_db.checkObjectExistense(p.getKey(), p.getValue());
break;
//------------------------------------------->>
case DownloadTest:
Print("Отправить клиенту тест " + request.arg);
test_id = Integer.parseInt(request.arg);
if (db.tests.containsKey(test_id)) {
test = db.tests.get(test_id);
response = new ServerExchangeUnit_2021(ServerCode.OK, "", Utils.packFile(test.getArchive()));
} else
throw new RepositoryRefuseException("Теста с именем " + request.arg + " не существует");
break;
//-------------------------------------------------------------------------------------->>>>
case GetAccountQueueSize:
Print("Получить размер очереди для пользователя " + request.arg);
SetCurrentAccountDB(request.arg);
response = new ServerExchangeUnit_2021(ServerCode.OK);
response.object = (int) account_db.testCompilationTasks.Data.values().stream().filter(ctask -> ctask.state.isActive()).count()
+ (int) account_db.testRunTasks.Data.values().stream().filter(rtask -> rtask.state.isActive()).count();
break;
case GetAccountObjectsCopiesByPKs:
Print("Получить список копий объектов для пользователя " + request.arg);
p = (Pair<Class, Object>) request.object;
SetCurrentAccountDB(request.arg);
response = new ServerExchangeUnit_2021(ServerCode.OK);
response.object = account_db.getObjectsCopies(p.getKey(), (Vector<Object>) p.getValue());
break;
case GetFirstActiveAccountPackage:
Print("Получить первый активный пакет задач для пользователя " + request.arg);
SetCurrentAccountDB(request.arg);
response = new ServerExchangeUnit_2021(ServerCode.OK);
TasksPackage tasksPackage = account_db.getFirstActivePackage();
LinkedHashMap<Long, TestCompilationTask> activeTasks = account_db.getPackageCompilationTasks(tasksPackage);
response.object = new Pair<>(tasksPackage, activeTasks);
break;
case GetFirstActiveSapforTasksPackage:
Print("Получить первый активный сценарий задач SAPFOR" + request.arg);
SetCurrentAccountDB(request.arg);
response = new ServerExchangeUnit_2021(ServerCode.OK);
response.object = account_db.getFirstActiveSapforPackage();
break;
case GetQueueSize:
Print("Получить размер глобальной очереди задач");
long date = (long) request.object;
long res = 0;
Vector<String> emails = new Vector<>();
File[] accountsBases_ = Global.DataDirectory.listFiles(pathname ->
pathname.isFile() &&
Utils.getExtension(pathname).equals("sqlite") &&
!Utils.getNameWithoutExtension(pathname.getName()).isEmpty() &&
!pathname.getName().equals(tests_db_name + ".sqlite")
);
if (accountsBases_ != null) {
for (File accountBase : accountsBases_) {
String fileName = accountBase.getName();
String account_email = accountBase.getName().substring(0, fileName.lastIndexOf('_'));
emails.add(account_email);
}
for (String email : emails) {
SetCurrentAccountDB(email);
res += account_db.getQueueSize(date);
}
}
//пройтись по всем аккаунтам, и узнать все пакеты, чья дата меньше равна дате в арге
response = new ServerExchangeUnit_2021(ServerCode.OK);
response.object = res;
break;
case ReceiveTestsDatabase:
Print("Получить базу данных тестов");
response = new ServerExchangeUnit_2021(ServerCode.OK);
response.object = Utils.packFile(db.getFile());
break;
case ReceiveTestsTasksDatabase:
Print("Получить базу данных тестовых задач пользователя " + request.arg);
SetCurrentAccountDB(request.arg);
response = new ServerExchangeUnit_2021(ServerCode.OK);
response.object = Utils.packFile(account_db.getFile());
break;
case DeleteAccountObjectByPK:
Print("Удалить объект по ключу из базы пользователя " + request.arg);
SetCurrentAccountDB(request.arg);
Pair<Class, Object> to_delete = (Pair<Class, Object>) request.object;
DeleteAction(account_db.DeleteByPK(to_delete.getKey(), to_delete.getValue()));
response = new ServerExchangeUnit_2021(ServerCode.OK);
break;
case PublishAccountAIObject:
Print("Опубликовать объект с автоинкрементным ключом для пользователя " + request.arg);
SetCurrentAccountDB(request.arg);
dbObject = (DBObject) request.object;
account_db.Insert(dbObject); //проверка не нужна,АИ гарантирует что ключ уникален.
PublishAction(dbObject);
response = new ServerExchangeUnit_2021(ServerCode.OK);
response.object = (Serializable) dbObject.getPK(); //чтобы пользователь знал, какой ключ.
break;
case GetActualSapforPackageData:
Print("Запросить актуальные данные пакета");
sapforTasksPackage = (SapforTasksPackage) request.object;
SapforPackageData sapforPackageData = new SapforPackageData();
Vector<String> notFoundLines = new Vector<>();
//---
String[] configurations = sapforTasksPackage.configurationsIds.split("\n");
for (String id_s : configurations) {
int id = Integer.parseInt(id_s);
if (db.sapforConfigurations.containsKey(id)) {
sapforPackageData.sapforConfigurations.put(id, db.sapforConfigurations.get(id));
} else {
notFoundLines.add("конфигурация с ключом " + id_s + " не существует");
}
}
//---
String[] tests = sapforTasksPackage.testsIds.split("\n");
for (String id_s : tests) {
int id = Integer.parseInt(id_s);
if (db.tests.containsKey(id)) { //если есть тест есть и группа.
test = db.tests.get(id);
sapforPackageData.tests.put(id, test);
sapforPackageData.groups.put(test.group_id, db.groups.get(test.group_id));
} else {
notFoundLines.add("теста с ключом " + id_s + " не существует");
}
}
//--
if (db.serverSapfors.containsKey(sapforTasksPackage.sapforId)) {
sapforPackageData.sapfor = db.serverSapfors.get(sapforTasksPackage.sapforId);
} else
notFoundLines.add("версии SAPFOR с ключом" + sapforTasksPackage.sapforId + " не существует");
//---
if (!notFoundLines.isEmpty())
sapforPackageData.notFound = String.join("\n", notFoundLines);
//---
response = new ServerExchangeUnit_2021(ServerCode.OK);
response.object = sapforPackageData;
break;
//---
case RefreshDVMTests:
Print("Синхронизировать репозиторий тестов ");
response = new ServerExchangeUnit_2021(ServerCode.OK);
response.object = RefreshDVMTests((Account) request.object);
break;
//--
default:
throw new RepositoryRefuseException("Неподдерживаемый код: " + code);
}
}
//->>
//->>
Pair<Group, Vector<File>> ConvertDirectoryToGroup(File src, LanguageName languageName, TestType testType, Account account) throws Exception {
Group object = new Group();
Vector<File> groupFiles = null; //транспорт.
//->>
object.description = src.getName();
object.language = languageName;
object.type = testType;
object.sender_name = account.name;
object.sender_address = account.email;
//-->>
File[] files = src.listFiles(pathname ->
pathname.isFile()
&& !pathname.getName().equals("settings")
&& !pathname.getName().equals("test-analyzer.sh")
&& Utils.getExtension(pathname).startsWith(languageName.getDVMCompile()));
;
if (files != null) {
groupFiles = new Vector<>(Arrays.asList(files));
groupFiles.sort(Comparator.comparing(File::getName));
}
//->>
return new Pair<>(object, groupFiles);
}
public LinkedHashMap<Group, Vector<Test>> RefreshDVMTests(Account account) throws Exception {
DownloadRepository downloadRepository = new DownloadRepository();
if (!downloadRepository.Do())
throw new RepositoryRefuseException("Не удалось обновить репозиторий");
//-->>
Vector<Pair<Group, Vector<File>>> groups = new Vector<>();
LinkedHashMap<Group, Vector<Test>> res = new LinkedHashMap<>();
File testsSrc = Paths.get(
Global.RepoDirectory.getAbsolutePath(),
"dvm", "tools", "tester", "trunk", "test-suite").toFile();
LanguageName[] supportedLanguages = new LanguageName[]{LanguageName.fortran, LanguageName.c};
for (LanguageName languageName : supportedLanguages) {
for (TestType testType : TestType.values()) {
File groupsSrc = null;
switch (testType) {
case Correctness:
String languageSrcName = null;
switch (languageName) {
case fortran:
languageSrcName = "Fortran";
break;
case c:
languageSrcName = "C";
break;
}
if (languageSrcName != null) {
groupsSrc = Paths.get(testsSrc.getAbsolutePath(), "Correctness", languageSrcName).toFile();
File[] groupsDirs = groupsSrc.listFiles(File::isDirectory);
if (groupsDirs != null) {
for (File groupDir : groupsDirs)
groups.add(ConvertDirectoryToGroup(groupDir, languageName, testType, account));
}
}
break;
case Performance:
File groupDir = Paths.get(testsSrc.getAbsolutePath(), "Performance").toFile();
groups.add(ConvertDirectoryToGroup(groupDir, languageName, testType, account));
break;
}
}
}
groups.sort(Comparator.comparing(o -> o.getKey().description));
//-теперь создать тесты.
System.out.println("найдено " + groups.size() + " групп");
//--
for (Pair<Group, Vector<File>> p : groups) {
Group group = p.getKey();
//-
db.Insert(group);
Vector<Test> testsIds = new Vector<>();
res.put(group, testsIds);
//-
Vector<File> files = p.getValue();
if (!files.isEmpty()) {
//->>
for (File file : files) {
System.out.println("Создание теста " + file.getName());
Test test = new Test();
test.description = Utils.getNameWithoutExtension(file.getName()) + "_" + group.language.getDVMCompile();
test.sender_name = account.name;
test.sender_address = account.email;
test.group_id = group.id;
db.Insert(test);
testsIds.add(test);
//->>
File testProject = new File(Global.TestsDirectory, String.valueOf(test.id));
Utils.CheckAndCleanDirectory(testProject);
File testFile = Paths.get(testProject.getAbsolutePath(), file.getName()).toFile();
FileUtils.copyFile(file, testFile);
//----
//архивация.
File archive = test.getArchive();
ZipFolderPass zip = new ZipFolderPass();
zip.Do(testProject.getAbsolutePath(), archive.getAbsolutePath());
}
}
}
return res;
}
}

View File

@@ -0,0 +1,65 @@
package TestingSystem.Common;
import Common.Constants;
import Common.Database.SQLITE.SQLiteDatabase;
import GlobalData.Settings.SettingName;
import TestingSystem.SAPFOR.SapforConfiguration.SapforConfigurationDBTable;
import TestingSystem.SAPFOR.SapforConfigurationCommand.SapforConfigurationCommandsDBTable;
import TestingSystem.SAPFOR.ServerSapfor.ServerSapforsDBTable;
import TestingSystem.DVM.Configuration.UI.ConfigurationDBTable;
import TestingSystem.Common.Group.GroupsDBTable;
import TestingSystem.Common.TSetting.TSetting;
import TestingSystem.Common.TSetting.TSettingsDBTable;
import TestingSystem.Common.Test.TestDBTable;
import Visual_DVM_2021.Passes.PassCode_2021;
import java.nio.file.Paths;
public class TestsDatabase extends SQLiteDatabase {
public ConfigurationDBTable configurations;
public TestDBTable tests;
public GroupsDBTable groups;
public TSettingsDBTable settings;
//--
public SapforConfigurationDBTable sapforConfigurations;
public SapforConfigurationCommandsDBTable sapforConfigurationCommands;
//----
public ServerSapforsDBTable serverSapfors;
public TestsDatabase() {
super(Paths.get(System.getProperty("user.dir"), "Data", Constants.tests_db_name + ".sqlite").toFile());
}
@Override
protected void initAllTables() throws Exception {
addTable(configurations = new ConfigurationDBTable());
addTable(groups = new GroupsDBTable());
addTable(tests = new TestDBTable());
addTable(settings = new TSettingsDBTable());
//-
addTable(sapforConfigurations = new SapforConfigurationDBTable());
addTable(sapforConfigurationCommands = new SapforConfigurationCommandsDBTable());
addTable(serverSapfors = new ServerSapforsDBTable());
}
@Override
public void Init() throws Exception {
if (!settings.containsKey(SettingName.TaskMaxId))
Insert(new TSetting(SettingName.TaskMaxId, 63128));
if (!settings.containsKey(SettingName.SapforTaskMaxId))
Insert(new TSetting(SettingName.SapforTaskMaxId, 0));
}
@Override
public PassCode_2021 getSynchronizePassCode() {
return PassCode_2021.SynchronizeTests;
}
public long IncMaxTaskId() throws Exception {
TSetting setting = settings.get(SettingName.TaskMaxId);
long res = setting.value;
setting.value++;
Update(setting);
return res;
}
public long IncSapforMaxTaskId() throws Exception {
TSetting setting = settings.get(SettingName.SapforTaskMaxId);
long res = setting.value;
setting.value++;
Update(setting);
return res;
}
}

View File

@@ -0,0 +1,103 @@
package TestingSystem.Common.ThreadsPlanner;
import Common.Global;
import Common.Utils.InterruptThread;
import java.util.LinkedHashMap;
import java.util.Vector;
public abstract class ThreadsPlanner {
//-->
protected Thread interruptThread = new InterruptThread(5000, () -> {
try {
Interrupt();
} catch (Exception exception) {
Global.Log.PrintException(exception);
}
System.exit(0);
return null;
});
protected int maxKernels;
protected int kernels;
//---
protected int threadMaxId = 0;
protected int wait_ms;
protected LinkedHashMap<Integer, Thread> threads = new LinkedHashMap<>();
protected Vector<Integer> activeThreads = new Vector<>();
protected Vector<Integer> waitingThreads = new Vector<>();
//--
public ThreadsPlanner(int wait_ms_in) {
wait_ms = wait_ms_in;
}
public void setMaxKernels(int maxKernels_in) {
maxKernels = maxKernels_in;
kernels = maxKernels;
}
public String printThread(Integer id) {
return "thread id = "+id;
}
public String getThreadsSummary() {
Vector<String> lines = new Vector<>();
lines.add("Planner summary:");
lines.add("Waiting: " + waitingThreads.size());
lines.add("Running: " + activeThreads.size());
for (Integer id : activeThreads) {
lines.add(printThread(id));
}
lines.add("");
return String.join("\n", lines);
}
//--
public void Start() {
Global.Log.Print("Planner started");
try {
//--
while (!waitingThreads.isEmpty() || !activeThreads.isEmpty()) {
Global.Log.Print(getThreadsSummary());
checkActiveThreads();
tryStartThreads();
Thread.sleep(wait_ms);
}
//--
} catch (Exception exception) {
Global.Log.PrintException(exception);
} finally {
Global.Log.Print("Planner finished");
finalize();
}
}
public void Interrupt() throws Exception {
}
protected void checkActiveThreads() throws Exception {
Vector<Integer> toExclude = new Vector<>();
//--
for (int i : activeThreads) {
Thread thread = threads.get(i);
if (!thread.isAlive()) {
toExclude.add(i);
kernels++;
}
}
activeThreads.removeAll(toExclude);
//--
}
protected void tryStartThreads() throws Exception {
Vector<Integer> toExclude = new Vector<>();
//-
for (int i : waitingThreads) {
if (kernels > 0) {
Thread thread = threads.get(i);
thread.start();
activeThreads.add(i);
kernels--;
toExclude.add(i);
} else break;
}
waitingThreads.removeAll(toExclude);
}
protected void finalize() {
}
protected void addThread(Thread thread) {
threads.put(threadMaxId, thread);
waitingThreads.add(threadMaxId);
threadMaxId++;
}
}

View File

@@ -0,0 +1,36 @@
package TestingSystem.DVM.Configuration;
import Common.Database.DBObject;
import Common.Database.rDBObject;
public class Configuration extends rDBObject {
//компиляция.
public String flags = "\n";
public int c_maxtime = 40;
//матрица
public int cube = 1;
public int max_proc_count = 4;
public int min_dim_proc_count = 1;
public int max_dim_proc_count = 4;
//запуск
public String environments="\n";
public String usr_par = "";
public int r_maxtime = 300;
//-
@Override
public void SynchronizeFields(DBObject src) {
super.SynchronizeFields(src);
Configuration c = (Configuration) src;
flags = c.flags;
c_maxtime=c.c_maxtime;
cube= c.cube;
max_proc_count=c.max_proc_count;
min_dim_proc_count=c.min_dim_proc_count;
max_dim_proc_count=c.max_dim_proc_count;
environments=c.environments;
usr_par=c.usr_par;
r_maxtime=c.r_maxtime;
}
public Configuration(Configuration src){
this.SynchronizeFields(src);
}
public Configuration(){}
}

View File

@@ -0,0 +1,69 @@
package TestingSystem.DVM.Configuration;
import Common.Utils.Utils;
import GlobalData.RunConfiguration.RunConfiguration;
import java.util.Vector;
public class ConfigurationInterface {
public static Vector<String> getFlags(TestingSystem.DVM.Configuration.Configuration object) {
return Utils.unpackStrings(object.flags);
}
public static Vector<String> getEnvironments(TestingSystem.DVM.Configuration.Configuration object) {
return Utils.unpackStrings(object.environments);
}
public static Vector<String> getParams(TestingSystem.DVM.Configuration.Configuration object) {
return Utils.unpackStrings(object.usr_par);
}
public static Vector<String> getMatrixes(TestingSystem.DVM.Configuration.Configuration object, int testDim) {
Vector<Vector<Integer>> res_ = new Vector<>();
Vector<String> res = new Vector<>();
if ((object.max_proc_count==0) || (object.min_dim_proc_count == 0 && object.max_dim_proc_count == 0)) {
res.add("");
} else {
if (testDim > 0) {
Vector<String> min_border = new Vector<>();
Vector<String> max_border = new Vector<>();
for (int i = 1; i <= testDim; ++i) {
min_border.add(String.valueOf(object.min_dim_proc_count));
max_border.add(String.valueOf(object.max_dim_proc_count));
}
Vector<Integer> from = RunConfiguration.getBounds(String.join(" ", min_border));
Vector<Integer> to = RunConfiguration.getBounds(String.join(" ", max_border));
if (from.size() != to.size()) {
System.out.println("Верхняя и нижняя границы матриц конфигурации имеют разные размерности");
return res;
}
if (from.size() != testDim) {
System.out.println("Границы матриц не совпадают с размерностью конфигурации");
return res;
}
//1 стадия. заполнение.
for (int j = from.get(0); j <= to.get(0); ++j) {
Vector<Integer> m = new Vector<>();
res_.add(m);
m.add(j);
}
//---
if (testDim > 1) RunConfiguration.gen_rec(from, to, res_, 1, testDim, object.cube == 1);
for (Vector<Integer> m : res_) {
Vector<String> ms = new Vector<>();
int proc = 1;
for (int i : m) {
ms.add(String.valueOf(i));
proc *= i;
}
if (proc <= object.max_proc_count)
res.add(String.join(" ", ms));
}
} else res.add("");
}
return res;
}
public static String getParamsText(Configuration object) {
Vector<String> params = getParams(object);
if ((params.size() == 1) && params.get(0).isEmpty()) return "";
return String.join("\n", params);
}
public static String getSummary(Configuration configuration) {
return configuration.description;
}
}

View File

@@ -0,0 +1,164 @@
package TestingSystem.DVM.Configuration.UI;
import Common.Current;
import Common.Database.DBObject;
import Common.Database.DBTable;
import Common.UI.DataSetControlForm;
import Common.UI.Tables.TableRenderers;
import Common.UI.VisualiserStringList;
import Common.UI.Windows.Dialog.DBObjectDialog;
import Common.Utils.Utils;
import TestingSystem.DVM.Configuration.Configuration;
import TestingSystem.DVM.Configuration.ConfigurationInterface;
public class ConfigurationDBTable extends DBTable<String, Configuration> {
public ConfigurationDBTable() {
super(String.class, Configuration.class);
}
@Override
public Current CurrentName() {
return Current.Configuration;
}
@Override
public String getSingleDescription() {
return "конфигурация тестирования";
}
@Override
public String getPluralDescription() {
return "конфигурации";
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this) {
@Override
public boolean hasCheckBox() {
return true;
}
@Override
protected void AdditionalInitColumns() {
columns.get(0).setVisible(false);
columns.get(4).setRenderer(TableRenderers.RendererMultiline);
columns.get(5).setRenderer(TableRenderers.RendererMultiline);
columns.get(12).setRenderer(TableRenderers.RendererMultiline);
}
};
}
@Override
public String[] getUIColumnNames() {
return new String[]{
"имя",
"автор",
"флаги",
"окружение",
"c_time",
"куб",
"max",
"min dim",
"max dim",
"r_time",
"usr.par"
};
}
@Override
public Object getFieldAt(Configuration object, int columnIndex) {
switch (columnIndex) {
case 2:
return object.description;
case 3:
return object.sender_name;
case 4:
return Utils.unpackStrings(object.flags, true);
case 5:
return Utils.unpackStrings(object.environments, true);
case 6:
return object.c_maxtime;
case 7:
return object.cube;
case 8:
return object.max_proc_count;
case 9:
return object.min_dim_proc_count;
case 10:
return object.max_dim_proc_count;
case 11:
return object.r_maxtime;
case 12:
return Utils.unpackStrings(object.usr_par, true);
default:
return null;
}
}
@Override
public DBObjectDialog<Configuration, ConfigurationFields> getDialog() {
return new DBObjectDialog<Configuration, ConfigurationFields>(ConfigurationFields.class) {
@Override
public int getDefaultHeight() {
return 480;
}
@Override
public int getDefaultWidth() {
return 1000;
}
@Override
public void validateFields() {
int min = (int) fields.sMinDimProc.getValue();
int max = (int) fields.sMaxDimProc.getValue();
if (max < min)
Log.Writeln_("Некорректный диапазон размерностей: максимум меньше минимума");
if ((min == 0) && (max != 0) || (min != 0) && (max == 0))
Log.Writeln_("Некорректный диапазон размерностей. " +
"'0' допускается только одновременно на обеих границах,\n" +
"и подразумевает единственный запуск без решётки");
}
@Override
public void fillFields() {
fields.tfName.setText(Result.description);
//------->>>>
((VisualiserStringList) (fields.flagsList)).fill(ConfigurationInterface.getFlags(Result));
((VisualiserStringList) (fields.environmentsList)).fill(ConfigurationInterface.getEnvironments(Result));
((VisualiserStringList) (fields.parList)).fill(ConfigurationInterface.getParams(Result));
//------->>>>
fields.sCompilationMaxtime.setValue(Result.c_maxtime);
//-
fields.sMinDimProc.setValue(Result.min_dim_proc_count);
fields.sMaxDimProc.setValue(Result.max_dim_proc_count);
fields.cbCube.setSelected(Result.cube == 1);
fields.sRunMaxtime.setValue(Result.r_maxtime);
//-
fields.sMaxProc.setValue(Result.max_proc_count);
}
@Override
public void ProcessResult() {
Result.description = fields.tfName.getText();
Result.c_maxtime = (int) fields.sCompilationMaxtime.getValue();
Result.min_dim_proc_count = (int) fields.sMinDimProc.getValue();
Result.max_dim_proc_count = (int) fields.sMaxDimProc.getValue();
Result.cube = fields.cbCube.isSelected() ? 1 : 0;
Result.max_proc_count = (int) fields.sMaxProc.getValue();
Result.r_maxtime = (int) fields.sRunMaxtime.getValue();
Result.flags = ((VisualiserStringList) (fields.flagsList)).pack();
Result.environments = ((VisualiserStringList) (fields.environmentsList)).pack();
Result.usr_par = ((VisualiserStringList) (fields.parList)).pack();
}
@Override
public void SetReadonly() {
fields.tfName.setEnabled(false);
fields.sCompilationMaxtime.setEnabled(false);
fields.sRunMaxtime.setEnabled(false);
fields.sMinDimProc.setEnabled(false);
fields.sMaxDimProc.setEnabled(false);
fields.cbCube.setEnabled(false);
fields.sMaxProc.setEnabled(false);
fields.bAddFlags.setEnabled(false);
fields.bDeleteFlags.setEnabled(false);
fields.bAddEnvironments.setEnabled(false);
fields.bDeleteEnvironment.setEnabled(false);
fields.bAddPar.setEnabled(false);
fields.bDeletePar.setEnabled(false);
}
};
}
@Override
public boolean ShowEditObjectDialog(DBObject object) {
return (Current.getAccount().CheckAccessRights(((Configuration) object).sender_address, null)) ? super.ShowEditObjectDialog(object) : ViewObject(object);
}
}

View File

@@ -0,0 +1,402 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="TestingSystem.DVM.Configuration.UI.ConfigurationFields">
<grid id="27dc6" binding="content" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="821" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<splitpane id="78a2d" binding="SC1">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<preferred-size width="200" height="200"/>
</grid>
</constraints>
<properties>
<dividerLocation value="500"/>
<dividerSize value="3"/>
</properties>
<border type="none"/>
<children>
<grid id="ee2fd" layout-manager="GridLayoutManager" row-count="8" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<splitpane position="left"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="259d7" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="название"/>
</properties>
</component>
<vspacer id="264c1">
<constraints>
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="6795f" class="javax.swing.JTextField" binding="tfName" custom-create="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<minimum-size width="200" height="30"/>
<preferred-size width="238" height="30"/>
<maximum-size width="200" height="30"/>
</grid>
</constraints>
<properties/>
</component>
<component id="9219f" class="javax.swing.JSpinner" binding="sMinDimProc">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<minimum-size width="100" height="30"/>
<preferred-size width="100" height="30"/>
<maximum-size width="100" height="30"/>
</grid>
</constraints>
<properties/>
</component>
<component id="5686a" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="мин. число процессоров по измерению"/>
</properties>
</component>
<component id="79cbe" class="javax.swing.JLabel">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="макс. число процессоров по измерению"/>
</properties>
</component>
<component id="33803" class="javax.swing.JSpinner" binding="sMaxDimProc">
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<minimum-size width="100" height="30"/>
<preferred-size width="100" height="30"/>
<maximum-size width="100" height="30"/>
</grid>
</constraints>
<properties/>
</component>
<component id="9b066" class="javax.swing.JLabel">
<constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="макс. время компиляции"/>
</properties>
</component>
<component id="d706b" class="javax.swing.JSpinner" binding="sCompilationMaxtime">
<constraints>
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<minimum-size width="100" height="30"/>
<preferred-size width="238" height="30"/>
<maximum-size width="100" height="30"/>
</grid>
</constraints>
<properties/>
</component>
<component id="a3108" class="javax.swing.JLabel">
<constraints>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="макс. время выполнения"/>
</properties>
</component>
<component id="22d31" class="javax.swing.JSpinner" binding="sRunMaxtime">
<constraints>
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<minimum-size width="100" height="30"/>
<preferred-size width="100" height="30"/>
<maximum-size width="100" height="30"/>
</grid>
</constraints>
<properties/>
</component>
<component id="cda3" class="javax.swing.JCheckBox" binding="cbCube">
<constraints>
<grid row="4" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<horizontalAlignment value="0"/>
<icon value="icons/NotPick.png"/>
<selectedIcon value="icons/Pick.png"/>
<text value="кубические решётки"/>
<toolTipText value="матрица с одинаковым размером измерений"/>
</properties>
</component>
<component id="a79b8" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="макс. число процессоров"/>
</properties>
</component>
<component id="a6c17" class="javax.swing.JSpinner" binding="sMaxProc">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<minimum-size width="100" height="30"/>
<preferred-size width="100" height="30"/>
<maximum-size width="100" height="30"/>
</grid>
</constraints>
<properties/>
</component>
</children>
</grid>
<grid id="f79b4" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<splitpane position="right"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<splitpane id="bd8be" binding="SC2">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<preferred-size width="200" height="200"/>
</grid>
</constraints>
<properties>
<dividerLocation value="180"/>
<dividerSize value="3"/>
<orientation value="0"/>
</properties>
<border type="none"/>
<children>
<grid id="a9834" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<splitpane position="left"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<toolbar id="4f6a1" binding="flagsTools">
<constraints border-constraint="North"/>
<properties>
<floatable value="false"/>
</properties>
<border type="none"/>
<children>
<component id="566f4" class="javax.swing.JLabel">
<constraints/>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<foreground color="-16777216"/>
<text value="флаги"/>
</properties>
</component>
<component id="79287" class="javax.swing.JButton" binding="bAddFlags">
<constraints/>
<properties>
<borderPainted value="false"/>
<icon value="icons/Menu/Regions.png"/>
<maximumSize width="30" height="30"/>
<minimumSize width="30" height="30"/>
<preferredSize width="30" height="30"/>
<text value=""/>
<toolTipText value="Добавить флаги"/>
</properties>
</component>
<component id="1cb75" class="javax.swing.JButton" binding="bDeleteFlags">
<constraints/>
<properties>
<borderPainted value="false"/>
<icon value="icons/Delete.png"/>
<maximumSize width="30" height="30"/>
<minimumSize width="30" height="30"/>
<preferredSize width="30" height="30"/>
<text value=""/>
<toolTipText value="Удалить флаги"/>
</properties>
</component>
</children>
</toolbar>
<scrollpane id="99ead">
<constraints border-constraint="Center"/>
<properties/>
<border type="none"/>
<children>
<component id="c0373" class="javax.swing.JList" binding="flagsList" custom-create="true">
<constraints/>
<properties/>
</component>
</children>
</scrollpane>
</children>
</grid>
<grid id="b9287" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<splitpane position="right"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<splitpane id="53277" binding="SC3">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<preferred-size width="200" height="200"/>
</grid>
</constraints>
<properties>
<dividerLocation value="85"/>
<dividerSize value="3"/>
<orientation value="0"/>
</properties>
<border type="none"/>
<children>
<grid id="3d5c8" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<splitpane position="right"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<toolbar id="612de" binding="parTools">
<constraints border-constraint="North"/>
<properties>
<floatable value="false"/>
</properties>
<border type="none"/>
<children>
<component id="4a428" class="javax.swing.JLabel">
<constraints/>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<foreground color="-16777216"/>
<text value="usr par"/>
</properties>
</component>
<component id="1d160" class="javax.swing.JButton" binding="bAddPar">
<constraints/>
<properties>
<borderPainted value="false"/>
<icon value="icons/RedAdd.png"/>
<maximumSize width="30" height="30"/>
<minimumSize width="30" height="30"/>
<preferredSize width="30" height="30"/>
<text value=""/>
<toolTipText value="Добавить параметр DVM системы"/>
</properties>
</component>
<component id="61ba8" class="javax.swing.JButton" binding="bDeletePar">
<constraints/>
<properties>
<borderPainted value="false"/>
<icon value="icons/Delete.png"/>
<maximumSize width="30" height="30"/>
<minimumSize width="30" height="30"/>
<preferredSize width="30" height="30"/>
<text value=""/>
<toolTipText value="Удалить параметр DVM системы"/>
</properties>
</component>
</children>
</toolbar>
<scrollpane id="d0f3b">
<constraints border-constraint="Center"/>
<properties/>
<border type="none"/>
<children>
<component id="7cdd5" class="javax.swing.JList" binding="parList" custom-create="true">
<constraints/>
<properties/>
</component>
</children>
</scrollpane>
</children>
</grid>
<grid id="4c856" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<splitpane position="left"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<toolbar id="81953" binding="environmentsTools">
<constraints border-constraint="North"/>
<properties>
<floatable value="false"/>
</properties>
<border type="none"/>
<children>
<component id="cec3c" class="javax.swing.JLabel">
<constraints/>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<foreground color="-16777216"/>
<text value="окружение"/>
</properties>
</component>
<component id="1e835" class="javax.swing.JButton" binding="bAddEnvironments">
<constraints/>
<properties>
<borderPainted value="false"/>
<icon value="icons/Menu/Regions.png"/>
<maximumSize width="30" height="30"/>
<minimumSize width="30" height="30"/>
<preferredSize width="30" height="30"/>
<text value=""/>
<toolTipText value="Добавить набор переменных окружения"/>
</properties>
</component>
<component id="b9e9d" class="javax.swing.JButton" binding="bDeleteEnvironment">
<constraints/>
<properties>
<borderPainted value="false"/>
<icon value="icons/Delete.png"/>
<maximumSize width="30" height="30"/>
<minimumSize width="30" height="30"/>
<preferredSize width="30" height="30"/>
<text value=""/>
<toolTipText value="Удалить переменную окружения"/>
</properties>
</component>
</children>
</toolbar>
<scrollpane id="f94f5">
<constraints border-constraint="Center"/>
<properties/>
<border type="none"/>
<children>
<component id="951ed" class="javax.swing.JList" binding="environmentsList" custom-create="true">
<constraints/>
<properties/>
</component>
</children>
</scrollpane>
</children>
</grid>
</children>
</splitpane>
</children>
</grid>
</children>
</splitpane>
</children>
</grid>
</children>
</splitpane>
</children>
</grid>
</form>

View File

@@ -0,0 +1,106 @@
package TestingSystem.DVM.Configuration.UI;
import Common.Current;
import Common.UI.VisualiserStringList;
import Common.UI.TextField.StyledTextField;
import Common.UI.Windows.Dialog.DialogFields;
import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.Pass_2021;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class ConfigurationFields implements DialogFields {
public JTextField tfName;
public JSpinner sMinDimProc;
public JSpinner sMaxDimProc;
public JSpinner sCompilationMaxtime;
public JSpinner sRunMaxtime;
public JCheckBox cbCube;
public JSpinner sMaxProc;
public JList<String> flagsList;
public JList<String> environmentsList;
public JList<String> parList;
//-
private JPanel content;
private JSplitPane SC1;
private JSplitPane SC2;
private JToolBar flagsTools;
public JButton bAddFlags;
public JButton bDeleteFlags;
private JSplitPane SC3;
private JToolBar parTools;
public JButton bAddPar;
public JButton bDeletePar;
private JToolBar environmentsTools;
public JButton bAddEnvironments;
public JButton bDeleteEnvironment;
@Override
public Component getContent() {
return content;
}
private void createUIComponents() {
// TODO: place custom component creation code here
tfName = new StyledTextField();
//-
flagsList = new VisualiserStringList();
environmentsList = new VisualiserStringList();
parList = new VisualiserStringList();
}
public ConfigurationFields(){
sMinDimProc.setModel(new SpinnerNumberModel(1, 0, 128, 1));
sMaxDimProc.setModel(new SpinnerNumberModel(1, 0, 128, 1));
sMaxProc.setModel(new SpinnerNumberModel(0, 0, 128, 1));
sCompilationMaxtime.setModel(new SpinnerNumberModel(40,
5, 3600, 1
));
sRunMaxtime.setModel(new SpinnerNumberModel(40,
5, 3600, 1
));
bAddFlags.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Pass_2021 pass = Pass_2021.passes.get(PassCode_2021.PickCompilerOptions);
if (pass.Do(Current.getCompiler()))
((VisualiserStringList) flagsList).addElement((String) pass.target);
}
});
bDeleteFlags.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
((VisualiserStringList) flagsList).removeElement(flagsList.getSelectedValue());
}
});
bAddEnvironments.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Pass_2021 pass = Pass_2021.passes.get(PassCode_2021.PickCompilerEnvironmentsForTesting);
if (pass.Do(Current.getCompiler()))
((VisualiserStringList) environmentsList).addElement((String) pass.target);
}
});
bDeleteEnvironment.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
((VisualiserStringList) environmentsList).removeElement(environmentsList.getSelectedValue());
}
});
bDeletePar.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
((VisualiserStringList) parList).removeElement(parList.getSelectedValue());
}
});
bAddPar.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Pass_2021 pass = Pass_2021.passes.get(PassCode_2021.AddDVMParameterForTesting);
if (pass.Do()) {
((VisualiserStringList) parList).addElement((String) pass.target);
}
}
});
}
}

View File

@@ -0,0 +1,51 @@
package TestingSystem.DVM.Tasks;
import Common.Database.DBObject;
import TestingSystem.DVM.Configuration.Configuration;
import TestingSystem.Common.Group.Group;
import TestingSystem.Common.Test.Test;
import com.sun.org.glassfish.gmbal.Description;
import java.util.Vector;
//-
public class TestCompilationTask extends TestTask {
@Description("DEFAULT ''")
public String makefile_text = "";
@Description("DEFAULT ''")
public String test_home = ""; //место где лежит код теста.
@Description("IGNORE")
public Vector<TestRunTask> runTasks = null;
@Override
public Vector<String> pack(int kernels_in) {
Vector<String> res = new Vector<>();
res.add(String.valueOf(id)); //1
res.add(String.valueOf(maxtime)); //2
res.add(String.valueOf(test_id)); //3
res.add(makefile_text.replace("\n", "|")); //4
//игнор аргумента. ядро всегда одно.
return res;
}
public TestCompilationTask() {
}
public TestCompilationTask(Configuration configuration, Group group, Test test, String flags_in) {
super(configuration, group, test, flags_in);
flags = flags_in;
maxtime = configuration.c_maxtime;
}
@Override
public void SynchronizeFields(DBObject src) {
super.SynchronizeFields(src);
TestCompilationTask ct = (TestCompilationTask) src;
makefile_text = ct.makefile_text;
test_home = ct.test_home;
if (ct.runTasks == null) this.runTasks = null;
else {
this.runTasks = new Vector<>();
for (TestRunTask runTask : ct.runTasks) {
this.runTasks.add(new TestRunTask(runTask));
}
}
}
public TestCompilationTask(TestCompilationTask src) {
this.SynchronizeFields(src);
}
}

View File

@@ -0,0 +1,16 @@
package TestingSystem.DVM.Tasks;
import Common.Current;
import Common.Database.DBTable;
public class TestCompilationTasksDBTable extends DBTable<Integer, TestCompilationTask> {
public TestCompilationTasksDBTable() {
super(Integer.class, TestCompilationTask.class);
}
@Override
public String getSingleDescription() {
return "задачи на компиляцию тестов";
}
@Override
public Current CurrentName() {
return Current.TestCompilationTask;
}
}

View File

@@ -0,0 +1,106 @@
package TestingSystem.DVM.Tasks;
import Common.Constants;
import Common.Database.DBObject;
import GlobalData.Tasks.TaskState;
import ProjectData.LanguageName;
import TestingSystem.DVM.Configuration.Configuration;
import TestingSystem.Common.Group.Group;
import TestingSystem.Common.Test.Test;
import com.sun.org.glassfish.gmbal.Description;
import java.util.Vector;
public class TestRunTask extends TestTask {
//не факт что тут нужно переводить на полный интерфейс. достаточно убрать фильтрацию
@Override
public boolean isVisible() {
return TestRunTaskInterface.isVisible(this);
}
//--
public long testcompilationtask_id = Constants.Nan;
public String matrix = "";
@Description("DEFAULT ''")
public String args = "";
public double CleanTime = 0.0;
@Description("DEFAULT 0")
public int progress = 0;
public LanguageName language = LanguageName.fortran;
public int cube = 1;
public int min_dim = 1;
public int max_dim = 1;
public String environments = "";
public String usr_par = "";
public int compilation_maxtime = 40;
public String compilation_output = "";
public String compilation_errors = "";
public TaskState compilation_state = TaskState.Waiting;
public double compilation_time = 0.0;
public String statistic = "";
public String jsonStatistic = "";
public TestRunTask(Configuration configuration,
Group group, Test test,
String matrix_in, String flags_in,
String environments_in,
String par_in) {
super(configuration, group, test, flags_in);
//--------------------------
//инфа о компиляции.
language = group.language;
compilation_maxtime = configuration.c_maxtime;
compilation_output = "";
compilation_errors = "";
compilation_state = TaskState.Waiting;
//инфа о запуске
cube = configuration.cube;
min_dim = configuration.max_dim_proc_count;
max_dim = configuration.max_dim_proc_count;
maxtime = configuration.r_maxtime;
environments = environments_in;
usr_par = par_in;
args = test.args;
//---------
matrix = matrix_in;
}
public TestRunTask() {
}
@Override
public void SynchronizeFields(DBObject src) {
super.SynchronizeFields(src);
TestRunTask rt = (TestRunTask) src;
testcompilationtask_id = rt.testcompilationtask_id;
matrix = rt.matrix;
CleanTime = rt.CleanTime;
progress = rt.progress;
language = rt.language;
cube = rt.cube;
min_dim = rt.min_dim;
max_dim = rt.max_dim;
maxtime = rt.maxtime;
environments = rt.environments;
usr_par = rt.usr_par;
compilation_maxtime = rt.compilation_maxtime;
compilation_output = rt.compilation_output;
compilation_errors = rt.compilation_errors;
compilation_state = rt.compilation_state;
compilation_time = rt.compilation_time;
statistic = rt.statistic;
args = rt.args;
jsonStatistic = rt.jsonStatistic;
}
public TestRunTask(TestRunTask src) {
this.SynchronizeFields(src);
}
//-
@Override
public Vector<String> pack(int kernels_in) {
Vector<String> res = new Vector<>();
res.add(String.valueOf(id)); //1
res.add(String.valueOf(maxtime)); //2
res.add(String.valueOf(testcompilationtask_id)); //3
res.add(matrix); //4
res.add(environments); //5
res.add(usr_par.replace("\n", "|")); //6
res.add(args); //7
res.add(String.valueOf(kernels_in)); //8
return res;
}
}

View File

@@ -0,0 +1,83 @@
package TestingSystem.DVM.Tasks;
import Common.Current;
import Common.Global;
import Common.Utils.StringTemplate;
import GlobalData.Tasks.TaskState;
import javafx.util.Pair;
import java.util.List;
public class TestRunTaskInterface {
public static boolean isVisible(TestRunTask object) {
return
Current.HasTasksPackage() &&
object.taskspackage_id.equals(Current.getTasksPackage().id) &&
Global.testingServer.account_db.testRunTasks.applyFilters(object);
}
public static String getEnvironments(TestRunTask object) {
return object.environments.replace("\n", ";");
}
public static String getUsrPar(TestRunTask object) {
return object.usr_par.replace("\n", ";");
}
//--
public static boolean isCrushedLine(String line) {
return line.contains("RTS err")
|| line.contains("RTS stack trace")
|| line.contains("RTS fatal err")
|| line.contains("SIGEGV")
|| line.contains("There are not enough slots available in the system to satisfy the")
|| line.contains("forrtl: severe")
|| line.contains("invalid pointer")
|| line.contains("forrtl: error");
}
public static boolean isCrushed(List<String> output_lines, List<String> errors_lines) {
return output_lines.stream().anyMatch(TestRunTaskInterface::isCrushedLine) || errors_lines.stream().anyMatch(TestRunTaskInterface::isCrushedLine);
}
public static Pair<TaskState, Integer> analyzeCorrectness(List<String> lines) {
int complete = 0;
int errors = 0;
int total = 0;
for (String s : lines) {
String line = s.toUpperCase();
if (line.contains("COMPLETE")) {
complete++;
total++;
} else if (line.contains("ERROR")) {
errors++;
total++;
}
}
return new Pair<>(
(errors > 0) ? TaskState.DoneWithErrors : ((complete > 0) ? TaskState.Done : TaskState.WrongTestFormat),
(int) ((((double) complete) / total) * 100)
);
}
public static Pair<TaskState, Integer> analyzePerformance(List<String> lines) {
StringTemplate stringTemplate = new StringTemplate("Verification =", "");
for (String line : lines) {
String param = stringTemplate.check_and_get_param(line);
if (param != null) {
switch (param) {
case "SUCCESSFUL":
return new Pair<>(TaskState.Done, 100);
case "UNSUCCESSFUL":
return new Pair<>(TaskState.DoneWithErrors, 0);
default:
break;
}
}
}
return new Pair<>(TaskState.WrongTestFormat, 0);
}
public static double parseCleanTime(String output) {
double res = 0.0;
StringTemplate template = new StringTemplate("Time in seconds =", "");
String p = template.check_and_get_param(output);
try {
if (p != null) res = Double.parseDouble(p);
} catch (Exception ex) {
Global.Log.PrintException(ex);
}
return res;
}
}

View File

@@ -0,0 +1,188 @@
package TestingSystem.DVM.Tasks;
import Common.Current;
import Common.Database.DBTable;
import Common.Database.TableFilter;
import Common.UI.DataSetControlForm;
import Common.UI.Menus_2023.TestRunTasksMenuBar.TestRunTasksMenuBar;
import Common.UI.Menus_2023.VisualiserMenu;
import Common.UI.UI;
import GlobalData.Tasks.TaskState;
import javax.swing.*;
import java.util.Comparator;
import java.util.Vector;
import static Common.UI.Tables.TableRenderers.RendererProgress;
import static Common.UI.Tables.TableRenderers.RendererStatusEnum;
public class TestRunTasksDBTable extends DBTable<Long, TestRunTask> {
public Vector<TableFilter<TestRunTask>> compilationFilters;
public Vector<TableFilter<TestRunTask>> runFilters;
public TestRunTasksDBTable() {
super(Long.class, TestRunTask.class);
//--
if (Current.hasUI()) {
compilationFilters = new Vector<>();
runFilters = new Vector<>();
//--
for (TaskState state : TaskState.values()) {
if (state.isVisible()) {
compilationFilters.add(new TableFilter<TestRunTask>(this, state.getDescription()) {
@Override
protected boolean validate(TestRunTask object) {
return object.compilation_state.equals(state);
}
});
}
}
//--
for (TaskState state : TaskState.values()) {
if (state.isVisible()) {
runFilters.add(new TableFilter<TestRunTask>(this, state.getDescription()) {
@Override
protected boolean validate(TestRunTask object) {
return object.state.equals(state);
}
});
}
}
}
}
public void ResetFiltersCount() {
for (TableFilter<TestRunTask> filter : compilationFilters)
filter.count = 0;
for (TableFilter<TestRunTask> filter : runFilters)
filter.count = 0;
}
public void ShowFiltersCount() {
for (TableFilter<TestRunTask> filter : compilationFilters) {
filter.ShowDescriptionAndCount();
}
for (TableFilter<TestRunTask> filter : runFilters) {
filter.ShowDescriptionAndCount();
}
}
public boolean applyFilters(TestRunTask object) {
for (TableFilter<TestRunTask> filter : compilationFilters)
if (!filter.Validate(object)) return false;
for (TableFilter<TestRunTask> filter : runFilters)
if (!filter.Validate(object)) return false;
return true;
}
@Override
public String getSingleDescription() {
return "задача";
}
@Override
public String getPluralDescription() {
return "задачи";
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this) {
@Override
public boolean hasCheckBox() {
return true;
}
@Override
protected void AdditionalInitColumns() {
columns.get(2).setVisible(false);
columns.get(6).setRenderer(RendererStatusEnum);
columns.get(7).setRenderer(RendererStatusEnum);
columns.get(14).setRenderer(RendererProgress);
}
};
}
@Override
public void mountUI(JPanel content_in) {
super.mountUI(content_in);
//-
TestRunTasksMenuBar menuBar = (TestRunTasksMenuBar) UI.menuBars.get(getClass());
menuBar.DropFilters();
//----
menuBar.addFilters(
new VisualiserMenu("Компиляция", "/icons/Filter.png", true) {
{
for (TableFilter filter : compilationFilters)
add(filter.menuItem);
}
},
new VisualiserMenu("Запуск", "/icons/Filter.png", true) {
{
for (TableFilter filter : runFilters)
add(filter.menuItem);
}
}
);
}
@Override
public String[] getUIColumnNames() {
return new String[]{
"Группа",
"Тест",
"Язык",
"Флаги",
"Сборка",
"Запуск",
"Время компиляции(с)",
"Матрица",
"Окружение",
"usr.par",
"Время выполнения (с)",
"Чистое время (с)",
"Прогресс",
};
}
@Override
public Object getFieldAt(TestRunTask object, int columnIndex) {
switch (columnIndex) {
case 2:
return object.group_description;
case 3:
return object.test_description;
case 4:
return object.language;
case 5:
return object.flags;
case 6:
return object.compilation_state;
case 7:
return object.state;
case 8:
return object.compilation_time;
case 9:
return object.matrix;
case 10:
return TestRunTaskInterface.getEnvironments(object);
case 11:
return TestRunTaskInterface.getUsrPar(object);
case 12:
return object.Time;
case 13:
return object.CleanTime;
case 14:
return object.progress;
default:
return null;
}
}
@Override
public Comparator<TestRunTask> getComparator() {
return (o1, o2) -> -o1.getChangeDate().compareTo(o2.getChangeDate());
}
@Override
public Current CurrentName() {
return Current.TestRunTask;
}
@Override
public void ShowUI() {
ResetFiltersCount();
super.ShowUI();
ShowFiltersCount();
}
@Override
public void ShowUI(Object key) {
ResetFiltersCount();
super.ShowUI(key);
ShowFiltersCount();
}
}

View File

@@ -0,0 +1,99 @@
package TestingSystem.DVM.Tasks;
import Common.Constants;
import Common.Database.DBObject;
import GlobalData.Tasks.TaskState;
import TestingSystem.DVM.Configuration.Configuration;
import TestingSystem.Common.Group.Group;
import TestingSystem.Common.Test.Test;
import TestingSystem.Common.Test.TestType;
import com.sun.org.glassfish.gmbal.Description;
import java.util.Date;
import java.util.Vector;
//тут все поля должны быть текстовыми. никаких ссылок по ид. мало ли, группу удалят
public class TestTask extends DBObject {
@Description("PRIMARY KEY, UNIQUE")
public long id = Constants.Nan;
@Description("DEFAULT ''")
public String taskspackage_id = "";
@Description("DEFAULT -1")
public int group_id = Constants.Nan;
@Description("DEFAULT ''")
public String group_description = ""; //видимое имя группы для юзера
@Description("DEFAULT -1")
public int test_id = Constants.Nan; //ключ - будет генерироваться автоматически.
@Description("DEFAULT ''")
public String test_description = ""; //видимое имя теста для юзера
@Description("DEFAULT ''")
public String flags = "";
@Description("DEFAULT 'Inactive'")
public TaskState state = TaskState.Inactive;
@Description("DEFAULT ''")
public String PID = "";
@Description("DEFAULT 40")
public int maxtime = 40;
@Description("DEFAULT ''")
public String remote_workspace = ""; //вывести. память экономим.
@Description("DEFAULT ''")
public String binary_name = ""; //вывести. имя генерим по ид задачи и матрице.
@Description("DEFAULT 'Default'")
public TestType test_type = TestType.Default;
//результаты-------------------------------
public double Time; //время выполнения.
public long StartDate = 0; //дата начала выполнения
public long ChangeDate = 0;//дата изменения
@Description("DEFAULT ''")
public String output = "";
@Description("DEFAULT ''")
public String errors = "";
//------------------------------------------------------
@Override
public Object getPK() {
return id;
}
public Date getChangeDate() {
return new Date(ChangeDate);
}
//--->>>
@Override
public void SynchronizeFields(DBObject src) {
super.SynchronizeFields(src);
TestTask t = (TestTask) src;
id = t.id;
taskspackage_id = t.taskspackage_id;
group_id = t.group_id;
group_description = t.group_description;
test_id = t.test_id;
test_description = t.test_description;
flags = t.flags;
state = t.state;
PID = t.PID;
maxtime = t.maxtime;
remote_workspace = t.remote_workspace;
binary_name = t.binary_name;
test_type = t.test_type;
Time = t.Time;
StartDate = t.StartDate;
ChangeDate = t.ChangeDate;
output = t.output;
errors = t.errors;
}
public TestTask(TestTask src) {
this.SynchronizeFields(src);
}
public TestTask() {
}
public TestTask(Configuration configuration,
Group group, Test test, String flags_in) {
group_id = group.id;
test_id = test.id;
group_description = group.description;
test_description = test.description;
test_type = group.type;
flags = flags_in;
}
public Vector<String> pack (int kernels){
return null;
}
}

View File

@@ -0,0 +1,83 @@
package TestingSystem.DVM.TasksPackage;
import Common.Database.DBObject;
import Common.Database.nDBObject;
import GlobalData.Machine.MachineType;
import TestingSystem.DVM.Tasks.TestCompilationTask;
import com.sun.org.glassfish.gmbal.Description;
import java.util.LinkedHashMap;
import java.util.Vector;
public class TasksPackage extends nDBObject {
public String pid=""; //сишная часть.
public String summary = "";
//---
public String dvm_version = "?";
public String dvm_drv = "";
//---
public String machine_name = "";
public String machine_address = "";
public int machine_port = 22;
public MachineType machine_type;
public String user_name = "";
public String user_password;
public String user_workspace;
//---
public int compilationTasksCount = 0;
public int runTasksCount = 0;
public int needsEmail = 0;
//---
public double Time; //время выполнения.
public long StartDate = 0; //дата начала выполнения
public long ChangeDate = 0;//дата окончания выполнения
//-
@Description("DEFAULT 1")
public int kernels = 1;
//-
public TasksPackageState state = TasksPackageState.Queued;
//--
//нужно только для публикации задач.
public LinkedHashMap<Integer, LinkedHashMap<Integer, Vector<TestCompilationTask>>> sorted_tasks = new LinkedHashMap<>();
@Override
public void SynchronizeFields(DBObject src) {
super.SynchronizeFields(src);
TasksPackage tasksPackage = (TasksPackage) src;
pid = tasksPackage.pid;
summary = tasksPackage.summary;
dvm_drv = tasksPackage.dvm_drv;
dvm_version = tasksPackage.dvm_version;
machine_name = tasksPackage.machine_name;
machine_address = tasksPackage.machine_address;
machine_port = tasksPackage.machine_port;
machine_type = tasksPackage.machine_type;
user_name = tasksPackage.user_name;
user_workspace = tasksPackage.user_workspace;
user_password = tasksPackage.user_password;
compilationTasksCount = tasksPackage.compilationTasksCount;
runTasksCount = tasksPackage.runTasksCount;
needsEmail = tasksPackage.needsEmail;
Time = tasksPackage.Time;
StartDate = tasksPackage.StartDate;
ChangeDate = tasksPackage.ChangeDate;
sorted_tasks = new LinkedHashMap<>();
kernels = tasksPackage.kernels;
state = tasksPackage.state;
//-
for (int group_id : tasksPackage.sorted_tasks.keySet()) {
LinkedHashMap<Integer, Vector<TestCompilationTask>> src_groupTasks = tasksPackage.sorted_tasks.get(group_id);
LinkedHashMap<Integer, Vector<TestCompilationTask>> dst_groupTasks = new LinkedHashMap<>();
for (int test_id : src_groupTasks.keySet()) {
Vector<TestCompilationTask> src_testTasks = src_groupTasks.get(test_id);
Vector<TestCompilationTask> dst_testTasks = new Vector<>();
for (TestCompilationTask src_testCompilationTask : src_testTasks)
dst_testTasks.add(new TestCompilationTask(src_testCompilationTask));
dst_groupTasks.put(test_id, dst_testTasks);
}
sorted_tasks.put(group_id, dst_groupTasks);
}
}
public TasksPackage(TasksPackage src) {
this.SynchronizeFields(src);
}
public TasksPackage() {
}
}

View File

@@ -0,0 +1,100 @@
package TestingSystem.DVM.TasksPackage;
import Common.Current;
import Common.Database.*;
import Common.UI.DataSetControlForm;
import Common.UI.UI;
import TestingSystem.DVM.Tasks.TestRunTask;
import java.util.Date;
import java.util.LinkedHashMap;
import static Common.UI.Tables.TableRenderers.RendererDate;
import static Common.UI.Tables.TableRenderers.RendererStatusEnum;
public class TasksPackageDBTable extends DBTable<String, TasksPackage> {
public TasksPackageDBTable() {
super(String.class, TasksPackage.class);
}
@Override
public Current CurrentName() {
return Current.TasksPackage;
}
@Override
public String getSingleDescription() {
return "пакет задач";
}
@Override
public String getPluralDescription() {
return "пакеты задач";
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this) {
@Override
public boolean hasCheckBox() {
return true;
}
@Override
protected void AdditionalInitColumns() {
columns.get(0).setVisible(false);
columns.get(7).setRenderer(RendererDate);
columns.get(8).setRenderer(RendererDate);
columns.get(9).setRenderer(RendererStatusEnum);
}
@Override
public void ShowCurrentObject() throws Exception {
super.ShowCurrentObject();
UI.getMainWindow().getTestingWindow().DropTestRunTasksComparison();
}
@Override
public void ShowNoCurrentObject() throws Exception {
super.ShowNoCurrentObject();
UI.getMainWindow().getTestingWindow().DropTestRunTasksComparison();
}
};
}
@Override
public String[] getUIColumnNames() {
return new String[]{
"Машина",
"Пользователь",
"DVM",
"Задач",
"Ядер",
"Начало",
"Изменено",
"Статус"
};
}
@Override
public Object getFieldAt(TasksPackage object, int columnIndex) {
switch (columnIndex) {
case 2:
return object.machine_address + ":" + object.machine_port;
case 3:
return object.user_name;
case 4:
return object.dvm_version;
case 5:
return object.runTasksCount;
case 6:
return object.kernels;
case 7:
return new Date(object.StartDate);
case 8:
return new Date(object.ChangeDate);
case 9:
return object.state;
default:
return null;
}
}
@Override
public LinkedHashMap<Class<? extends DBObject>, FKBehaviour> getFKDependencies() {
LinkedHashMap<Class<? extends DBObject>, FKBehaviour> res = new LinkedHashMap<>();
res.put(TestRunTask.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
return res;
}
}

View File

@@ -0,0 +1,88 @@
package TestingSystem.DVM.TasksPackage;
import Common.Current;
import Common.UI.StatusEnum;
import Common.UI.Themes.VisualiserFonts;
import java.awt.*;
public enum TasksPackageState implements StatusEnum {
Queued,
TestsSynchronize, //оставить.
PackageWorkspaceCreation,
PackageStart,
//
CompilationWorkspacesCreation,
CompilationPreparation,
CompilationExecution,
//-
RunningWorkspacesCreation,
RunningPreparation,
RunningExecution,
//--
RunningEnd, //скачка архива
Cleaning, //todo удаление папки пакета на удаленной машине. пока отладки ради не делать.
//---------------------------------------
Analysis,
Done,
Aborted;
public boolean isActive() {
switch (this) {
case Done:
case Aborted:
return false;
default:
return true;
}
}
@Override
public Font getFont() {
switch (this) {
case TestsSynchronize:
case Analysis:
return Current.getTheme().Fonts.get(VisualiserFonts.BlueState);
case CompilationExecution:
case RunningExecution:
return Current.getTheme().Fonts.get(VisualiserFonts.ProgressState);
case Done:
return Current.getTheme().Fonts.get(VisualiserFonts.GoodState);
default:
return StatusEnum.super.getFont();
}
}
//-
public String getDescription() {
switch (this) {
case Aborted:
return "Прерван";
case Queued:
return "в очереди";
case TestsSynchronize:
return "синхронизация тестов";
case PackageWorkspaceCreation:
return "создание рабочей папки пакета";
case PackageStart:
return "старт пакета";
case CompilationWorkspacesCreation:
return "создание рабочих папок компиляции";
case CompilationPreparation:
return "подготовка к компиляции";
case CompilationExecution:
return "компиляция";
case RunningWorkspacesCreation:
return "создание рабочих папок для запуска";
case RunningPreparation:
return "подготовка к запуску";
case RunningExecution:
return "запуск";
case RunningEnd:
return "загрузка результатов";
case Analysis:
return "анализ результатов";
case Cleaning:
return "очистка";
case Done:
return "завершен";
default:
return StatusEnum.super.getDescription();
}
}
}

View File

@@ -0,0 +1,321 @@
package TestingSystem.DVM;
import Common.Constants;
import Common.Global;
import Common.Utils.Utils;
import GlobalData.RemoteFile.RemoteFile;
import GlobalData.Tasks.TaskState;
import Repository.Server.ServerCode;
import TestingSystem.DVM.Tasks.TestCompilationTask;
import TestingSystem.DVM.Tasks.TestRunTask;
import TestingSystem.DVM.Tasks.TestRunTaskInterface;
import TestingSystem.DVM.Tasks.TestTask;
import TestingSystem.DVM.TasksPackage.TasksPackage;
import TestingSystem.DVM.TasksPackage.TasksPackageState;
import TestingSystem.Common.Test.TestType;
import TestingSystem.Common.TestingPlanner;
import com.jcraft.jsch.ChannelSftp;
import javafx.util.Pair;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.nio.charset.Charset;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Vector;
public class TestsSupervisor_2022 {
protected TestingPlanner planner; //планировщик.
protected UserConnection connection;
protected TasksPackage tasksPackage;
protected RemoteFile packageRemoteWorkspace;
protected File packageLocalWorkspace;
protected Vector<TestCompilationTask> compilationTasks; //список задач на компиляцию
protected int count = 0; //число активных задач.
//----
public TestsSupervisor_2022(TestingPlanner planner_in, UserConnection connection_in, TasksPackage tasksPackage_in, Vector<TestCompilationTask> tasks_in) {
planner = planner_in;
connection = connection_in;
tasksPackage = tasksPackage_in;
compilationTasks = tasks_in;
planner.Print(getClass().getSimpleName() + ": найдено задач на компиляцию: " + compilationTasks.size());
packageRemoteWorkspace = new RemoteFile(tasksPackage.user_workspace + "/tests", tasksPackage.id, true);
packageLocalWorkspace = Paths.get(Global.PackagesDirectory.getAbsolutePath(), tasksPackage.id).toFile();
}
public boolean packageNeedsKill() throws Exception{
return (boolean) planner.ServerCommand(ServerCode.CheckPackageToKill,tasksPackage.id);
}
public void Perform() throws Exception {
if (packageNeedsKill()){
System.out.println("PACKAGE "+tasksPackage.id+" NEEDS TO KILL");
if (!tasksPackage.pid.isEmpty()) {
connection.ShellCommand("kill -9 " + tasksPackage.pid);
}
tasksPackage.state = TasksPackageState.Aborted;
planner.UpdatePackage();
}else {
switch (tasksPackage.state) {
case TestsSynchronize:
TestsSynchronize();
tasksPackage.state = TasksPackageState.PackageWorkspaceCreation;
planner.UpdatePackage();
break;
case PackageWorkspaceCreation:
PackageWorkspaceCreation();
tasksPackage.state = TasksPackageState.PackageStart;
planner.UpdatePackage();
break;
case PackageStart:
PackageStart();
tasksPackage.state = TasksPackageState.CompilationWorkspacesCreation;
planner.UpdatePackage();
break;
case CompilationWorkspacesCreation:
case CompilationPreparation:
case CompilationExecution:
case RunningWorkspacesCreation:
case RunningPreparation:
case RunningExecution:
checkNextState();
break;
case RunningEnd:
DownloadResults();
tasksPackage.state = TasksPackageState.Analysis;
planner.UpdatePackage();
break;
case Analysis:
AnalyseResults();
tasksPackage.state = TasksPackageState.Done;
planner.UpdatePackage();
break;
default:
break;
}
}
}
private void TestsSynchronize() throws Exception {
//1, получить набор уникальных тестов.
Vector<String> test_ids = new Vector<>();
for (TestCompilationTask current_task : compilationTasks)
if (!test_ids.contains(current_task.test_id))
test_ids.add(String.valueOf(current_task.test_id));
//синхронизировать их.
for (String test_id : test_ids) {
File test_src = Paths.get(Global.TestsDirectory.getAbsolutePath(), test_id).toFile();
RemoteFile test_dst = new RemoteFile(tasksPackage.user_workspace + "/projects/" + test_id, true);
connection.MKDIR(test_dst);
connection.SynchronizeSubDirsR(test_src, test_dst);
}
}
private void PackageWorkspaceCreation() throws Exception {
//создать папку для пакета.
connection.sftpChannel.mkdir(packageRemoteWorkspace.full_name);
//положить туда запакованные тексты задач.
Vector<String> compilationLines = new Vector<>();
Vector<String> runLines = new Vector<>();
for (TestCompilationTask compilationTask : planner.packageTasks.values()) {
compilationLines.addAll(compilationTask.pack(1));
for (TestRunTask runTask : compilationTask.runTasks) {
int rt_kernels = (runTask.test_type == TestType.Performance) ? tasksPackage.kernels :
Math.min(Utils.getMatrixProcessors(runTask.matrix), tasksPackage.kernels);
runLines.addAll(runTask.pack(rt_kernels));
}
}
RemoteFile compilationPackage = new RemoteFile(packageRemoteWorkspace, "compilationTasks");
RemoteFile runPackage = new RemoteFile(packageRemoteWorkspace, "runTasks");
connection.writeToFile(String.join("\n", compilationLines) + "\n", compilationPackage);
connection.writeToFile(String.join("\n", runLines) + "\n", runPackage);
// --
connection.MKDIR(new RemoteFile(packageRemoteWorkspace, "state"));
}
private void PackageStart() throws Exception {
String plannerStartCommand =
String.join(" ",
"nohup",
Utils.DQuotes(planner.getPlanner()),
Utils.DQuotes(tasksPackage.user_workspace),
Utils.DQuotes(packageRemoteWorkspace.full_name),
Utils.DQuotes(tasksPackage.kernels),
Utils.DQuotes(tasksPackage.dvm_drv),
"&"
);
connection.ShellCommand(plannerStartCommand);
RemoteFile PID = new RemoteFile(packageRemoteWorkspace, "PID");
while (!connection.Exists(packageRemoteWorkspace.full_name, "STARTED")){
System.out.println("waiting for package start...");
Utils.sleep(1000);
}
if (connection.Exists(packageRemoteWorkspace.full_name, "PID")){
tasksPackage.pid = connection.readFromFile(PID);
}
}
public void checkNextState() throws Exception {
TasksPackageState oldState = tasksPackage.state;
Vector<ChannelSftp.LsEntry> files_ = connection.sftpChannel.ls(packageRemoteWorkspace.full_name + "/state");
Vector<ChannelSftp.LsEntry> files = new Vector<>();
for (ChannelSftp.LsEntry file : files_) {
try {
TasksPackageState.valueOf(file.getFilename());
files.add(file);
} catch (Exception ignore) {
}
}
files.sort(Comparator.comparingInt(o -> o.getAttrs().getMTime()));
if (!files.isEmpty()) {
String fileName = files.get(files.size() - 1).getFilename();
System.out.println(fileName + " last file");
tasksPackage.state = TasksPackageState.valueOf(files.get(files.size() - 1).getFilename());
if (tasksPackage.state != oldState)
planner.UpdatePackage();
}
}
public void DownloadResults() throws Exception {
Utils.CheckDirectory(packageLocalWorkspace);
for (TestCompilationTask testCompilationTask : compilationTasks) {
//------------>>>
if (TryDownloadTask(testCompilationTask)) {
for (TestRunTask testRunTask : testCompilationTask.runTasks) {
TryDownloadTask(testRunTask);
}
}else {
//задача на компиляцию не состоялась. значит и все ее задачи на запуск тоже.
for (TestRunTask testRunTask : testCompilationTask.runTasks) {
testRunTask.state = TaskState.Canceled;
planner.UpdateTask(testRunTask);
}
}
//--->>>>>>>>>
}
}
public boolean TryDownloadTask(TestTask testTask) throws Exception {
if (
!testTask.state.equals(TaskState.ResultsDownloaded) &&
!testTask.state.equals(TaskState.Canceled)
) {
File taskLocalWorkspace = Paths.get(packageLocalWorkspace.getAbsolutePath(), String.valueOf(testTask.id)).toFile();
RemoteFile taskRemoteWorkspace = new RemoteFile(packageRemoteWorkspace.full_name, String.valueOf(testTask.id));
Utils.CheckDirectory(taskLocalWorkspace);
if (connection.Exists(packageRemoteWorkspace.full_name, String.valueOf(testTask.id))) {
CheckTaskFile(taskRemoteWorkspace, taskLocalWorkspace, Constants.out_file);
CheckTaskFile(taskRemoteWorkspace, taskLocalWorkspace, Constants.err_file);
CheckTaskFile(taskRemoteWorkspace, taskLocalWorkspace, Constants.time_file);
CheckTaskFile(taskRemoteWorkspace, taskLocalWorkspace, "TaskState");
if (testTask instanceof TestRunTask)
CheckTaskFile(taskRemoteWorkspace, taskLocalWorkspace, "sts.gz+");
testTask.state = TaskState.ResultsDownloaded;
planner.UpdateTask(testTask);
return true;
} else {
testTask.state = TaskState.Canceled;
planner.UpdateTask(testTask);
return false;
//нет раб пространства. значит задача не выполнялась.
}
} else return true;
}
public void CheckTaskFile(RemoteFile taskRemoteWorkspace, File taskLocalWorkspace, String fileName) throws Exception {
RemoteFile rFile = new RemoteFile(taskRemoteWorkspace.full_name, fileName);
File lFile = Paths.get(taskLocalWorkspace.getAbsolutePath(), fileName).toFile();
if (connection.Exists(taskRemoteWorkspace.full_name, fileName)) {
connection.getSingleFile(rFile, lFile, 0);
}
}
public void AnalyseResults() throws Exception {
System.out.println("analysing results");
int ct_count = 0;
int rt_count = 0;
for (TestCompilationTask testCompilationTask : compilationTasks) {
ct_count++;
if (CheckTask(testCompilationTask)) {
planner.UpdateTask(testCompilationTask);
for (TestRunTask testRunTask : testCompilationTask.runTasks) {
rt_count++;
testRunTask.compilation_state = testCompilationTask.state;
testRunTask.compilation_output = testCompilationTask.output;
testRunTask.compilation_errors = testCompilationTask.errors;
if (testCompilationTask.state == TaskState.DoneWithErrors) {
testRunTask.state = TaskState.Canceled;
} else {
CheckTask(testRunTask);
}
planner.UpdateTask(testRunTask);
if (testRunTask.state.equals(TaskState.Finished)) {
//анализ задачи на запуск.
List<String> output_lines = Arrays.asList(testRunTask.output.split("\n"));
List<String> errors_lines = Arrays.asList(testRunTask.errors.split("\n"));
//---
if (TestRunTaskInterface.isCrushed(output_lines, errors_lines)) {
testRunTask.state = TaskState.Crushed;
} else {
Pair<TaskState, Integer> results = new Pair<>(TaskState.Done, 100);
switch (testRunTask.test_type) {
case Correctness:
results = TestRunTaskInterface.analyzeCorrectness(output_lines);
break;
case Performance:
results = TestRunTaskInterface.analyzePerformance(output_lines);
break;
default:
break;
}
testRunTask.state = results.getKey();
testRunTask.progress = results.getValue();
testRunTask.CleanTime = TestRunTaskInterface.parseCleanTime(testRunTask.output);
}
File local_sts_text = Utils.getTempFileName("sts_text");
Vector<ChannelSftp.LsEntry> files = connection.sftpChannel.ls(testRunTask.remote_workspace);
for (ChannelSftp.LsEntry file : files) {
if (file.getFilename().equals("sts.gz+")) {
RemoteFile remote_sts = new RemoteFile(
testRunTask.remote_workspace, file.getFilename(), false);
RemoteFile remote_sts_text = new RemoteFile(
testRunTask.remote_workspace, "statistic.txt", false);
try {
connection.ShellCommand(Utils.DQuotes(tasksPackage.dvm_drv) + " pa " +
Utils.DQuotes(remote_sts.full_name) + " " + Utils.DQuotes(remote_sts_text.full_name));
connection.getSingleFile(remote_sts_text, local_sts_text, 10240);
} catch (Exception ex) {
ex.printStackTrace();
}
if (local_sts_text.exists()) {
try {
testRunTask.statistic = FileUtils.readFileToString(local_sts_text, Charset.defaultCharset());
} catch (Exception e) {
e.printStackTrace();
}
}
break;
}
}
}
planner.UpdateTask(testRunTask);
}
}
}
System.out.println("ct_count=" + ct_count + " rt count=" + rt_count);
}
public boolean CheckTask(TestTask testTask) throws Exception {
if (testTask.state.equals(TaskState.ResultsDownloaded)) {
File taskWorkspace = Paths.get(packageLocalWorkspace.getAbsolutePath(), String.valueOf(testTask.id)).toFile();
System.out.println("id=" + testTask.id + ": path=" + taskWorkspace.getAbsolutePath());
File stateFile = Paths.get(taskWorkspace.getAbsolutePath(), "TaskState").toFile();
File outFile = Paths.get(taskWorkspace.getAbsolutePath(), Constants.out_file).toFile();
File errFile = Paths.get(taskWorkspace.getAbsolutePath(), Constants.err_file).toFile();
File timeFile = Paths.get(taskWorkspace.getAbsolutePath(), Constants.time_file).toFile();
if (outFile.exists())
testTask.output = FileUtils.readFileToString(outFile);
if (errFile.exists())
testTask.errors = FileUtils.readFileToString(errFile);
if (timeFile.exists())
testTask.Time = Double.parseDouble(Utils.ReadAllText(timeFile));
if (stateFile.exists()) {
String stateText = FileUtils.readFileToString(stateFile, Charset.defaultCharset()).replace("\n", "");
testTask.state = TaskState.valueOf(stateText);
} else testTask.state = TaskState.InternalError; //поменять на то что состояние не найдено. ?
return true;
}
return false;
}
}

View File

@@ -0,0 +1,228 @@
package TestingSystem.DVM;
import Common.Constants;
import Common.Global;
import Common.Utils.Utils;
import Common.Utils.Validators.ShellParser;
import GlobalData.Machine.Machine;
import GlobalData.RemoteFile.RemoteFile;
import GlobalData.User.User;
import Visual_DVM_2021.Passes.PassException;
import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.ChannelShell;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.LinkedHashMap;
import java.util.Vector;
public class UserConnection {
public ChannelSftp sftpChannel = null;
public ChannelShell shellChannel = null;
//--
JSch jsch = null;
Session session = null;
//---
PipedInputStream in = null;
PipedOutputStream out = null;
//---
PipedOutputStream pin = null;
PipedInputStream pout = null;
InputStreamReader fromServer = null;
//---
public UserConnection(Machine machine, User user) throws Exception {
session = (jsch = new JSch()).getSession(user.login, machine.address, machine.port);
session.setPassword(user.password);
session.setConfig("StrictHostKeyChecking", "no");
session.connect(0);
//-->
//создать канал для файлов
sftpChannel = (ChannelSftp) session.openChannel("sftp");
sftpChannel.connect();
//-->
//создать канал для команд
shellChannel = (ChannelShell) session.openChannel("shell");
in = new PipedInputStream();
out = new PipedOutputStream();
shellChannel.setInputStream(in);
shellChannel.setOutputStream(out);
pin = new PipedOutputStream(in);
pout = new PipedInputStream(out);
shellChannel.connect();
//-
fromServer = new InputStreamReader(pout);
ShellParser.setUserName(user.login);
ShellParser.ReadInvitation(fromServer); //прочитать первое приглашение от машины.
}
public void Disconnect() {
if (in != null) {
try {
in.close();
} catch (Exception exception) {
Global.Log.PrintException(exception);
}
}
if (out != null) {
try {
out.close();
} catch (Exception exception) {
Global.Log.PrintException(exception);
}
}
if (pin != null) {
try {
pin.close();
} catch (Exception exception) {
Global.Log.PrintException(exception);
}
}
if (pout != null) {
try {
pout.close();
} catch (Exception exception) {
Global.Log.PrintException(exception);
}
}
if (fromServer != null) {
try {
fromServer.close();
} catch (Exception exception) {
Global.Log.PrintException(exception);
}
}
if (sftpChannel != null) sftpChannel.disconnect();
if (shellChannel != null) shellChannel.disconnect();
if (session != null) session.disconnect();
//----------------------
sftpChannel = null;
shellChannel = null;
jsch = null;
session = null;
//---
in = null;
out = null;
//---
pin = null;
pout = null;
fromServer = null;
System.gc();
}
//--
//из за мусора результатом пользоваться в общем случае невозможно.
public String ShellCommand(String command) throws Exception {
StringBuilder result = new StringBuilder();
// System.out.println("command=" + Utils.Brackets(command));
pin.write((command + "\r\n").getBytes());
ShellParser.ReadInvitation(fromServer); //первое приглашение после эхо. возможен мусор.
result.append(ShellParser.getCommandResult(fromServer)); //возможный результат и второе приглашение.
// System.out.println("answer=" + Utils.Brackets(result));
//в реалиях визуалиазтора нас интересует только ПОСЛЕДНЯЯ СТРОКА ОТВЕТА.
String[] data = result.toString().split("\n");
// System.out.println("res="+Utils.Brackets(res));
return (data.length > 0) ? data[data.length - 1] : result.toString();
}
//--
//тут имя файла короткое.
public boolean Exists(String folder, String name) throws Exception {
Vector<ChannelSftp.LsEntry> files = sftpChannel.ls(folder);
for (ChannelSftp.LsEntry file : files) {
file.getAttrs().getSize();
if (file.getFilename().equals(name)) {
return true;
}
}
return false;
}
//--
public void getSingleFile(String src, String dst) throws Exception {
sftpChannel.get(src, dst);
}
public long getFileKBSize(String path) throws Exception{
long size = sftpChannel.lstat(path).getSize();
return size/1024;
}
public boolean getSingleFile(RemoteFile src, File dst, int maxSize) throws Exception {
if (Exists(src.parent, src.name)) {
if ((maxSize == 0) || getFileKBSize(src.full_name) <= maxSize) {
getSingleFile(src.full_name, dst.getAbsolutePath());
return true;
} else {
Utils.WriteToFile(dst, "Размер файла превышает " + maxSize + " KB.\n" + "Файл не загружен. Его можно просмотреть на машине по адресу\n" + Utils.Brackets(src.full_name));
}
}
return false;
}
public void putSingleFile(File src, RemoteFile dst) throws Exception {
sftpChannel.put(src.getAbsolutePath(), dst.full_name);
}
//-
public void MKDIR(RemoteFile dir) throws Exception {
if (!Exists(dir.parent, dir.name)) sftpChannel.mkdir(dir.full_name);
}
//-
public void RMDIR(String dir) throws Exception {
if (!dir.isEmpty() && !dir.equals("/") && !dir.equals("\\") && !dir.equals("*")) {
ShellCommand("rm -rf " + Utils.DQuotes(dir));
} else throw new PassException("Недопустимый путь для удаления папки " + Utils.DQuotes(dir));
}
//-
public void SynchronizeSubDirsR(File local_dir, RemoteFile remote_dir) throws Exception {
File[] local_subdirs = local_dir.listFiles(File::isDirectory);
File[] local_files = local_dir.listFiles(File::isFile);
//------------------------------------------------------------------------
LinkedHashMap<String, RemoteFile> remote_subdirs = new LinkedHashMap<>();
LinkedHashMap<String, RemoteFile> remote_files = new LinkedHashMap<>();
Vector<ChannelSftp.LsEntry> files = sftpChannel.ls(remote_dir.full_name);
for (ChannelSftp.LsEntry file : files) {
if (file.getAttrs().isDir()) {
if (!file.getFilename().equals(".") && !file.getFilename().equals(".."))
remote_subdirs.put(file.getFilename(), new RemoteFile(remote_dir.full_name, file.getFilename(), true));
} else {
RemoteFile rf = new RemoteFile(remote_dir.full_name, file.getFilename());
rf.updateTime = RemoteFile.convertUpdateTime(file.getAttrs().getMTime());
remote_files.put(file.getFilename(), rf);
}
}
if (local_subdirs != null) {
for (File lsd : local_subdirs) {
if (!lsd.getName().equals(Constants.data)) {
RemoteFile rsd = null;
if (!remote_subdirs.containsKey(lsd.getName()))
sftpChannel.mkdir((rsd = new RemoteFile(remote_dir.full_name, lsd.getName(), true)).full_name);
else rsd = remote_subdirs.get(lsd.getName());
SynchronizeSubDirsR(lsd, rsd);
}
}
}
if (local_files != null) {
for (File lf : local_files) {
RemoteFile rf = null;
if (!remote_files.containsKey(lf.getName())) {
rf = new RemoteFile(remote_dir.full_name, lf.getName());
putSingleFile(lf, rf);
} else {
rf = remote_files.get(lf.getName());
if (lf.lastModified() > rf.updateTime) {
putSingleFile(lf, rf);
}
}
}
}
}
/*
public void copy(RemoteFile src, RemoteFile dst) throws Exception {
ShellCommand("cp " + Utils.DQuotes(src.full_name) + " " + Utils.DQuotes(dst.full_name));
}
*/
//-------
public void writeToFile(String text, RemoteFile dst) throws Exception {
sftpChannel.put(new ByteArrayInputStream(text.getBytes(StandardCharsets.UTF_8)), dst.full_name);
sftpChannel.chmod(0777, dst.full_name);
}
public String readFromFile(RemoteFile src) throws Exception {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
sftpChannel.get(src.full_name, outputStream);
return outputStream.toString(StandardCharsets.UTF_8.name());
}
}

View File

@@ -0,0 +1,15 @@
package TestingSystem.SAPFOR.Json;
import Common.Constants;
import Visual_DVM_2021.Passes.PassCode_2021;
import com.google.gson.annotations.Expose;
import java.util.List;
import java.util.Vector;
public class SapforConfiguration_json {
@Expose
public int id = Constants.Nan;
@Expose
public String flags = "";
@Expose
public List<PassCode_2021> codes = new Vector<>();
}

View File

@@ -0,0 +1,15 @@
package TestingSystem.SAPFOR.Json;
import com.google.gson.annotations.Expose;
import java.util.List;
import java.util.Vector;
public class SapforTasksPackage_json {
@Expose
public int kernels = 1;
@Expose
public String sapfor_drv = ""; //файл с сапфором. Имя уникально для сценария.
@Expose
public List<SapforTest_json> tests = new Vector<>();
@Expose
public List<SapforConfiguration_json> configurations = new Vector<>();
}

View File

@@ -0,0 +1,266 @@
package TestingSystem.SAPFOR.Json;
import Common.Utils.Utils;
import GlobalData.Tasks.TaskState;
import TestingSystem.SAPFOR.SapforTask.MatchState;
import TestingSystem.SAPFOR.SapforTask.SapforTask;
import TestingSystem.SAPFOR.SapforTasksPackage.SapforTasksPackage;
import TestingSystem.SAPFOR.SapforTasksPackage.UI.*;
import com.google.gson.annotations.Expose;
import javax.swing.tree.DefaultMutableTreeNode;
import java.io.File;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Vector;
public class SapforTasksResults_json {
//---
public PackageSummary root = null;
public PackageSummary comparison_root = null;
//---
@Expose
public long StartDate = 0;
@Expose
public long EndDate = 0;
@Expose
public List<SapforTask> tasks = new Vector<>();
//все задачи по ключам.
public LinkedHashMap<String, SapforTask> allTasks = new LinkedHashMap<>();
public LinkedHashMap<TaskState, LinkedHashMap<Integer, LinkedHashMap<String, Vector<SapforTask>>>> sortedTasks = new LinkedHashMap<>();
//-- задачи, отсортированные для сравнения.
public LinkedHashMap<MatchState, LinkedHashMap<TaskState, LinkedHashMap<Integer, LinkedHashMap<String, Vector<SapforTask>>>>> comparisonSortedTasks = new LinkedHashMap<>();
//----
public void buildTree(SapforTasksPackage package_in) {
root = new PackageSummary();
//---
for (TaskState state : sortedTasks.keySet()) {
//--
StateSummary stateSummary = new StateSummary(state);
//--
LinkedHashMap<Integer, LinkedHashMap<String, Vector<SapforTask>>> tasksByConfigurations = sortedTasks.get(state);
for (int configuration_id : tasksByConfigurations.keySet()) {
//--
DefaultMutableTreeNode configurationNode = null;
//--
LinkedHashMap<String, Vector<SapforTask>> groups_tasks = tasksByConfigurations.get(configuration_id);
for (String group : groups_tasks.keySet()) {
//--
GroupSummary groupSummary = new GroupSummary(group);
//--
for (SapforTask task : groups_tasks.get(group)) {
//--
stateSummary.count++;
root.count++;
//--
if (configurationNode == null) {
configurationNode = new ConfigurationSummary(configuration_id, task);
}
//--
groupSummary.add(task.getVersionsTree(new File(package_in.getLocalWorkspace(), String.valueOf(configuration_id))));
}
if (configurationNode != null)
configurationNode.add(groupSummary);
}
stateSummary.add(configurationNode);
}
if (stateSummary.count > 0) {
root.add(stateSummary);
}
}
}
public void buildComparisonTree(SapforTasksPackage package_in) {
comparison_root = new PackageSummary();
for (MatchState match_state : comparisonSortedTasks.keySet()) {
//--
MatchesSummary matchesSummary = new MatchesSummary(match_state);
//---
LinkedHashMap<TaskState, LinkedHashMap<Integer, LinkedHashMap<String, Vector<SapforTask>>>> task_states = comparisonSortedTasks.get(match_state);
//---
for (TaskState state : task_states.keySet()) {
//--
StateSummary stateSummary = new StateSummary(state);
//--
LinkedHashMap<Integer, LinkedHashMap<String, Vector<SapforTask>>> tasksByConfigurations = task_states.get(state);
for (int configuration_id : tasksByConfigurations.keySet()) {
//--
DefaultMutableTreeNode configurationNode = null;
//--
LinkedHashMap<String, Vector<SapforTask>> groups_tasks = tasksByConfigurations.get(configuration_id);
for (String group : groups_tasks.keySet()) {
//--
GroupSummary groupSummary = new GroupSummary(group);
//--
for (SapforTask task : groups_tasks.get(group)) {
//--
stateSummary.count++;
matchesSummary.count++;
comparison_root.count++;
//--
if (configurationNode == null) {
configurationNode = new ConfigurationSummary(configuration_id, task);
}
//--
groupSummary.add(task.getVersionsTree(new File(package_in.getLocalWorkspace(), String.valueOf(configuration_id))));
}
if (configurationNode != null)
configurationNode.add(groupSummary);
}
stateSummary.add(configurationNode);
}
if (stateSummary.count > 0) {
matchesSummary.add(stateSummary);
}
}
//---
if (matchesSummary.count > 0) {
comparison_root.add(matchesSummary);
}
}
}
//----
public void SortTasks() {
sortedTasks.clear();
//--
for (TaskState state : TaskState.values()) {
LinkedHashMap<Integer, LinkedHashMap<String, Vector<SapforTask>>> configuration_tasks = new LinkedHashMap<>();
sortedTasks.put(state, configuration_tasks);
//--
for (SapforTask task : tasks) {
if (task.state.equals(state)) {
LinkedHashMap<String, Vector<SapforTask>> groups_tasks = null;
if (configuration_tasks.containsKey(task.sapfor_configuration_id)) {
groups_tasks = configuration_tasks.get(task.sapfor_configuration_id);
} else {
groups_tasks = new LinkedHashMap<>();
configuration_tasks.put(task.sapfor_configuration_id, groups_tasks);
}
Vector<SapforTask> tasks_ = null;
if (groups_tasks.containsKey(task.group_description)) {
tasks_ = groups_tasks.get(task.group_description);
} else {
tasks_ = new Vector<>();
groups_tasks.put(task.group_description, tasks_);
}
tasks_.add(task);
}
}
//--
}
//--
for (TaskState state : TaskState.values()) {
LinkedHashMap<Integer, LinkedHashMap<String, Vector<SapforTask>>> configuration_tasks = sortedTasks.get(state);
for (int configuration_id : configuration_tasks.keySet()) {
LinkedHashMap<String, Vector<SapforTask>> groups_tasks = configuration_tasks.get(configuration_id);
for (String group : groups_tasks.keySet()) {
Vector<SapforTask> tasks_ = groups_tasks.get(group);
tasks_.sort(Comparator.comparing(SapforTask::getUniqueKey));
}
}
}
}
public void SortTasksForComparison() {
comparisonSortedTasks.clear();
//раскидать задачи по состояниям, конфигам, группам
for (MatchState matchState : MatchState.values()) {
LinkedHashMap<TaskState, LinkedHashMap<Integer, LinkedHashMap<String, Vector<SapforTask>>>> state_tasks = new LinkedHashMap<>();
comparisonSortedTasks.put(matchState, state_tasks);
//--
for (TaskState state : TaskState.values()) {
LinkedHashMap<Integer, LinkedHashMap<String, Vector<SapforTask>>> configuration_tasks = new LinkedHashMap<>();
state_tasks.put(state, configuration_tasks);
//--
for (SapforTask task : tasks) {
if (task.match.equals(matchState) && task.state.equals(state)) {
LinkedHashMap<String, Vector<SapforTask>> groups_tasks = null;
if (configuration_tasks.containsKey(task.sapfor_configuration_id)) {
groups_tasks = configuration_tasks.get(task.sapfor_configuration_id);
} else {
groups_tasks = new LinkedHashMap<>();
configuration_tasks.put(task.sapfor_configuration_id, groups_tasks);
}
Vector<SapforTask> tasks = null;
if (groups_tasks.containsKey(task.group_description)) {
tasks = groups_tasks.get(task.group_description);
} else {
tasks = new Vector<>();
groups_tasks.put(task.group_description, tasks);
}
tasks.add(task);
}
}
}
//--
}
//рассортировать задачи в группах по ключам.
for (MatchState matchState : MatchState.values()) {
LinkedHashMap<TaskState, LinkedHashMap<Integer, LinkedHashMap<String, Vector<SapforTask>>>> state_tasks = comparisonSortedTasks.get(matchState);
for (TaskState state : TaskState.values()) {
LinkedHashMap<Integer, LinkedHashMap<String, Vector<SapforTask>>> configuration_tasks = state_tasks.get(state);
for (int configuration_id : configuration_tasks.keySet()) {
LinkedHashMap<String, Vector<SapforTask>> groups_tasks = configuration_tasks.get(configuration_id);
for (String group : groups_tasks.keySet()) {
Vector<SapforTask> tasks_ = groups_tasks.get(group);
tasks_.sort(Comparator.comparing(SapforTask::getUniqueKey));
}
}
}
}
}
public void DropComparison() {
comparison_root = null;
comparisonSortedTasks.clear();
for (SapforTask task : allTasks.values())
task.match = MatchState.NotMatch;
}
//---
public String getEmailSummary() {
String res = "";
Vector<String> summary_lines = new Vector<>();
summary_lines.add("Всего задач: " + tasks.size());
for (TaskState state : sortedTasks.keySet()) {
LinkedHashMap<Integer, LinkedHashMap<String, Vector<SapforTask>>> tasksByConfigurations = sortedTasks.get(state);
if (!tasksByConfigurations.isEmpty()) {
int count = 0;
if (!state.equals(TaskState.Done)) {
Vector<String> flagsLines = new Vector<>();
for (int configuration_id : tasksByConfigurations.keySet()) {
LinkedHashMap<String, Vector<SapforTask>> tasksByGroups = tasksByConfigurations.get(configuration_id);
for (String group : tasksByGroups.keySet()) {
Vector<SapforTask> tasks = tasksByGroups.get(group);
flagsLines.add("Группа " + group + ": " + tasks.size());
count += tasks.size();
for (SapforTask task : tasks) {
task.versionsDescription = task.getVersionsChain();
flagsLines.add(
"тест: " +
Utils.Brackets(task.test_description) + " " +
"флаги: "
+ Utils.Brackets(task.flags) + " " +
"версии: " +
task.versionsDescription
// + " " + "конфигурация " + task.sapfor_configuration_id
);
}
}
}
summary_lines.add(state.getDescription() + " :" + count);
summary_lines.addAll(flagsLines);
} else {
for (int configurationId : tasksByConfigurations.keySet()) {
LinkedHashMap<String, Vector<SapforTask>> tasksByGroups = tasksByConfigurations.get(configurationId);
for (String group : tasksByGroups.keySet()) {
Vector<SapforTask> tasks = tasksByGroups.get(group);
for (SapforTask task : tasks)
task.versionsDescription = task.getVersionsChain();
count += tasks.size();
}
}
summary_lines.add(state.getDescription() + " :" + count);
}
}
}
res = String.join("\n", summary_lines);
return res;
}
//---
}

View File

@@ -0,0 +1,8 @@
package TestingSystem.SAPFOR.Json;
import com.google.gson.annotations.Expose;
public class SapforTest_json {
@Expose
public String test_description = "";
@Expose
public String group_description = "";
}

View File

@@ -0,0 +1,287 @@
package TestingSystem.SAPFOR.Json;
import Common.Constants;
import Common.Global;
import Common.Utils.Utils;
import ProjectData.Files.DBProjectFile;
import ProjectData.Files.FileType;
import ProjectData.Files.ProjectFile;
import ProjectData.LanguageName;
import ProjectData.Messages.Errors.MessageError;
import ProjectData.Project.db_project_info;
import TestingSystem.SAPFOR.SapforTask.SapforTask;
import com.google.gson.annotations.Expose;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.Serializable;
import java.nio.charset.Charset;
import java.nio.file.Paths;
import java.util.LinkedHashMap;
import java.util.Vector;
import static java.lang.Character.isDigit;
public class SapforVersion_json implements Serializable {
@Expose
public String version = "";
@Expose
public String description = "";
public boolean success = true;
//поля для отображения деревьев.
public File Home = null;
public LinkedHashMap<String, ProjectFile> files = new LinkedHashMap<>();
//--
public ProjectFile parse_out = null;
public ProjectFile parse_err = null;
public ProjectFile out = null;
public ProjectFile err = null;
//--
public SapforTask task = null; //родная задача. Нужна для построения дерева версий.
public db_project_info project = null;
//--
public SapforVersion_json(String version_in, String description_in) {
version = version_in;
description = description_in;
}
public SapforVersion_json(String root_in, String version_in, String description_in) {
version = version_in.substring(root_in.length() + 1);
description = description_in;
}
@Override
public String toString() {
return Home.getName() + " : " + Utils.Brackets(description);
}
public void init(File configurationRoot) {
String relativePath = Global.isWindows ? Utils.toW(version) : version;
Home = Paths.get(configurationRoot.getAbsolutePath(), relativePath).toFile();
files = new LinkedHashMap<>();
//--
File[] files_ = Home.listFiles();
if (files_ != null) {
for (File file : files_) {
if (file.isFile()) {
ProjectFile projectFile = new ProjectFile(file);
if (!projectFile.fileType.equals(FileType.forbidden)
) {
files.put(projectFile.file.getName(), projectFile);
}
}
}
}
parse_out = new ProjectFile(Paths.get(Home.getAbsolutePath(), Constants.data, Constants.parse_out_file).toFile());
parse_err = new ProjectFile(Paths.get(Home.getAbsolutePath(), Constants.data, Constants.parse_err_file).toFile());
out = new ProjectFile(Paths.get(Home.getAbsolutePath(), Constants.data, Constants.out_file).toFile());
err = new ProjectFile(Paths.get(Home.getAbsolutePath(), Constants.data, Constants.err_file).toFile());
}
public boolean isMatch(SapforVersion_json version_json) {
if (!description.equals(version_json.description)) {
System.out.println("не совпадение описания версии");
return false;
}
if (files.size() != version_json.files.size()) {
System.out.println("не совпадение количества файлов");
return false;
}
for (String name1 : files.keySet()) {
if (!version_json.files.containsKey(name1)) {
System.out.println("Файл " + Utils.Brackets(name1) + " не найден в версии " + version_json.Home);
return false;
}
}
for (String name1 : files.keySet()) {
ProjectFile file1 = files.get(name1);
ProjectFile file2 = version_json.files.get(name1);
//---
String text1 = "";
String text2 = "";
try {
text1 = FileUtils.readFileToString(file1.file, Charset.defaultCharset());
} catch (Exception ex) {
ex.printStackTrace();
}
try {
text2 = FileUtils.readFileToString(file2.file, Charset.defaultCharset());
} catch (Exception ex) {
ex.printStackTrace();
}
if (!text1.equals(text2)) {
System.out.println("различие текста файла " + Utils.Brackets(file1.file.getName()));
return false;
}
}
return true;
}
public MessageError unpackMessage(String line_in) throws Exception {
MessageError res = new MessageError();
res.file = "";
res.line = Constants.Nan;
res.value = "";
String line = line_in.substring(9);
//System.out.println(line);
int i = 0;
int s = 0;
String lexeme = "";
//#1020: red43.fdv: line 988]: Active DVM directives are not supported (turn on DVM-directive support option)
for (char c : line.toCharArray()) {
// System.out.print("<s=" + s + ">");
// System.out.println(c);
switch (s) {
case 0:
//поиск groups_s
if (c == '#') {
s = 1;
lexeme = "";
} else return null;
break;
case 1:
//group_s
if (isDigit(c)) {
res.group_s += c;
lexeme += c;
} else if (c == ':') {
s = 2;
res.group = Integer.parseInt(lexeme);
} else return null;
break;
case 2:
//поиск filename
if (c == ' ') {
s = 3;
} else return null;
break;
case 3:
//filename
if (c == ':') {
s = 4;
} else {
res.file += c;
}
break;
case 4:
//поиск line
if (c == ' ') {
s = 5;
lexeme = "";
} else return null;
break;
case 5:
//line
if (c == ' ') {
if (!lexeme.equals("line"))
return null;
else {
s = 6;
lexeme = "";
}
} else {
lexeme += c;
}
break;
case 6:
//line number
if (isDigit(c)) {
lexeme += c;
} else if (c == ']') {
res.line = Integer.parseInt(lexeme);
s = 7;
} else return null;
break;
case 7:
//Поиск value
if (c == ':') {
s = 8;
} else return null;
break;
case 8:
if (c == ' ') {
s = 9;
} else return null;
break;
case 9:
//value
res.value += c;
break;
}
;
++i;
}
//--
if (s != 9)
return null;
//--
return res;
}
public void readMessagesFromFileDump(File file, Vector<MessageError> messages) {
try {
//Образец запакованного сообщения
//ERROR - [#1020: red43.fdv: line 988]: Active DVM directives are not supported (turn on DVM-directive support option)
Vector<String> lines = new Vector<>(FileUtils.readLines(file));
if (!lines.isEmpty()) {
for (int i = lines.size() - 1; i >= 0; --i) {
String line = lines.get(i);
if (line.startsWith("ERROR - ")) {
MessageError message = unpackMessage(line);
if (message != null)
messages.add(message);
//--
} else break;
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
//--
public void createProject(File rootHome) throws Exception {
project = null;
String version_ = Global.isWindows ? Utils.toW(version) : Utils.toU(version);
project = new db_project_info();
project.Home = Paths.get(rootHome.getAbsolutePath(), version_).toFile();
project.name = project.Home.getName();
project.description = description;
project.languageName = LanguageName.fortran;
project.creationDate = Utils.getDateNumber();
//---
FileUtils.copyDirectory(Home, project.Home);
///--------------------------------------
project.CreateVisualiserData();
}
public void ReadMessages() throws Exception {
if (project != null) {
Vector<MessageError> messages = new Vector<>();
//--
File p_out = Paths.get(project.Home.getAbsolutePath(), Constants.data, Constants.parse_out_file).toFile();
File p_err = Paths.get(project.Home.getAbsolutePath(), Constants.data, Constants.parse_err_file).toFile();
File out = Paths.get(project.Home.getAbsolutePath(), Constants.data, Constants.out_file).toFile();
File err = Paths.get(project.Home.getAbsolutePath(), Constants.data, Constants.err_file).toFile();
//--
if (p_out.exists()) {
project.Log += (FileUtils.readFileToString(p_out));
readMessagesFromFileDump(p_out, messages);
}
if (out.exists()) {
project.Log += "\n" + FileUtils.readFileToString(out);
readMessagesFromFileDump(out, messages);
}
//в потоки ошибок идет информация от операционной системы. сообщений там быть не должно.
if (p_err.exists())
project.Log += (FileUtils.readFileToString(p_err));
if (err.exists())
project.Log += "\n" + FileUtils.readFileToString(err);
//--
project.Open();
project.Update(); //Журнал
//а так же, убрать dep и txt
project.db.BeginTransaction();
for (MessageError m : messages) {
if (project.db.files.containsKey(m.file)) {
DBProjectFile file = project.db.files.Data.get(m.file);
file.CreateAndAddNewMessage(1, m.value, m.line, m.group);
//update file
project.db.Update(file);
}
}
project.db.Commit();
project.db.Disconnect();
}
}
}

View File

@@ -0,0 +1,69 @@
package TestingSystem.SAPFOR;
import Common.Constants;
import Common.Global;
import Common.Utils.Utils;
import TestingSystem.SAPFOR.Json.SapforConfiguration_json;
import TestingSystem.SAPFOR.Json.SapforTasksPackage_json;
import TestingSystem.SAPFOR.Json.SapforTasksResults_json;
import TestingSystem.SAPFOR.Json.SapforTest_json;
import TestingSystem.SAPFOR.SapforTask.SapforTask;
import TestingSystem.Common.TaskThread;
import TestingSystem.Common.ThreadsPlanner.ThreadsPlanner;
import Visual_DVM_2021.Passes.PassCode_2021;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.util.Date;
import java.util.Vector;
public class PackageModeSupervisor extends ThreadsPlanner {
SapforTasksPackage_json package_json = null;
SapforTasksResults_json results_json = new SapforTasksResults_json();
public PackageModeSupervisor() throws Exception {
super(2000);
package_json = (SapforTasksPackage_json) Utils.jsonFromFile(new File(Global.Home, Constants.package_json), SapforTasksPackage_json.class);
Date startDate = new Date();
results_json.StartDate = startDate.getTime();
File started = new File(Constants.STARTED);
FileUtils.writeStringToFile(started, String.valueOf(startDate));
//формирование списка задач.
File sapfor_drv = new File(Global.Home, package_json.sapfor_drv);
setMaxKernels(package_json.kernels);
for (SapforConfiguration_json sapforConfiguration_json : package_json.configurations) {
for (SapforTest_json test : package_json.tests) {
//--- чтобы было можно на нее сослаться после выполнения всех нитей.
SapforTask task = new SapforTask();
task.group_description = test.group_description;
task.test_description = test.test_description;
task.flags = sapforConfiguration_json.flags;
task.sapfor_configuration_id = sapforConfiguration_json.id;
task.sapfortaskspackage_id = Integer.parseInt(new File(Global.Home).getName());
results_json.tasks.add(task);
Vector<String> codes_s = new Vector<>();
for (PassCode_2021 code : sapforConfiguration_json.codes) {
codes_s.add(code.toString());
}
task.codes = String.join(" ", codes_s);
//---
addThread(new TaskThread(task, sapfor_drv, sapforConfiguration_json));
}
}
interruptThread.start();
}
@Override
public String printThread(Integer id) {
TaskThread taskThread = (TaskThread) threads.get(id);
return taskThread.task.getSummary();
}
@Override
protected void finalize() {
results_json.EndDate = new Date().getTime();
//записать результаты всех задач.
try {
Utils.jsonToFile(results_json, new File(Global.Home, Constants.results_json));
FileUtils.writeStringToFile(new File(Constants.DONE), "");
} catch (Exception e) {
Global.Log.PrintException(e);
}
System.exit(0);
}
}

View File

@@ -0,0 +1,366 @@
package TestingSystem.SAPFOR;
import Common.Constants;
import Common.Global;
import Common.Utils.Utils;
import GlobalData.Tasks.TaskState;
import ProjectData.Messages.Errors.MessageError;
import TestingSystem.SAPFOR.Json.SapforConfiguration_json;
import TestingSystem.SAPFOR.Json.SapforVersion_json;
import TestingSystem.SAPFOR.SapforTask.SapforTask;
import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.Pass_2021;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.nio.charset.Charset;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Date;
import java.util.Vector;
import static java.lang.Character.isDigit;
public class PerformSapforTask extends Pass_2021<SapforTask> {
@Override
public String getDescription() {
return "";
// "Запуск задачи SAPFOR"; Оставляем пустое описание чтобы не засорять журнал.
}
@Override
protected boolean needsAnimation() {
return false;
}
//--
File sapfor_drv;
SapforConfiguration_json sapforConfiguration_json;
//-----
File root;
File parentTask;
File task;
//-----
Process process = null;
int exit_code = Constants.Nan;
//----
File outputFile = null;
File errorsFile = null;
//--
Vector<String> outputLines;
Vector<String> errorsLines;
//---
@Override
protected boolean canStart(Object... args) throws Exception {
sapfor_drv = (File) args[0];
sapforConfiguration_json = (SapforConfiguration_json) args[1];
target = (SapforTask) args[2];
//--->>
parentTask = Paths.get(Global.Home, String.valueOf(sapforConfiguration_json.id), target.test_description).toFile();
root = new File(Global.Home, String.valueOf(sapforConfiguration_json.id));
task = null;
//--->>
return true;
}
protected static boolean checkLines(Vector<String> lines) {
for (String line : lines) {
if (line.toLowerCase().contains("internal error")) {
return false;
}
if (line.toLowerCase().contains("exception")) {
return false;
}
if (line.contains("[ERROR]")) {
return false;
}
if (line.toLowerCase().contains("segmentation fault")) {
return false;
}
}
return true;
}
protected boolean performSapforScript(String name, File workspace, String command, String outName, String errName) throws Exception {
process = null;
exit_code = Constants.Nan;
//---
File data_workspace = new File(workspace, Constants.data);
Utils.CheckDirectory(data_workspace);
outputFile = new File(data_workspace, outName);
errorsFile = new File(data_workspace, errName);
Utils.delete_with_check(outputFile);
Utils.delete_with_check(errorsFile);
//---
File file = new File(data_workspace, name + (Global.isWindows ? ".bat" : ".sh"));
FileUtils.write(file,
Utils.DQuotes(sapfor_drv.getAbsolutePath())
+ (target.flags.isEmpty() ? "" : (" " + target.flags))
+ " -noLogo"
+ " " + command +
" 1>" +
Utils.DQuotes(outputFile.getAbsolutePath()) +
" 2>" +
Utils.DQuotes(errorsFile.getAbsolutePath()),
Charset.defaultCharset());
if (!file.setExecutable(true))
throw new Exception("Не удалось сделать файл скрипта " + name + " исполняемым!");
//--
boolean flag = false;
do {
try {
ProcessBuilder procBuilder = new ProcessBuilder(file.getAbsolutePath());
procBuilder.directory(workspace);
process = procBuilder.start();
exit_code = process.waitFor();
flag = true;
} catch (Exception ex) {
Global.Log.PrintException(ex);
Utils.sleep(1000);
}
}
while (!flag);
process = null;
//---
outputLines = new Vector<>(FileUtils.readLines(outputFile));
errorsLines = new Vector<>(FileUtils.readLines(errorsFile));
return (exit_code == 0) &&
checkLines(outputLines) &&
checkLines(errorsLines);
}
protected boolean parse() throws Exception {
if (performSapforScript("parse", parentTask,
"-parse *.f *.for *.fdv *.f90 *.f77",
Constants.parse_out_file,
Constants.parse_err_file)
&& (new File(parentTask, "dvm.proj")).exists()) {
return true;
} else {
target.state = TaskState.DoneWithErrors;
return false;
}
}
//слегка изменить подход.
protected boolean transformation(PassCode_2021 code) throws Exception {
task = new File(parentTask, "v1");
Utils.CheckAndCleanDirectory(task); //папка для преобразования.
//если версия пустая, это тоже результат тестирования. Поэтому должна учитываться в древе.
target.versions.add(new SapforVersion_json(
root.getAbsolutePath(),
task.getAbsolutePath(), code.getDescription()));
//---
if (performSapforScript("transformation", parentTask,
code.getTestingCommand() + " -F " + Utils.DQuotes(task.getAbsolutePath()),
Constants.out_file,
Constants.err_file
)) {
target.state = TaskState.Done;
parentTask = task;
return true;
}
target.state = TaskState.DoneWithErrors;
return false;
}
protected void variants() throws Exception {
//папки вариантов создается самим сапфором.
target.state = performSapforScript("create_variants", parentTask, " -t 13 -allVars"
+ " -tinfo"
,
Constants.out_file,
Constants.err_file
) ? TaskState.Done : TaskState.DoneWithErrors;
//найти папки с вариантами.
File[] files_ = parentTask.listFiles((dir, name) -> dir.isDirectory() && Utils.isParallelVersionName(name));
if ((files_ != null) && (files_.length > 0)) {
Vector<File> files = new Vector<>(Arrays.asList(files_));
files.sort(Comparator.comparingInt(o -> Integer.parseInt(o.getName().substring(1))));
for (File file : files)
target.variants.add(
new SapforVersion_json(
root.getAbsolutePath(),
file.getAbsolutePath(), PassCode_2021.SPF_CreateParallelVariant.getDescription()));
}
}
//-------------------------------------------------->>
public MessageError unpackMessage(String line_in) throws Exception {
MessageError res = new MessageError();
res.file = "";
res.line = Constants.Nan;
res.value = "";
String line = line_in.substring(9);
//System.out.println(line);
int i = 0;
int s = 0;
String lexeme = "";
//#1020: red43.fdv: line 988]: Active DVM directives are not supported (turn on DVM-directive support option)
for (char c : line.toCharArray()) {
// System.out.print("<s=" + s + ">");
// System.out.println(c);
switch (s) {
case 0:
//поиск groups_s
if (c == '#') {
s = 1;
lexeme = "";
} else return null;
break;
case 1:
//group_s
if (isDigit(c)) {
res.group_s += c;
lexeme += c;
} else if (c == ':') {
s = 2;
res.group = Integer.parseInt(lexeme);
} else return null;
break;
case 2:
//поиск filename
if (c == ' ') {
s = 3;
} else return null;
break;
case 3:
//filename
if (c == ':') {
s = 4;
} else {
res.file += c;
}
break;
case 4:
//поиск line
if (c == ' ') {
s = 5;
lexeme = "";
} else return null;
break;
case 5:
//line
if (c == ' ') {
if (!lexeme.equals("line"))
return null;
else {
s = 6;
lexeme = "";
}
} else {
lexeme += c;
}
break;
case 6:
//line number
if (isDigit(c)) {
lexeme += c;
} else if (c == ']') {
res.line = Integer.parseInt(lexeme);
s = 7;
} else return null;
break;
case 7:
//Поиск value
if (c == ':') {
s = 8;
} else return null;
break;
case 8:
if (c == ' ') {
s = 9;
} else return null;
break;
case 9:
//value
res.value += c;
break;
}
;
++i;
}
//--
if (s != 9)
return null;
//--
return res;
}
public void readMessagesFromFileDump(File file, Vector<MessageError> messages) throws Exception {
//Образец запакованного сообщения
//ERROR - [#1020: red43.fdv: line 988]: Active DVM directives are not supported (turn on DVM-directive support option)
Vector<String> lines = new Vector<>(FileUtils.readLines(file));
if (!lines.isEmpty()) {
for (int i = lines.size() - 1; i >= 0; --i) {
String line = lines.get(i);
if (line.startsWith("ERROR - ")) {
MessageError message = unpackMessage(line);
if (message != null)
messages.add(message);
//--
} else break;
}
}
}
//--
/*
protected void createVersionProjectData(SapforVersion_json version, boolean isTransformation) throws Exception {
db_project_info project = new db_project_info();
project.Home = new File(version.version);
project.name = project.Home.getName();
project.description = version.description;
project.languageName = LanguageName.fortran;
project.creationDate = Utils.getDateNumber();
//--
Vector<MessageError> messages = new Vector<>();
//--
if (isTransformation) {
File p_out = Paths.get(project.Home.getAbsolutePath(), Constants.data, Constants.parse_out_file).toFile();
File p_err = Paths.get(project.Home.getAbsolutePath(), Constants.data, Constants.parse_err_file).toFile();
File out = Paths.get(project.Home.getAbsolutePath(), Constants.data, Constants.out_file).toFile();
File err = Paths.get(project.Home.getAbsolutePath(), Constants.data, Constants.err_file).toFile();
//--
if (p_out.exists()) {
project.Log += (FileUtils.readFileToString(p_out));
readMessagesFromFileDump(p_out, messages);
}
if (out.exists()) {
project.Log += "\n" + FileUtils.readFileToString(out);
readMessagesFromFileDump(out, messages);
}
//в потоки ошибок идет информация от операционной системы. сообщений там быть не должно.
if (p_err.exists())
project.Log += (FileUtils.readFileToString(p_err));
if (err.exists())
project.Log += "\n" + FileUtils.readFileToString(err);
//--
}
project.CreateVisualiserData();
//---
if (isTransformation && !messages.isEmpty()) {
project.Open(); //нельзя!!! сначала надо определиться с версиями. И только потом, получать файлы.
//а так же, убрать dep и txt
project.db.BeginTransaction();
for (MessageError m : messages) {
if (project.db.files.containsKey(m.file)) {
DBProjectFile file = project.db.files.Data.get(m.file);
file.CreateAndAddNewMessage(1, m.value, m.line, m.group);
//update file
project.db.Update(file);
}
}
project.db.Commit();
project.db.Disconnect();
}
}
*/
//-------------------------------------------------->>
@Override
protected void body() throws Exception {
target.StartDate = new Date().getTime();
target.versions.add(new SapforVersion_json(target.test_description, "исходная"));
for (PassCode_2021 code : sapforConfiguration_json.codes) {
if (parse()) {
if (code.equals(PassCode_2021.CreateParallelVariants))
variants();
else if (!transformation(code))
break;
} else
break;
}
target.ChangeDate = new Date().getTime();
}
}

View File

@@ -0,0 +1,59 @@
package TestingSystem.SAPFOR.SapforConfiguration;
import Common.Database.DBObject;
import Common.Database.riDBObject;
import Common.Global;
import TestingSystem.SAPFOR.SapforConfigurationCommand.SapforConfigurationCommand;
import Visual_DVM_2021.Passes.PassCode_2021;
import java.util.Vector;
public class SapforConfiguration extends riDBObject {
//настройки.
public int maxtime = 300; //лимит времени преобразования. (пока не используется)
public int FREE_FORM = 0; //"Свободный выходной стиль"; -f90
public int STATIC_SHADOW_ANALYSIS = 0;//"Оптимизация теневых обменов"; -sh
public int MAX_SHADOW_WIDTH = 50; // "Максимальный размер теневых граней"; (%) -shwidth значение поля
public int KEEP_SPF_DIRECTIVES = 0; //"Сохранять SPF директивы при построении параллельных вариантов"; -keepSPF
public int KEEP_DVM_DIRECTIVES = 0;// "Учитывать DVM директивы"; -keepDVM
//----
public String getFlags() {
Vector<String> res = new Vector<>();
if (FREE_FORM > 0)
res.add("-f90");
if (STATIC_SHADOW_ANALYSIS > 0)
res.add("-sh");
if (MAX_SHADOW_WIDTH > 0)
res.add("-shwidth " + MAX_SHADOW_WIDTH);
if (KEEP_DVM_DIRECTIVES > 0)
res.add("-keepDVM");
if (KEEP_SPF_DIRECTIVES > 0)
res.add("-keepSPF");
return String.join(" ", res);
}
//-
public Vector<PassCode_2021> getPassCodes() {
Vector<PassCode_2021> res = new Vector<>();
for (SapforConfigurationCommand command : Global.testingServer.db.sapforConfigurationCommands.Data.values()) {
if (command.sapforconfiguration_id == id) {
res.add(command.passCode);
}
}
return res;
}
//--
@Override
public void SynchronizeFields(DBObject src) {
super.SynchronizeFields(src);
SapforConfiguration c = (SapforConfiguration) src;
maxtime = c.maxtime;
FREE_FORM = c.FREE_FORM;
STATIC_SHADOW_ANALYSIS = c.STATIC_SHADOW_ANALYSIS;
MAX_SHADOW_WIDTH = c.MAX_SHADOW_WIDTH;
KEEP_SPF_DIRECTIVES = c.KEEP_SPF_DIRECTIVES;
KEEP_DVM_DIRECTIVES = c.KEEP_DVM_DIRECTIVES;
}
public SapforConfiguration(SapforConfiguration sapforConfiguration) {
this.SynchronizeFields(sapforConfiguration);
}
public SapforConfiguration() {
}
}

View File

@@ -0,0 +1,108 @@
package TestingSystem.SAPFOR.SapforConfiguration;
import Common.Current;
import Common.Database.*;
import Common.UI.DataSetControlForm;
import Common.UI.Windows.Dialog.DBObjectDialog;
import Common.Utils.Utils;
import TestingSystem.SAPFOR.SapforConfiguration.UI.SapforConfigurationFields;
import TestingSystem.SAPFOR.SapforConfigurationCommand.SapforConfigurationCommand;
import java.util.LinkedHashMap;
public class SapforConfigurationDBTable extends iDBTable<SapforConfiguration> {
public SapforConfigurationDBTable() {
super(SapforConfiguration.class);
}
@Override
public Current CurrentName() {
return Current.SapforConfiguration;
}
@Override
public String getSingleDescription() {
return "конфигурация тестирования SAPFOR";
}
@Override
public String getPluralDescription() {
return "конфигурации";
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this){
@Override
public boolean hasCheckBox() {
return true;
}
@Override
protected void AdditionalInitColumns() {
//columns.get(0).setVisible(false);
}
};
}
@Override
public String[] getUIColumnNames() {
return new String[]{
"имя",
"автор",
"флаги"
};
}
@Override
public Object getFieldAt(SapforConfiguration object, int columnIndex) {
switch (columnIndex) {
case 2:
return object.description;
case 3:
return object.sender_name;
case 4:
return object.getFlags();
default:
return null;
}
}
//--
@Override
public DBObjectDialog<SapforConfiguration, SapforConfigurationFields> getDialog() {
return new DBObjectDialog<SapforConfiguration, SapforConfigurationFields>(SapforConfigurationFields.class) {
@Override
public int getDefaultHeight() {
return 415;
}
@Override
public int getDefaultWidth() {
return 600;
}
@Override
public void validateFields() {
}
@Override
public void fillFields() {
fields.tfName.setText(Result.description);
fields.cbFREE_FORM.setSelected(Result.FREE_FORM != 0);
fields.cbKEEP_DVM_DIRECTIVES.setSelected(Result.KEEP_DVM_DIRECTIVES != 0);
fields.cbKEEP_SPF_DIRECTIVES.setSelected(Result.KEEP_SPF_DIRECTIVES != 0);
fields.cbSTATIC_SHADOW_ANALYSIS.setSelected(Result.STATIC_SHADOW_ANALYSIS != 0);
fields.sMAX_SHADOW_WIDTH.setValue(Result.MAX_SHADOW_WIDTH);
}
@Override
public void ProcessResult() {
Result.description = fields.tfName.getText();
Result.FREE_FORM = Utils.fromBoolean(fields.cbFREE_FORM.isSelected());
Result.KEEP_DVM_DIRECTIVES = Utils.fromBoolean(fields.cbKEEP_DVM_DIRECTIVES.isSelected());
Result.KEEP_SPF_DIRECTIVES = Utils.fromBoolean(fields.cbKEEP_SPF_DIRECTIVES.isSelected());
Result.STATIC_SHADOW_ANALYSIS = Utils.fromBoolean(fields.cbSTATIC_SHADOW_ANALYSIS.isSelected());
Result.MAX_SHADOW_WIDTH = fields.sMAX_SHADOW_WIDTH.getValue();
}
@Override
public void SetReadonly() {
fields.tfName.setEnabled(false);
fields.sTransformationMaxtime.setEnabled(false);
}
};
}
@Override
public LinkedHashMap<Class<? extends DBObject>, FKBehaviour> getFKDependencies() {
LinkedHashMap<Class<? extends DBObject>, FKBehaviour> res = new LinkedHashMap<>();
res.put(SapforConfigurationCommand.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
return res;
}
}

View File

@@ -0,0 +1,130 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="TestingSystem.SAPFOR.SapforConfiguration.UI.SapforConfigurationFields">
<grid id="27dc6" binding="content" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="883" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="d1d6e" layout-manager="GridLayoutManager" row-count="8" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="3257b" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false">
<preferred-size width="284" height="20"/>
</grid>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="название"/>
</properties>
</component>
<vspacer id="224d6">
<constraints>
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false">
<preferred-size width="284" height="14"/>
</grid>
</constraints>
</vspacer>
<component id="ecbf1" class="javax.swing.JTextField" binding="tfName" custom-create="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<minimum-size width="200" height="30"/>
<preferred-size width="200" height="30"/>
<maximum-size width="200" height="30"/>
</grid>
</constraints>
<properties/>
</component>
<component id="b644a" class="javax.swing.JCheckBox" binding="cbFREE_FORM">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="284" height="25"/>
</grid>
</constraints>
<properties>
<font name="Times New Roman" size="14" style="2"/>
<icon value="icons/NotPick.png"/>
<selectedIcon value="icons/Pick.png"/>
<text value="Свободный выходной стиль"/>
</properties>
</component>
<component id="7721e" class="javax.swing.JCheckBox" binding="cbKEEP_SPF_DIRECTIVES">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="284" height="25"/>
</grid>
</constraints>
<properties>
<font name="Times New Roman" size="14" style="2"/>
<icon value="icons/NotPick.png"/>
<selectedIcon value="icons/Pick.png"/>
<text value="Сохранять SPF директивы"/>
</properties>
</component>
<component id="f44c1" class="javax.swing.JLabel">
<constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="3" use-parent-layout="false">
<preferred-size width="284" height="17"/>
</grid>
</constraints>
<properties>
<font name="Times New Roman" size="14" style="2"/>
<text value="Максимальный размер теневых граней, %"/>
</properties>
</component>
<component id="54e77" class="javax.swing.JCheckBox" binding="cbSTATIC_SHADOW_ANALYSIS">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="284" height="25"/>
</grid>
</constraints>
<properties>
<font name="Times New Roman" size="14" style="2"/>
<icon value="icons/NotPick.png"/>
<selectedIcon value="icons/Pick.png"/>
<text value="Оптимизация теневых обменов"/>
</properties>
</component>
<component id="4e865" class="javax.swing.JCheckBox" binding="cbKEEP_DVM_DIRECTIVES">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="284" height="25"/>
</grid>
</constraints>
<properties>
<font name="Times New Roman" size="14" style="2"/>
<icon value="icons/NotPick.png"/>
<selectedIcon value="icons/Pick.png"/>
<text value="Учитывать DVM директивы"/>
</properties>
</component>
<component id="14243" class="javax.swing.JSlider" binding="sMAX_SHADOW_WIDTH">
<constraints>
<grid row="6" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<minimum-size width="500" height="40"/>
<preferred-size width="500" height="40"/>
<maximum-size width="500" height="40"/>
</grid>
</constraints>
<properties>
<majorTickSpacing value="25"/>
<minorTickSpacing value="1"/>
<paintLabels value="true"/>
<paintTicks value="true"/>
<snapToTicks value="false"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
</form>

View File

@@ -0,0 +1,25 @@
package TestingSystem.SAPFOR.SapforConfiguration.UI;
import Common.UI.TextField.StyledTextField;
import Common.UI.Windows.Dialog.DialogFields;
import javax.swing.*;
import java.awt.*;
public class SapforConfigurationFields implements DialogFields {
private JPanel content;
public JTextField tfName;
public JSpinner sTransformationMaxtime;
public JCheckBox cbFREE_FORM;
public JSlider sMAX_SHADOW_WIDTH;
public JCheckBox cbSTATIC_SHADOW_ANALYSIS;
public JCheckBox cbKEEP_SPF_DIRECTIVES;
public JCheckBox cbKEEP_DVM_DIRECTIVES;
//--
@Override
public Component getContent() {
return content;
}
private void createUIComponents() {
// TODO: place custom component creation code here
tfName = new StyledTextField();
}
}

View File

@@ -0,0 +1,28 @@
package TestingSystem.SAPFOR.SapforConfigurationCommand;
import Common.Constants;
import Common.Current;
import Common.Database.DBObject;
import Common.Database.riDBObject;
import Visual_DVM_2021.Passes.PassCode_2021;
import com.sun.org.glassfish.gmbal.Description;
public class SapforConfigurationCommand extends riDBObject {
@Description("DEFAULT -1")
public int sapforconfiguration_id = Constants.Nan;
public PassCode_2021 passCode = PassCode_2021.SPF_RemoveDvmDirectives;
@Override
public boolean isVisible() {
return Current.HasSapforConfiguration() && (Current.getSapforConfiguration().id == sapforconfiguration_id);
}
@Override
public void SynchronizeFields(DBObject src) {
super.SynchronizeFields(src);
SapforConfigurationCommand c = (SapforConfigurationCommand) src;
sapforconfiguration_id = c.sapforconfiguration_id;
passCode = c.passCode;
}
public SapforConfigurationCommand() {
}
public SapforConfigurationCommand(SapforConfigurationCommand sapforConfigurationCommand) {
this.SynchronizeFields(sapforConfigurationCommand);
}
}

View File

@@ -0,0 +1,67 @@
package TestingSystem.SAPFOR.SapforConfigurationCommand;
import Common.Current;
import Common.Database.iDBTable;
import Common.UI.DataSetControlForm;
import Common.UI.UI;
import Common.UI.Windows.Dialog.DBObjectDialog;
import TestingSystem.SAPFOR.SapforConfigurationCommand.UI.SapforConfigurationCommandFields;
import Visual_DVM_2021.Passes.PassCode_2021;
public class SapforConfigurationCommandsDBTable extends iDBTable<SapforConfigurationCommand> {
public SapforConfigurationCommandsDBTable() {
super(SapforConfigurationCommand.class);
}
@Override
public String getSingleDescription() {
return "команда";
}
@Override
public String getPluralDescription() {
return "команды";
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this){
@Override
protected void AdditionalInitColumns() {
//columns.get(0).setVisible(false);
}
};
}
@Override
public String[] getUIColumnNames() {
return new String[]{
"Проход"
};
}
@Override
public Object getFieldAt(SapforConfigurationCommand object, int columnIndex) {
switch (columnIndex) {
case 1:
return object.passCode.getDescription();
default:
return null;
}
}
@Override
public Current CurrentName() {
return Current.SapforConfigurationCommand;
}
@Override
public DBObjectDialog<SapforConfigurationCommand, SapforConfigurationCommandFields> getDialog() {
return new DBObjectDialog<SapforConfigurationCommand, SapforConfigurationCommandFields>(SapforConfigurationCommandFields.class) {
@Override
public int getDefaultHeight() {
return 250;
}
@Override
public void fillFields() {
UI.TrySelect(fields.cbPassCode, Result.passCode);
}
@Override
public void ProcessResult() {
Result.passCode = (PassCode_2021) fields.cbPassCode.getSelectedItem();
Result.sapforconfiguration_id = Current.getSapforConfiguration().id;
}
};
}
}

View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="TestingSystem.SAPFOR.SapforConfigurationCommand.UI.SapforConfigurationCommandFields">
<grid id="27dc6" binding="content" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="97a3c" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
<text value="проход"/>
</properties>
</component>
<vspacer id="7e4ea">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="e95d0" class="javax.swing.JComboBox" binding="cbPassCode" custom-create="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<toolTipText value="выберите проход"/>
</properties>
</component>
</children>
</grid>
</form>

View File

@@ -0,0 +1,32 @@
package TestingSystem.SAPFOR.SapforConfigurationCommand.UI;
import Common.Current;
import Common.UI.Tables.StyledCellLabel;
import Common.UI.Windows.Dialog.DialogFields;
import Repository.Component.Sapfor.Sapfor;
import Visual_DVM_2021.Passes.PassCode_2021;
import javax.swing.*;
import java.awt.*;
public class SapforConfigurationCommandFields implements DialogFields {
private JPanel content;
public JComboBox<PassCode_2021> cbPassCode;
@Override
public Component getContent() {
return content;
}
private void createUIComponents() {
// TODO: place custom component creation code here
cbPassCode = new JComboBox<>();
cbPassCode.setRenderer((list, value, index, isSelected, cellHasFocus) -> {
JLabel res = new StyledCellLabel();
res.setText(value.getDescription());
res.setBackground(isSelected ?
Current.getTheme().selection_background : Current.getTheme().background
);
return res;
});
//-
for (PassCode_2021 code : Sapfor.getScenariosCodes())
cbPassCode.addItem(code);
}
}

View File

@@ -0,0 +1,36 @@
package TestingSystem.SAPFOR.SapforTask;
import Common.Current;
import Common.UI.StatusEnum;
import Common.UI.Themes.VisualiserFonts;
import java.awt.*;
public enum MatchState implements StatusEnum {
Unknown,
NotMatch,
Match;
public String getDescription() {
switch (this) {
case Unknown:
return "неизвестно";
case Match:
return "совпадений";
case NotMatch:
return "различий";
default:
return "?";
}
}
@Override
public Font getFont() {
switch (this) {
case Unknown:
return Current.getTheme().Fonts.get(VisualiserFonts.UnknownState);
case Match:
return Current.getTheme().Fonts.get(VisualiserFonts.GoodState);
case NotMatch:
return Current.getTheme().Fonts.get(VisualiserFonts.BadState);
default:
return StatusEnum.super.getFont();
}
}
}

View File

@@ -0,0 +1,196 @@
package TestingSystem.SAPFOR.SapforTask;
import Common.Constants;
import Common.Current;
import Common.Database.DBObject;
import Common.Utils.Utils;
import GlobalData.Tasks.TaskState;
import TestingSystem.SAPFOR.Json.SapforVersion_json;
import TestingSystem.SAPFOR.SapforTasksPackage.UI.VersionSummary;
import Visual_DVM_2021.Passes.PassCode_2021;
import com.google.gson.annotations.Expose;
import com.sun.org.glassfish.gmbal.Description;
import javax.swing.tree.DefaultMutableTreeNode;
import java.io.File;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Vector;
public class SapforTask extends DBObject {
//------------------------------------>>
@Description("PRIMARY KEY, UNIQUE")
@Expose
public long id = Constants.Nan;
@Description("DEFAULT '-1'")
@Expose
public int sapfor_configuration_id = Constants.Nan;
@Expose
@Description("DEFAULT '-1'")
public int sapfortaskspackage_id = Constants.Nan;
//------------------------------------->>
@Description("DEFAULT ''")
@Expose
public String test_description = "";
@Description("DEFAULT ''")
@Expose
public String group_description = "";
@Description("DEFAULT ''")
@Expose
public String flags = "";
@Description("DEFAULT ''")
@Expose
public String codes = "";
@Expose
public TaskState state = TaskState.Inactive;
@Expose
public long StartDate = 0; //дата начала выполнения
@Expose
public long ChangeDate = 0;//дата окончания выполнения
//в json не выносить. это только для БД.
@Description("DEFAULT ''")
public String versionsDescription = "";
//------
@Description("IGNORE")
@Expose
public Vector<SapforVersion_json> versions = new Vector<>();
//----------
@Description("IGNORE")
@Expose
public Vector<SapforVersion_json> variants = new Vector<>();
//----------
@Description("IGNORE")
public MatchState match = MatchState.Unknown;
//-----------
public String getUniqueKey() {
return sapfor_configuration_id + "_" + group_description + "_" + test_description;
}
public String getSummary() {
Vector<String> lines = new Vector<>();
lines.add(group_description);
lines.add(test_description);
lines.add(codes);
lines.add(flags);
return String.join(" ", lines);
}
//-----------
public SapforTask() {
}
public DefaultMutableTreeNode getVersionsTree(File configurationRoot) {
DefaultMutableTreeNode root = null;
DefaultMutableTreeNode child = null;
DefaultMutableTreeNode parent = null;
//--
for (SapforVersion_json version_json : versions) {
version_json.init(configurationRoot);
version_json.task = this;
//-
child = new VersionSummary(version_json);
if (parent == null) {
root = child;
parent = child;
} else {
parent.add(child);
parent = child;
}
//-
}
if (parent != null) {
for (SapforVersion_json version_json : variants) {
version_json.init(configurationRoot);
version_json.task = this;
parent.add(new VersionSummary(version_json));
}
}
//--
return root;
}
public void Reset() {
state = TaskState.Inactive;
versions.clear();
variants.clear();
}
public SapforTask(SapforTask src) {
this.SynchronizeFields(src);
}
@Override
public Object getPK() {
return id;
}
@Override
public void SynchronizeFields(DBObject object) {
super.SynchronizeFields(object);
SapforTask t = (SapforTask) object;
id = t.id;
sapfor_configuration_id = t.sapfor_configuration_id;
sapfortaskspackage_id = t.sapfortaskspackage_id;
//-
test_description = t.test_description;
group_description = t.group_description;
versionsDescription = t.versionsDescription;
//--
codes = t.codes;
state = t.state;
//--
}
public String getVersionsChain() {
Vector<String> versionsLines = new Vector<>();
for (int i = 1; i < versions.size(); ++i) {
versionsLines.add(Utils.Brackets(versions.get(i).description));
}
if (!variants.isEmpty()) {
versionsLines.add(Utils.Brackets(PassCode_2021.CreateParallelVariants.getDescription()));
}
return String.join("", versionsLines);
}
@Override
public boolean isVisible() {
return Current.HasSapforTasksPackage() && Current.getSapforTasksPackage().id == this.sapfortaskspackage_id;
}
public LinkedHashMap<String, SapforVersion_json> getSortedVersions() {
LinkedHashMap<String, SapforVersion_json> res = new LinkedHashMap<>();
for (SapforVersion_json version_json : versions)
res.put(version_json.version, version_json);
//--
for (SapforVersion_json version_json : variants)
res.put(version_json.version, version_json);
return res;
}
public void checkMatch(SapforTask task2) {
if (!state.equals(task2.state)) {
System.out.println("Не совпадение цепочки версий в задаче " + getUniqueKey());
} else if (versions.size() != task2.versions.size()) {
System.out.println("Не совпадение длины цепочки версий в задаче " + getUniqueKey());
} else if (variants.size() != task2.variants.size()) {
System.out.println("Не совпадение длины цепочки вариантов в задаче " + getUniqueKey());
} else {
LinkedHashMap<String, SapforVersion_json> versions1 = getSortedVersions();
LinkedHashMap<String, SapforVersion_json> versions2 = task2.getSortedVersions();
//---
for (String name1 : versions1.keySet()) {
if (!versions2.containsKey(name1)) {
System.out.println("Не совпадение имен версий в задаче " + getUniqueKey());
return;
}
}
System.out.println("сравнение версий.");
//--
for (String name1 : versions1.keySet()) {
System.out.println("version name=" + name1);
SapforVersion_json version1 = versions1.get(name1);
SapforVersion_json version2 = versions2.get(name1);
//---
if (!version1.isMatch(version2)) {
System.out.println("Не совпадение версий в задаче " + getUniqueKey());
return;
}
}
match = MatchState.Match;
task2.match = MatchState.Match;
}
}
public Date getStartDate() {
return new Date(StartDate);
}
public Date getChangeDate() {
return new Date(ChangeDate);
}
}

View File

@@ -0,0 +1,68 @@
package TestingSystem.SAPFOR.SapforTask;
import Common.Current;
import Common.Database.DBTable;
import Common.UI.DataSetControlForm;
import static Common.UI.Tables.TableRenderers.RendererDate;
import static Common.UI.Tables.TableRenderers.RendererStatusEnum;
public class SapforTasksDBTable extends DBTable<Long, SapforTask> {
public SapforTasksDBTable() {
super(Long.class, SapforTask.class);
}
@Override
public String getSingleDescription() {
return "задача";
}
@Override
public String getPluralDescription() {
return "задачи";
}
@Override
public Current CurrentName() {
return Current.SapforTask;
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this) {
@Override
protected void AdditionalInitColumns() {
columns.get(4).setRenderer(RendererStatusEnum);
columns.get(5).setRenderer(RendererDate);
columns.get(6).setRenderer(RendererDate);
}
};
}
@Override
public String[] getUIColumnNames() {
return new String[]{
"Группа",
"Тест",
"Флаги",
"Статус",
"Начало",
"Окончание",
"Версии"
};
}
@Override
public Object getFieldAt(SapforTask object, int columnIndex) {
switch (columnIndex) {
case 1:
return object.group_description;
case 2:
return object.test_description;
case 3:
return object.flags;
case 4:
return object.state;
case 5:
return object.getStartDate();
case 6:
return object.getChangeDate();
case 7:
return object.versionsDescription;
default:
return null;
}
}
}

View File

@@ -0,0 +1,17 @@
package TestingSystem.SAPFOR.SapforTasksPackage;
import TestingSystem.Common.Group.Group;
import TestingSystem.Common.Test.Test;
import TestingSystem.SAPFOR.SapforConfiguration.SapforConfiguration;
import TestingSystem.SAPFOR.ServerSapfor.ServerSapfor;
import java.io.Serializable;
import java.util.LinkedHashMap;
public class SapforPackageData implements Serializable {
//--->
public LinkedHashMap<Integer, Group> groups =new LinkedHashMap<Integer, Group>();
public LinkedHashMap<Integer, Test> tests = new LinkedHashMap<>();
public LinkedHashMap<Integer, SapforConfiguration> sapforConfigurations = new LinkedHashMap<>();
public ServerSapfor sapfor = null;
//-->>
public String notFound = "";
}

View File

@@ -0,0 +1,98 @@
package TestingSystem.SAPFOR.SapforTasksPackage;
import Common.Constants;
import Common.Database.DBObject;
import Common.Database.riDBObject;
import Common.Global;
import Common.Utils.Utils;
import TestingSystem.DVM.TasksPackage.TasksPackageState;
import TestingSystem.SAPFOR.Json.SapforTasksResults_json;
import TestingSystem.SAPFOR.SapforTask.SapforTask;
import com.sun.org.glassfish.gmbal.Description;
import java.io.File;
import java.nio.file.Paths;
import java.util.Comparator;
public class SapforTasksPackage extends riDBObject {
@Description("DEFAULT ''")
public String testsNames = "";//имена тестов через ; для отображения
//---
public int sapforId = Constants.Nan;
public String sapfor_version = "?"; //тестируемая версия SAPFOR для таблицы
public String sapfor_process_name = "";
//---
public String workspace = ""; //домашняя папка
//---
public int tasksCount = 0; //Общее число задач
//---
public int needsEmail = 0;
public long StartDate = 0; //дата начала выполнения
public long ChangeDate = 0;//дата окончания выполнения
//-
public int kernels = 1; //количество потоков.
@Description("DEFAULT 'TestsSynchronize'")
public TasksPackageState state = TasksPackageState.TestsSynchronize;
@Description("DEFAULT ''")
public String testsIds = "";
@Description("DEFAULT ''")
public String configurationsIds = "";
@Description("DEFAULT ''")
public String summary = "";
@Description("IGNORE")
public SapforTasksResults_json results = null;
///---
public File getArchive() {
return new File(Global.SapforPackagesDirectory, id + ".zip");
}
public File getLocalWorkspace() {
return new File(Global.SapforPackagesDirectory, String.valueOf(id));
}
public File getLoadedSign() {
return Paths.get(Global.SapforPackagesDirectory.getAbsolutePath(), String.valueOf(id), Constants.LOADED).toFile();
}
public boolean isLoaded() {
return getLoadedSign().exists();
}
public void readResults() {
File json_file = new File(getLocalWorkspace(), Constants.results_json);
results = null;
try {
results = (SapforTasksResults_json) Utils.jsonFromFile(json_file,
SapforTasksResults_json.class);
//----
results.tasks.sort(Comparator.comparing(SapforTask::getUniqueKey));
for (SapforTask task : results.tasks)
results.allTasks.put(task.getUniqueKey(), task);
//---
results.SortTasks(); //по состояниям конфигурациям и группам
//---
results.buildTree(this);
//---
} catch (Exception ex) {
ex.printStackTrace();
}
}
@Override
public void SynchronizeFields(DBObject src) {
super.SynchronizeFields(src);
SapforTasksPackage p = (SapforTasksPackage) src;
sapforId = p.sapforId;
testsNames = p.testsNames;
sapfor_version = p.sapfor_version;
workspace = p.workspace;
tasksCount = p.tasksCount;
StartDate = p.StartDate;
ChangeDate = p.ChangeDate;
kernels = p.kernels;
sapfor_process_name = p.sapfor_process_name;
state = p.state;
needsEmail = p.needsEmail;
summary = p.summary;
}
//---
public SapforTasksPackage() {
}
//--
public SapforTasksPackage(SapforTasksPackage sapforTasksPackage) {
this.SynchronizeFields(sapforTasksPackage);
}
}

View File

@@ -0,0 +1,80 @@
package TestingSystem.SAPFOR.SapforTasksPackage;
import Common.Current;
import Common.Database.*;
import Common.UI.DataSetControlForm;
import TestingSystem.SAPFOR.SapforTask.SapforTask;
import java.util.Date;
import java.util.LinkedHashMap;
import static Common.UI.Tables.TableRenderers.RendererDate;
import static Common.UI.Tables.TableRenderers.RendererStatusEnum;
public class SapforTasksPackagesDBTable extends iDBTable<SapforTasksPackage> {
public SapforTasksPackagesDBTable() {
super(SapforTasksPackage.class);
}
@Override
public Current CurrentName() {
return Current.SapforTasksPackage;
}
@Override
public String getSingleDescription() {
return "пакет задач Sapfor";
}
@Override
public String getPluralDescription() {
return "пакеты задач Sapfor";
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this) {
@Override
protected void AdditionalInitColumns() {
// columns.get(0).setVisible(false);
columns.get(5).setRenderer(RendererDate);
columns.get(6).setRenderer(RendererDate);
columns.get(7).setRenderer(RendererStatusEnum);
}
};
}
@Override
public String[] getUIColumnNames() {
return new String[]{
"SAPFOR",
"Тесты",
"Задач",
"Ядер",
"Начало",
"Изменено",
"Статус"
};
}
@Override
public Object getFieldAt(SapforTasksPackage object, int columnIndex) {
switch (columnIndex) {
case 1:
return object.sapfor_version;
case 2:
return object.testsNames;
case 3:
return object.tasksCount;
case 4:
return object.kernels;
case 5:
return new Date(object.StartDate);
case 6:
return new Date(object.ChangeDate);
case 7:
return object.state;
default:
return null;
}
}
@Override
public LinkedHashMap<Class<? extends DBObject>, FKBehaviour> getFKDependencies() {
LinkedHashMap<Class<? extends DBObject>, FKBehaviour> res = new LinkedHashMap<>();
res.put(SapforTask.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
return res;
}
}

View File

@@ -0,0 +1,29 @@
package TestingSystem.SAPFOR.SapforTasksPackage.UI;
import Common.Constants;
import Common.Utils.Utils;
import TestingSystem.SAPFOR.SapforTask.SapforTask;
import Visual_DVM_2021.Passes.PassCode_2021;
import java.util.Arrays;
import java.util.Vector;
public class ConfigurationSummary extends SapforPackageTreeNode {
public int configuration_id = Constants.Nan;
public String flags = "";
public Vector<String> codes_descriptions = new Vector<>();
public ConfigurationSummary(int configuration_id_in, SapforTask task) {
configuration_id = configuration_id_in;
flags = task.flags;
Vector<String> codes_s = new Vector<>(Arrays.asList(task.codes.split(" ")));
for (int i = 1; i < codes_s.size(); ++i) {
codes_descriptions.add(Utils.Brackets(PassCode_2021.valueOf(codes_s.get(i)).getDescription()));
}
}
@Override
public String toString() {
return flags + " " + String.join("", codes_descriptions);
}
@Override
public String getImageKey() {
return "Configuration";
}
}

View File

@@ -0,0 +1,15 @@
package TestingSystem.SAPFOR.SapforTasksPackage.UI;
public class GroupSummary extends SapforPackageTreeNode {
public String group_name = "";
@Override
public String getImageKey() {
return "Group";
}
public GroupSummary(String group_name_in) {
group_name = group_name_in;
}
@Override
public String toString() {
return group_name;
}
}

View File

@@ -0,0 +1,24 @@
package TestingSystem.SAPFOR.SapforTasksPackage.UI;
import TestingSystem.SAPFOR.SapforTask.MatchState;
public class MatchesSummary extends SapforPackageTreeNode {
public MatchState state;
public int count = 0;
public MatchesSummary(MatchState state_in) {
state = state_in;
}
@Override
public String toString() {
return state.getDescription() + " : " + count;
}
@Override
public String getImageKey() {
switch (state) {
case Match:
return "Match";
case NotMatch:
return "NotMatch";
default:
return "TestVersion";
}
}
}

View File

@@ -0,0 +1,14 @@
package TestingSystem.SAPFOR.SapforTasksPackage.UI;
public class PackageSummary extends SapforPackageTreeNode {
public int count = 0;
@Override
public String getImageKey() {
return null;
}
public PackageSummary() {
}
@Override
public String toString() {
return "всего задач : " + count;
}
}

View File

@@ -0,0 +1,12 @@
package TestingSystem.SAPFOR.SapforTasksPackage.UI;
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
import java.util.Objects;
public abstract class SapforPackageTreeNode extends DefaultMutableTreeNode {
public ImageIcon getIcon() {
return (getImageKey() != null) ?
new ImageIcon(Objects.requireNonNull(getClass().getResource("/icons/versions/" + getImageKey() + ".png")))
: null;
}
public abstract String getImageKey();
}

View File

@@ -0,0 +1,70 @@
package TestingSystem.SAPFOR.SapforTasksPackage.UI;
import Common.Current;
import Common.UI.Trees.DataTree;
import Common.UI.Trees.TreeRenderers;
import Common.UI.UI;
import TestingSystem.SAPFOR.Json.SapforVersion_json;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;
import java.util.Vector;
public class SapforTasksPackageTree extends DataTree {
Current current;
SapforTasksPackageTree slave_tree = null;
public void setSlaveTree(SapforTasksPackageTree slave_tree_in) {
slave_tree = slave_tree_in;
}
public SapforTasksPackageTree(DefaultMutableTreeNode root_in, Current current_in) {
super(root_in);
current = current_in;
}
@Override
protected int getStartLine() {
return 1;
}
@Override
public TreeRenderers getRenderer() {
return TreeRenderers.RendererSapforVersion;
}
@Override
public Current getCurrent() {
return current;
}
public void selectSamePath_r(TreePath example, int index, DefaultMutableTreeNode node, Vector<DefaultMutableTreeNode> res) {
if (index < example.getPathCount()) {
DefaultMutableTreeNode exampleNode = (DefaultMutableTreeNode) example.getPathComponent(index);
if (exampleNode.toString().equals(node.toString())) {
res.add(node);
for (int i = 0; i < node.getChildCount(); ++i)
selectSamePath_r(example, index + 1, (DefaultMutableTreeNode) node.getChildAt(i), res);
}
}
}
public void selectSamePath(TreePath path_in) {
Vector<DefaultMutableTreeNode> pathNodes = new Vector<>();
selectSamePath_r(path_in, 0, root, pathNodes);
if (!pathNodes.isEmpty()) {
TreePath path = new TreePath(pathNodes.toArray());
setSelectionPath(path);
}
}
@Override
public void SelectionAction(TreePath e) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.getLastPathComponent();
Object o = node.getUserObject();
//---
if (slave_tree != null) {
slave_tree.selectSamePath(e);
}
//---
if (o instanceof SapforVersion_json) {
SapforVersion_json version = (SapforVersion_json) o;
Current.set(current, version);
if (current.equals(Current.SapforEtalonVersion))
UI.getMainWindow().getTestingWindow().ShowCurrentSapforPackageVersionEtalon();
else
UI.getMainWindow().getTestingWindow().ShowCurrentSapforPackageVersion();
//--
}
}
}

View File

@@ -0,0 +1,19 @@
package TestingSystem.SAPFOR.SapforTasksPackage.UI;
import Common.UI.Trees.StyledTreeCellRenderer;
import javax.swing.*;
public class SapforVersionsTreeCellRenderer extends StyledTreeCellRenderer {
public java.awt.Component getTreeCellRendererComponent(
JTree tree, Object value,
boolean selected, boolean expanded,
boolean leaf, int row, boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
if (value instanceof SapforPackageTreeNode) {
SapforPackageTreeNode node = (SapforPackageTreeNode) value;
setForeground(tree.getForeground());
setFont(getFont().deriveFont((float) 14.0));
setIcon(node.getIcon());
}
return this;
}
}

View File

@@ -0,0 +1,24 @@
package TestingSystem.SAPFOR.SapforTasksPackage.UI;
import GlobalData.Tasks.TaskState;
public class StateSummary extends SapforPackageTreeNode {
public TaskState state;
public int count = 0;
public StateSummary(TaskState state_in) {
state = state_in;
}
@Override
public String toString() {
return state.getDescription() + " : " + count;
}
@Override
public String getImageKey() {
switch (state) {
case Done:
return "DoneStateSummary";
case DoneWithErrors:
return "ErrorsStateSummary";
default:
return "UnknownStateSummary";
}
}
}

View File

@@ -0,0 +1,15 @@
package TestingSystem.SAPFOR.SapforTasksPackage.UI;
import javax.swing.*;
import java.util.Objects;
public abstract class TreeSummary {
public String text = "";
public abstract void refreshText();
@Override
public String toString() {
return text;
}
public ImageIcon getIcon() {
return new ImageIcon(Objects.requireNonNull(getClass().getResource("/icons/versions/" + getImageKey() + ".png")));
}
public abstract String getImageKey();
}

View File

@@ -0,0 +1,20 @@
package TestingSystem.SAPFOR.SapforTasksPackage.UI;
import TestingSystem.SAPFOR.Json.SapforVersion_json;
public class VersionSummary extends SapforPackageTreeNode{
public String version_name = "";
public String version_description = "";
public VersionSummary(SapforVersion_json version_json) {
setUserObject(version_json);
version_name = version_json.Home.getName();
version_description = version_json.description;
}
@Override
public String getImageKey() {
return "TestVersion";
}
@Override
public String toString() {
return version_name+ " : " +version_description;
}
}

View File

@@ -0,0 +1,202 @@
package TestingSystem.SAPFOR.SapforTasksPackageSupervisor;
import Common.Constants;
import Common.Current;
import Common.Global;
import Common.GlobalProperties;
import Common.Utils.Utils;
import Repository.Server.ServerCode;
import TestingSystem.Common.Test.Test;
import TestingSystem.Common.TestingPlanner;
import TestingSystem.DVM.TasksPackage.TasksPackageState;
import TestingSystem.SAPFOR.Json.SapforConfiguration_json;
import TestingSystem.SAPFOR.Json.SapforTasksPackage_json;
import TestingSystem.SAPFOR.Json.SapforTasksResults_json;
import TestingSystem.SAPFOR.Json.SapforTest_json;
import TestingSystem.SAPFOR.SapforConfiguration.SapforConfiguration;
import TestingSystem.SAPFOR.SapforTask.SapforTask;
import TestingSystem.SAPFOR.SapforTasksPackage.SapforPackageData;
import TestingSystem.SAPFOR.SapforTasksPackage.SapforTasksPackage;
import Visual_DVM_2021.Passes.PassCode_2021;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.util.Date;
import java.util.Vector;
public class SapforTasksPackageSupervisor {
protected TestingPlanner planner; //планировщик.
SapforTasksPackage sapforTasksPackage = null;
public SapforTasksPackageSupervisor(TestingPlanner planner_in, SapforTasksPackage sapforTasksPackage_in) {
planner = planner_in;
sapforTasksPackage = sapforTasksPackage_in;
}
private void TestsSynchronize() throws Exception {
SapforPackageData data = (SapforPackageData) planner.ServerCommand(ServerCode.GetActualSapforPackageData, sapforTasksPackage);
if (!data.notFound.isEmpty()) {
sapforTasksPackage.summary = data.notFound;
sapforTasksPackage.state = TasksPackageState.Aborted;
return;
}
//--
System.out.println(sapforTasksPackage.id + " — TestsSynchronize");
File sapfor_src = new File(data.sapfor.call_command);
//--
SapforTasksPackage_json package_json = new SapforTasksPackage_json();
package_json.kernels = sapforTasksPackage.kernels;
for (Test test : data.tests.values()) {
SapforTest_json test_json = new SapforTest_json();
test_json.test_description = test.description;
test_json.group_description = data.groups.get(test.group_id).description;
package_json.tests.add(test_json);
}
//создание рабочего пространства для пакетного режима
File packageWorkspace = new File(Global.SapforPackagesDirectory, String.valueOf(sapforTasksPackage.id));
Utils.CheckAndCleanDirectory(packageWorkspace);
sapforTasksPackage.workspace = packageWorkspace.getAbsolutePath();
//копирование тестов по конфигурациям.
int actual_tasks_count = 0;
for (SapforConfiguration configuration: data.sapforConfigurations.values()){
//--
SapforConfiguration_json configuration_json = new SapforConfiguration_json();
configuration_json.id = configuration.id;
configuration_json.flags = configuration.getFlags();
configuration_json.codes.add(PassCode_2021.SPF_CorrectCodeStylePass); //всегда добавляется.
configuration_json.codes.addAll(configuration.getPassCodes());
//--->>
package_json.configurations.add(configuration_json);
//-->>
File configurationWorkspace = new File(packageWorkspace, String.valueOf(configuration.id));
FileUtils.forceMkdir(configurationWorkspace);
//--->>>
for (Test test : data.tests.values()) {
File test_root = new File(configurationWorkspace, test.description);
Utils.CheckAndCleanDirectory(test_root);
FileUtils.copyDirectory(new File(Global.TestsDirectory, String.valueOf(test.id)), test_root);
actual_tasks_count++;
}
}
sapforTasksPackage.tasksCount = actual_tasks_count;
//копирование SAPFOR
File sapforFile = new File(sapforTasksPackage.workspace, Utils.getDateName("SAPFOR_F"));
FileUtils.copyFile(sapfor_src, sapforFile);
if (!sapforFile.setExecutable(true))
throw new Exception("Не удалось сделать файл " + sapforFile.getName() + " исполняемым!");
sapforTasksPackage.sapfor_process_name = package_json.sapfor_drv = sapforFile.getName();
//--->>
//копирование визуализатора
File visualiser = new File(sapforTasksPackage.workspace, "VisualSapfor.jar");
FileUtils.copyFile(new File(Global.Home, "TestingSystem.jar"), visualiser);
//создание настроек
GlobalProperties properties = new GlobalProperties();
properties.Mode = Current.Mode.Package;
Utils.jsonToFile(properties, new File(sapforTasksPackage.workspace, "properties"));
//создание инструкции
File package_json_file = new File(sapforTasksPackage.workspace, "package_json");
Utils.jsonToFile(package_json, package_json_file);
//подготовка пакетного режима. Запустит его уже очередь.
Utils.createScript(packageWorkspace, packageWorkspace, "start", "java -jar VisualSapfor.jar");
//--
sapforTasksPackage.state = TasksPackageState.RunningPreparation;
}
void PackageStart() throws Exception {
System.out.println("start sapfor package " + sapforTasksPackage.id);
File workspace = new File(sapforTasksPackage.workspace);
File script = new File(sapforTasksPackage.workspace, "start");
ProcessBuilder procBuilder = new ProcessBuilder(script.getAbsolutePath());
procBuilder.directory(workspace);
procBuilder.start();
//--->>
File started = new File(sapforTasksPackage.workspace, Constants.STARTED);
while (!started.exists()) {
System.out.println("waiting for package start...");
Utils.sleep(1000);
}
//-->>
sapforTasksPackage.state = TasksPackageState.RunningExecution;
planner.UpdateSapforPackage();
System.out.println("done");
}
void CheckPackageState() throws Exception {
System.out.println("check sapfor package " + sapforTasksPackage.id);
File done = new File(sapforTasksPackage.workspace, Constants.DONE);
File aborted = new File(sapforTasksPackage.workspace, Constants.ABORTED);
if (done.exists()) {
sapforTasksPackage.state = TasksPackageState.Analysis;
planner.UpdateSapforPackage();
System.out.println("package done, start Analysis");
} else if (aborted.exists()) {
sapforTasksPackage.state = TasksPackageState.Aborted;
planner.UpdateSapforPackage();
System.out.println("package aborted");
} else {
System.out.println("package running");
}
}
//--
public boolean packageNeedsKill() throws Exception {
return (boolean) planner.ServerCommand(ServerCode.CheckPackageToKill, String.valueOf(sapforTasksPackage.id));
}
public void killPackage() throws Exception {
//----
File interrupt_file = new File(sapforTasksPackage.workspace, Constants.INTERRUPT);
//----
FileUtils.writeStringToFile(interrupt_file, new Date().toString());
File aborted_file = new File(sapforTasksPackage.workspace, Constants.ABORTED);
do {
System.out.println("waiting for interrupt...");
Thread.sleep(1000);
} while (!aborted_file.exists());
System.out.println("coup de grace..");
String kill_command = "killall -SIGKILL " + sapforTasksPackage.sapfor_process_name;
System.out.println(kill_command);
Process killer = Runtime.getRuntime().exec(kill_command);
killer.waitFor();
System.out.println("done!");
}
public void AnalysePackage() throws Exception {
File results_json_file = new File(sapforTasksPackage.workspace, Constants.results_json);
if (results_json_file.exists()) {
SapforTasksResults_json results_json = (SapforTasksResults_json) Utils.jsonFromFile(results_json_file, SapforTasksResults_json.class);
results_json.SortTasks();
//--
sapforTasksPackage.summary = results_json.getEmailSummary();
for (SapforTask task : results_json.tasks) {
//--
task.versions = null;
task.variants = null;
}
planner.ServerCommand(ServerCode.PublishSapforPackageTasks, planner.email, new Vector<>(results_json.tasks));
}
//Очистка
//очистка служебных файлов.
Utils.deleteFilesByExtensions(new File(sapforTasksPackage.workspace),
"proj", "dep", "jar", "sh", "exe", "bat");
}
public void Perform() throws Exception {
if (packageNeedsKill()) {
System.out.println("PACKAGE " + sapforTasksPackage.id + " NEEDS TO KILL");
killPackage();
sapforTasksPackage.state = TasksPackageState.Aborted;
planner.UpdateSapforPackage();
} else {
switch (sapforTasksPackage.state) {
case TestsSynchronize:
TestsSynchronize();
planner.UpdateSapforPackage();
break;
case RunningPreparation:
PackageStart();
break;
case RunningExecution:
CheckPackageState();
break;
case Analysis:
AnalysePackage();
sapforTasksPackage.state = TasksPackageState.Done;
planner.UpdateSapforPackage();
break;
default:
break;
}
}
}
}

View File

@@ -0,0 +1,33 @@
package TestingSystem.SAPFOR.ServerSapfor;
import Common.Database.riDBObject;
import Common.Utils.Utils;
import ProjectData.LanguageName;
import com.sun.org.glassfish.gmbal.Description;
import java.util.Date;
public class ServerSapfor extends riDBObject {
//--------------------------------------------------------------------->>>
@Description("IGNORE")
public static String version_command = "-ver";//команда запроса версии компилятора.
@Description("IGNORE")
public static String help_command = "-help";// команда запроса help
//--------------------------------------------------------------------->>>
public LanguageName languageName = LanguageName.fortran;
public String home_path = ""; //домашняя папка.
public String call_command = ""; //полная команда вызова.
public String version = "?";
public long buildDate = 0;
public Date getBuildDate() {
return new Date(buildDate);
}
//--
public ServerSapfor() {
}
@Override
public String toString() {
return call_command;
}
public String getVersionCommand() {
return Utils.DQuotes(call_command) + " " + version_command;
}
}

View File

@@ -0,0 +1,46 @@
package TestingSystem.SAPFOR.ServerSapfor;
import Common.Current;
import Common.Database.iDBTable;
import Common.UI.DataSetControlForm;
import Common.UI.Tables.TableRenderers;
public class ServerSapforsDBTable extends iDBTable<ServerSapfor> {
public ServerSapforsDBTable() {
super(ServerSapfor.class);
}
@Override
public String getSingleDescription() {
return "SAPFOR";
}
@Override
public String getPluralDescription() {
return "SAPFOR";
}
@Override
public Current CurrentName() {
return Current.ServerSapfor;
}
@Override
public String[] getUIColumnNames() {
return new String[]{"версия", "дата сборки"};
}
@Override
public Object getFieldAt(ServerSapfor object, int columnIndex) {
switch (columnIndex) {
case 1:
return object.version;
case 2:
return object.getBuildDate();
}
return null;
}
@Override
protected DataSetControlForm createUI() {
return new DataSetControlForm(this) {
@Override
protected void AdditionalInitColumns() {
// columns.get(0).setVisible(false);
columns.get(2).setRenderer(TableRenderers.RendererDate);
}
};
}
}