no message
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
package _VisualDVM.TestingSystem.Common.Configuration;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import Common.Database.Objects.riDBObject;
|
||||
import Common.Utils.CommonUtils;
|
||||
import Common.Utils.TextLog;
|
||||
import _VisualDVM.TestingSystem.Common.Group.Group;
|
||||
import _VisualDVM.TestingSystem.Common.Group.Json.GroupsJson;
|
||||
import _VisualDVM.TestingSystem.Common.Settings.Json.SettingsArrayJson;
|
||||
import _VisualDVM.TestingSystem.Common.Settings.Settings;
|
||||
import _VisualDVM.TestingSystem.Common.Test.Json.TestsJson;
|
||||
import _VisualDVM.TestingSystem.Common.Test.Test;
|
||||
import com.sun.org.glassfish.gmbal.Description;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Vector;
|
||||
public class Configuration extends riDBObject {
|
||||
//конфигурация = данные для пакета.
|
||||
//группы
|
||||
//тесты
|
||||
//настройки тестируемого объекта
|
||||
//пакет = запуск конфигурация + тестируемый объект
|
||||
//---
|
||||
public int maxtime = 300;
|
||||
@Description("DEFAULT 0")
|
||||
public int autoTesting = 0;
|
||||
@Description("DEFAULT 1")
|
||||
public int kernels = 1; //ядра
|
||||
//----
|
||||
public String printAuto() {
|
||||
return autoTesting > 0 ? "Да" : "Нет";
|
||||
}
|
||||
public void SwitchAuto() {
|
||||
autoTesting = (autoTesting == 0) ? 1 : 0;
|
||||
}
|
||||
public ImageIcon GetAutoIcon() {
|
||||
return CommonUtils.getIcon("/Common/icons/" + (autoTesting == 1 ? "RedPick" : "NotPick") + ".png");
|
||||
}
|
||||
//--
|
||||
@Description("DEFAULT ''")
|
||||
public String packedGroupsJson = "";
|
||||
@Description("DEFAULT ''")
|
||||
public String packedTestsJson = "";
|
||||
@Description("DEFAULT ''")
|
||||
public String packedSettingsJson = "";
|
||||
//--
|
||||
public void saveGroupsAsJson(Vector<Group> groups) {
|
||||
packedGroupsJson = CommonUtils.gson.toJson(new GroupsJson(groups));
|
||||
}
|
||||
public void saveTestsAsJson(Vector<Test> tests) {
|
||||
packedTestsJson = CommonUtils.gson.toJson(new TestsJson(tests));
|
||||
}
|
||||
public void saveSettingsAsJson(Vector<Settings> settings) {
|
||||
packedSettingsJson = CommonUtils.gson.toJson(new SettingsArrayJson(settings));
|
||||
}
|
||||
//--
|
||||
@Override
|
||||
public void SynchronizeFields(DBObject src) {
|
||||
super.SynchronizeFields(src);
|
||||
Configuration c = (Configuration) src;
|
||||
//--
|
||||
maxtime = c.maxtime;
|
||||
autoTesting = c.autoTesting;
|
||||
kernels = c.kernels;
|
||||
//-
|
||||
packedGroupsJson = c.packedGroupsJson;
|
||||
packedTestsJson = c.packedTestsJson;
|
||||
packedSettingsJson = c.packedSettingsJson;
|
||||
}
|
||||
//- для автоматического тестирования главным образом.
|
||||
public boolean validate(TextLog log) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package _VisualDVM.TestingSystem.Common.Configuration.Json;
|
||||
import _VisualDVM.TestingSystem.Common.Configuration.Configuration;
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
import java.io.Serializable;
|
||||
public class ConfigurationJson implements Serializable {
|
||||
@Expose
|
||||
public int id;
|
||||
@Expose
|
||||
public String description;
|
||||
public ConfigurationJson(Configuration configuration){
|
||||
id=configuration.id;
|
||||
description= configuration.description;
|
||||
}
|
||||
public ConfigurationJson(){}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package _VisualDVM.TestingSystem.Common.Configuration.Json;
|
||||
import _VisualDVM.TestingSystem.Common.Configuration.Configuration;
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
public class ConfigurationsJson implements Serializable {
|
||||
@Expose
|
||||
public List<ConfigurationJson> array =new Vector<>();
|
||||
public ConfigurationsJson(){
|
||||
}
|
||||
//при создании пакета.
|
||||
public ConfigurationsJson(Vector<? extends Configuration> configurations){
|
||||
array =new Vector<>();
|
||||
for (Configuration configuration:configurations)
|
||||
array.add(new ConfigurationJson(configuration));
|
||||
}
|
||||
}
|
||||
117
src/_VisualDVM/TestingSystem/Common/Group/Group.java
Normal file
117
src/_VisualDVM/TestingSystem/Common/Group/Group.java
Normal file
@@ -0,0 +1,117 @@
|
||||
package _VisualDVM.TestingSystem.Common.Group;
|
||||
import Common.Utils.CommonUtils;
|
||||
import Common.Visual.CommonUI;
|
||||
import _VisualDVM.Current;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import Common.Database.Objects.riDBObject;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.Visual.UI;
|
||||
import _VisualDVM.Utils;
|
||||
import _VisualDVM.ProjectData.Files.ProjectFile;
|
||||
import _VisualDVM.ProjectData.LanguageName;
|
||||
import _VisualDVM.TestingSystem.Common.Test.Test;
|
||||
import _VisualDVM.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 (CommonUI.isActive())
|
||||
UI.getMainWindow().ShowCheckedTestsCount();
|
||||
}
|
||||
//--
|
||||
//-
|
||||
public static void generateForLanguage(
|
||||
String dvm_drv,
|
||||
LinkedHashMap<LanguageName, Vector<ProjectFile>> 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 (ProjectFile program : programs.get(language)) {
|
||||
//--
|
||||
String object = CommonUtils.DQuotes(language + "_" + i + ".o");
|
||||
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=" + CommonUtils.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(Test test, String dvm_drv, String flags_in) {
|
||||
//----->>
|
||||
LinkedHashMap<LanguageName, Vector<ProjectFile>> programs = test.getPrograms();
|
||||
Vector<String> titles = new Vector<>();
|
||||
Vector<String> objects = new Vector<>();
|
||||
Vector<String> bodies = new Vector<>();
|
||||
String binary = CommonUtils.DQuotes("0");
|
||||
//----->>
|
||||
generateForLanguage(dvm_drv, programs, language, titles, objects, bodies, flags_in);
|
||||
//----->>
|
||||
return String.join("\n",
|
||||
"LINK_COMMAND=" + CommonUtils.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));
|
||||
}
|
||||
}
|
||||
149
src/_VisualDVM/TestingSystem/Common/Group/GroupsDBTable.java
Normal file
149
src/_VisualDVM/TestingSystem/Common/Group/GroupsDBTable.java
Normal file
@@ -0,0 +1,149 @@
|
||||
package _VisualDVM.TestingSystem.Common.Group;
|
||||
import Common.Visual.CommonUI;
|
||||
import _VisualDVM.Current;
|
||||
import Common.Visual.DataSetControlForm;
|
||||
import Common.Visual.Windows.Dialog.DBObjectDialog;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import Common.Database.Tables.FKBehaviour;
|
||||
import Common.Database.Tables.FKCurrentObjectBehaviuor;
|
||||
import Common.Database.Tables.FKDataBehaviour;
|
||||
import Common.Database.Tables.iDBTable;
|
||||
import Common.Visual.DBObjectFilter;
|
||||
import Common.Visual.DataSetFilter;
|
||||
import _VisualDVM.ProjectData.LanguageName;
|
||||
import _VisualDVM.TestingSystem.Common.Group.UI.GroupFields;
|
||||
import _VisualDVM.TestingSystem.Common.Test.Test;
|
||||
import _VisualDVM.TestingSystem.Common.Test.TestType;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
//-
|
||||
public class GroupsDBTable extends iDBTable<Group> {
|
||||
public static boolean filterMyOnly = false;
|
||||
public GroupsDBTable() {
|
||||
super(Group.class);
|
||||
}
|
||||
//------------------------------------------------>>>
|
||||
@Override
|
||||
protected void createFilters() {
|
||||
filters.add(new Common.Visual.DataSetFilter<Group>("Тип", this) {
|
||||
@Override
|
||||
public void fill() {
|
||||
for (TestType type : TestType.values())
|
||||
field_filters.add(new Common.Visual.DBObjectFilter<Group>(dataSet, type.getDescription()) {
|
||||
@Override
|
||||
protected boolean validate(Group object) {
|
||||
return object.type.equals(type);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
filters.add(new DataSetFilter<Group>("Язык", this) {
|
||||
@Override
|
||||
public void fill() {
|
||||
for (LanguageName languageName : LanguageName.values()) {
|
||||
field_filters.add(new DBObjectFilter<Group>(dataSet, languageName.getDescription()) {
|
||||
@Override
|
||||
protected boolean validate(Group object) {
|
||||
return object.language.equals(languageName);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@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
|
||||
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);
|
||||
CommonUI.TrySelect(fields.cbType, Result.type);
|
||||
CommonUI.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();
|
||||
}
|
||||
};
|
||||
}
|
||||
public boolean containsGroupWithDescription(String description_in) {
|
||||
for (Group group : Data.values()) {
|
||||
if (group.description.equalsIgnoreCase(description_in))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public Group getGroupByDescription(LanguageName language_in,String description_in) {
|
||||
for (Group group : Data.values()) {
|
||||
if (group.sender_address.equals("vmk-post@yandex.ru")&&
|
||||
group.language.equals(language_in)&&group.description.equalsIgnoreCase(description_in))
|
||||
return group;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
36
src/_VisualDVM/TestingSystem/Common/Group/GroupsMenuBar.java
Normal file
36
src/_VisualDVM/TestingSystem/Common/Group/GroupsMenuBar.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package _VisualDVM.TestingSystem.Common.Group;
|
||||
import Common.Utils.CommonUtils;
|
||||
import _VisualDVM.Global;
|
||||
import Common.Visual.Menus.DataMenuBar;
|
||||
import Common.Visual.Controls.MenuBarButton;
|
||||
import _VisualDVM.TestingSystem.Common.Group.UI.AddGroupMenu;
|
||||
import _VisualDVM.TestingSystem.Common.Group.UI.EditGroupMenu;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
|
||||
import javax.swing.*;
|
||||
public class GroupsMenuBar extends DataMenuBar {
|
||||
public GroupsMenuBar() {
|
||||
super("группы",
|
||||
PassCode_2021.SynchronizeTests,
|
||||
PassCode_2021.ConvertCorrectnessTests
|
||||
);
|
||||
addMenus(new AddGroupMenu(), new EditGroupMenu());
|
||||
addPasses(PassCode_2021.DeleteGroup);
|
||||
add(new JSeparator());
|
||||
add(new MenuBarButton() {
|
||||
{
|
||||
setText("Свои");
|
||||
setToolTipText("Отображать только группы тестов авторства пользователя");
|
||||
Mark();
|
||||
addActionListener(e -> {
|
||||
GroupsDBTable.filterMyOnly = !GroupsDBTable.filterMyOnly;
|
||||
Mark();
|
||||
Global.testingServer.db.groups.ShowUI();
|
||||
});
|
||||
}
|
||||
public void Mark() {
|
||||
setIcon(CommonUtils.getIcon(GroupsDBTable.filterMyOnly ? "/icons/Pick.png" : "/icons/NotPick.png"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package _VisualDVM.TestingSystem.Common.Group.Json;
|
||||
import _VisualDVM.TestingSystem.Common.Group.Group;
|
||||
import com.google.gson.annotations.Expose;
|
||||
public class GroupJson {
|
||||
@Expose
|
||||
public int id;
|
||||
@Expose
|
||||
public String description;
|
||||
@Expose
|
||||
public String language;
|
||||
public GroupJson(Group group) {
|
||||
id = group.id;
|
||||
language = group.language.toString();
|
||||
description = group.description;
|
||||
}
|
||||
public GroupJson() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package _VisualDVM.TestingSystem.Common.Group.Json;
|
||||
import _VisualDVM.TestingSystem.Common.Group.Group;
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
public class GroupsJson implements Serializable {
|
||||
@Expose
|
||||
public List<GroupJson> array = new Vector<>();
|
||||
public GroupsJson() {
|
||||
}
|
||||
//при создании пакета.
|
||||
public GroupsJson(Vector<Group> groups) {
|
||||
array = new Vector<>();
|
||||
for (Group group : groups)
|
||||
array.add(new GroupJson(group));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package _VisualDVM.TestingSystem.Common.Group.UI;
|
||||
import _VisualDVM.Visual.Menus.VisualiserMenu;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
public class AddGroupMenu extends VisualiserMenu {
|
||||
public AddGroupMenu() {
|
||||
super("", "/icons/RedAdd.png");
|
||||
addPasses(PassCode_2021.PublishGroup,PassCode_2021.CreateGroupFromDirectory,PassCode_2021.CreateGroupFromFiles);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package _VisualDVM.TestingSystem.Common.Group.UI;
|
||||
import _VisualDVM.Visual.Menus.VisualiserMenu;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
public class EditGroupMenu extends VisualiserMenu {
|
||||
public EditGroupMenu() {
|
||||
super("", "/icons/Edit.png" );
|
||||
addPasses(PassCode_2021.EditGroup, PassCode_2021.ReplaceTestsFromFiles);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="_VisualDVM.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>
|
||||
@@ -0,0 +1,32 @@
|
||||
package _VisualDVM.TestingSystem.Common.Group.UI;
|
||||
import Common.Visual.TextField.StyledTextField;
|
||||
import Common.Visual.Windows.Dialog.DialogFields;
|
||||
import _VisualDVM.ProjectData.LanguageName;
|
||||
import _VisualDVM.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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package _VisualDVM.TestingSystem.Common.MachineProcess;
|
||||
import Common.CommonConstants;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import Common.Mode;
|
||||
import Common.Utils.CommonUtils;
|
||||
import _VisualDVM.Constants;
|
||||
import _VisualDVM.GlobalProperties;
|
||||
import _VisualDVM.Utils;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMPackage.DVMPackage;
|
||||
import _VisualDVM.Global;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.InetAddress;
|
||||
import java.util.Vector;
|
||||
public class MachineProcess extends DBObject {
|
||||
public String id = "";
|
||||
public String machineAddress = "";
|
||||
public int machinePort = CommonConstants.Nan;
|
||||
public String userName = "";
|
||||
public String userPassword = "";
|
||||
public String userWorkspace = "";
|
||||
public String testingSystemRoot = "";
|
||||
public String serverName = "";
|
||||
public MachineProcess() {
|
||||
}
|
||||
public MachineProcess(MachineProcess p) {
|
||||
SynchronizeFields(p);
|
||||
}
|
||||
public MachineProcess(DVMPackage p) {
|
||||
machineAddress = p.machine_address;
|
||||
machinePort = p.machine_port;
|
||||
userName = p.user_name;
|
||||
userPassword = p.user_password;
|
||||
userWorkspace = p.user_workspace;
|
||||
testingSystemRoot =CommonUtils.getHomePath();
|
||||
serverName = Global.testingServer.name;
|
||||
id = CommonUtils.getDateName(machineAddress + "_" + machinePort + "_" + userName);
|
||||
}
|
||||
@Override
|
||||
public Object getPK() {
|
||||
return id;
|
||||
}
|
||||
@Override
|
||||
public void SynchronizeFields(DBObject src) {
|
||||
super.SynchronizeFields(src);
|
||||
MachineProcess p = (MachineProcess) src;
|
||||
machineAddress = p.machineAddress;
|
||||
machinePort = p.machinePort;
|
||||
userName = p.userName;
|
||||
userPassword = p.userPassword;
|
||||
userWorkspace = p.userWorkspace;
|
||||
testingSystemRoot = p.testingSystemRoot;
|
||||
serverName = p.serverName;
|
||||
}
|
||||
public String getUniqueKey() {
|
||||
Vector<String> res = new Vector<>();
|
||||
res.add(machineAddress);
|
||||
res.add(String.valueOf(machinePort));
|
||||
res.add(userName);
|
||||
res.add(userWorkspace);
|
||||
return String.join("_", res);
|
||||
}
|
||||
public File getWorkspace() {
|
||||
return new File(Global.MachinesDirectory, id);
|
||||
}
|
||||
public File getStartedFile() {
|
||||
return new File(getWorkspace(), Constants.STARTED);
|
||||
}
|
||||
public File getAbortedFile() {
|
||||
return new File(getWorkspace(), Constants.ABORTED);
|
||||
}
|
||||
//---
|
||||
public boolean isAborted() {
|
||||
File aborted = getAbortedFile();
|
||||
return aborted.exists();
|
||||
}
|
||||
public boolean isStarted() {
|
||||
File started = getStartedFile();
|
||||
return started.exists();
|
||||
}
|
||||
public boolean isLocal() {
|
||||
boolean local = false;
|
||||
try {
|
||||
InetAddress address = InetAddress.getByName(machineAddress);
|
||||
InetAddress localAddress = InetAddress.getByName(Global.properties.ServerAddress);
|
||||
local = localAddress.getHostAddress().equals(address.getHostAddress());
|
||||
} catch (Exception ex) {
|
||||
CommonUtils.MainLog.PrintException(ex);
|
||||
}
|
||||
return local;
|
||||
}
|
||||
//--
|
||||
public void Start() {
|
||||
try {
|
||||
File workspace = getWorkspace();
|
||||
Utils.CheckAndCleanDirectory(workspace);
|
||||
//копирование визуализатора
|
||||
File src = new File(CommonUtils.getHomeDirectory(), "_VisualDVM.TestingSystem.jar");
|
||||
File supervisor = new File(workspace, "VisualSapfor.jar");
|
||||
FileUtils.copyFile(src, supervisor);
|
||||
//создание настроек
|
||||
GlobalProperties properties = new GlobalProperties(Global.properties);
|
||||
properties.Mode = Mode.MachineQueue;
|
||||
CommonUtils.jsonToFile(properties, new File(workspace, "properties"));
|
||||
Vector<String> args = new Vector<>();
|
||||
args.add(CommonUtils.DQuotes(machineAddress));
|
||||
args.add(CommonUtils.DQuotes(machinePort));
|
||||
args.add(CommonUtils.DQuotes(userName));
|
||||
args.add(CommonUtils.DQuotes(userPassword));
|
||||
args.add(CommonUtils.DQuotes(userWorkspace));
|
||||
args.add(CommonUtils.DQuotes(testingSystemRoot));
|
||||
args.add(CommonUtils.DQuotes(Global.testingServer.name));
|
||||
//--
|
||||
Utils.startScript(workspace, workspace,
|
||||
"start",
|
||||
"java -jar VisualSapfor.jar " +
|
||||
String.join(" ", args) + " 1>out.txt 2>err.txt");
|
||||
//---
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package _VisualDVM.TestingSystem.Common.MachineProcess;
|
||||
import Common.Database.Tables.DataSet;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMPackage.DVMPackage;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
public class MachineProcessSet extends DataSet<String, MachineProcess> {
|
||||
public MachineProcessSet() {
|
||||
super(String.class, MachineProcess.class);
|
||||
}
|
||||
public LinkedHashMap<String, MachineProcess> getSortedByKeys() {
|
||||
LinkedHashMap<String, MachineProcess> res = new LinkedHashMap<>();
|
||||
for (MachineProcess process : Data.values())
|
||||
res.put(process.getUniqueKey(), process);
|
||||
return res;
|
||||
}
|
||||
public boolean hasProcessForPackage(DVMPackage package_in) {
|
||||
for (MachineProcess process : Data.values()) {
|
||||
if (
|
||||
process.machineAddress.equals(package_in.machine_address) &&
|
||||
process.machinePort == package_in.machine_port &&
|
||||
process.userName.equals(package_in.user_name) &&
|
||||
process.userWorkspace.equals(package_in.user_workspace)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package _VisualDVM.TestingSystem.Common.MachineProcess;
|
||||
public enum MachineProcessState {
|
||||
Inactive,
|
||||
Active,
|
||||
Aborted
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package _VisualDVM.TestingSystem.Common.Settings.Json;
|
||||
import _VisualDVM.TestingSystem.Common.Settings.Settings;
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
public class SettingsArrayJson {
|
||||
@Expose
|
||||
public List<SettingsJson> array =new Vector<>();
|
||||
public SettingsArrayJson(){
|
||||
}
|
||||
//при создании пакета.
|
||||
public SettingsArrayJson(Vector<? extends Settings> settings_in){
|
||||
array =new Vector<>();
|
||||
for (Settings settings: settings_in)
|
||||
array.add(new SettingsJson(settings));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package _VisualDVM.TestingSystem.Common.Settings.Json;
|
||||
import _VisualDVM.TestingSystem.Common.Settings.Settings;
|
||||
import com.google.gson.annotations.Expose;
|
||||
public class SettingsJson {
|
||||
@Expose
|
||||
public int id;
|
||||
@Expose
|
||||
public String description;
|
||||
public SettingsJson(Settings settings) {
|
||||
id = settings.id;
|
||||
description = settings.description;
|
||||
}
|
||||
public SettingsJson() {
|
||||
}
|
||||
}
|
||||
15
src/_VisualDVM/TestingSystem/Common/Settings/Settings.java
Normal file
15
src/_VisualDVM/TestingSystem/Common/Settings/Settings.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package _VisualDVM.TestingSystem.Common.Settings;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import Common.Database.Objects.riDBObject;
|
||||
import Common.Utils.TextLog;
|
||||
//предопределенный набор настроек тестируемой системы. сохраняется для упрощения.
|
||||
public abstract class Settings extends riDBObject {
|
||||
public String flags="";
|
||||
@Override
|
||||
public void SynchronizeFields(DBObject src) {
|
||||
super.SynchronizeFields(src);
|
||||
Settings s = (Settings) src;
|
||||
flags=s.flags;
|
||||
}
|
||||
public boolean validate(TextLog Log){return true;}
|
||||
}
|
||||
17
src/_VisualDVM/TestingSystem/Common/TaskThread.java
Normal file
17
src/_VisualDVM/TestingSystem/Common/TaskThread.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package _VisualDVM.TestingSystem.Common;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.PerformSapforTask;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforTask.SapforTask;
|
||||
|
||||
import java.io.File;
|
||||
public class TaskThread extends Thread {
|
||||
public SapforTask task = null;
|
||||
public TaskThread(SapforTask task_, File sapfor_drv) {
|
||||
super(() -> {
|
||||
while (!task_.state.isComplete()) {
|
||||
task_.Reset();
|
||||
new PerformSapforTask().Do(task_,sapfor_drv);
|
||||
}
|
||||
});
|
||||
task = task_;
|
||||
}
|
||||
}
|
||||
123
src/_VisualDVM/TestingSystem/Common/TasksPackageState.java
Normal file
123
src/_VisualDVM/TestingSystem/Common/TasksPackageState.java
Normal file
@@ -0,0 +1,123 @@
|
||||
package _VisualDVM.TestingSystem.Common;
|
||||
import Common.Visual.StatusEnum;
|
||||
import Common.Visual.Fonts.VisualiserFonts;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Vector;
|
||||
import java.util.stream.Collectors;
|
||||
public enum TasksPackageState implements StatusEnum {
|
||||
Draft,
|
||||
//--
|
||||
Inactive, //пакет просто есть. не запущен.
|
||||
Queued,
|
||||
//--
|
||||
TestsSynchronize, //оставить.
|
||||
PackageWorkspaceCreation,
|
||||
PackageStart,
|
||||
//
|
||||
CompilationWorkspacesCreation,
|
||||
CompilationPreparation,
|
||||
CompilationExecution,
|
||||
//-
|
||||
RunningWorkspacesCreation,
|
||||
RunningPreparation,
|
||||
RunningExecution,
|
||||
//--
|
||||
RunningEnd, //скачка архива
|
||||
Analysis,
|
||||
//-
|
||||
Done,
|
||||
Aborted,
|
||||
ConnectionError,
|
||||
DoneWithErrors
|
||||
;
|
||||
public boolean isActive() {
|
||||
switch (this) {
|
||||
case Inactive:
|
||||
case Done:
|
||||
case DoneWithErrors:
|
||||
case Aborted:
|
||||
case Draft:
|
||||
case ConnectionError:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public boolean isDone() {
|
||||
switch (this) {
|
||||
case Done:
|
||||
case DoneWithErrors:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VisualiserFonts getFont() {
|
||||
switch (this) {
|
||||
case TestsSynchronize:
|
||||
case Analysis:
|
||||
case Draft:
|
||||
return VisualiserFonts.BlueState;
|
||||
case CompilationExecution:
|
||||
case RunningExecution:
|
||||
return VisualiserFonts.ProgressState;
|
||||
case Done:
|
||||
return VisualiserFonts.GoodState;
|
||||
case DoneWithErrors:
|
||||
return VisualiserFonts.BadState;
|
||||
default:
|
||||
return StatusEnum.super.getFont();
|
||||
}
|
||||
}
|
||||
//-
|
||||
public String getDescription() {
|
||||
switch (this) {
|
||||
case Inactive:
|
||||
return "неактивен";
|
||||
case Draft:
|
||||
return "Подготовка к публикации";
|
||||
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 Done:
|
||||
return "завершен";
|
||||
case ConnectionError:
|
||||
return "сбой связи";
|
||||
case DoneWithErrors:
|
||||
return "завершен с ошибками";
|
||||
default:
|
||||
return StatusEnum.super.getDescription();
|
||||
}
|
||||
}
|
||||
|
||||
public Vector<TasksPackageState> getHigherStates(){
|
||||
return Arrays.stream(values()).filter(state -> state.ordinal() > this.ordinal()).collect(Collectors.toCollection(Vector::new));
|
||||
}
|
||||
|
||||
}
|
||||
13
src/_VisualDVM/TestingSystem/Common/Test/Json/TestJson.java
Normal file
13
src/_VisualDVM/TestingSystem/Common/Test/Json/TestJson.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package _VisualDVM.TestingSystem.Common.Test.Json;
|
||||
import _VisualDVM.TestingSystem.Common.Test.Test;
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
import java.io.Serializable;
|
||||
public class TestJson implements Serializable {
|
||||
@Expose
|
||||
public int id;
|
||||
public TestJson(Test test){
|
||||
id=test.id;
|
||||
}
|
||||
public TestJson(){}
|
||||
}
|
||||
19
src/_VisualDVM/TestingSystem/Common/Test/Json/TestsJson.java
Normal file
19
src/_VisualDVM/TestingSystem/Common/Test/Json/TestsJson.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package _VisualDVM.TestingSystem.Common.Test.Json;
|
||||
import _VisualDVM.TestingSystem.Common.Test.Test;
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
public class TestsJson implements Serializable {
|
||||
@Expose
|
||||
public List<TestJson> array = new Vector<>();
|
||||
public TestsJson() {
|
||||
}
|
||||
//при создании пакета.
|
||||
public TestsJson(Vector<Test> tests) {
|
||||
array = new Vector<>();
|
||||
for (Test test : tests)
|
||||
array.add(new TestJson(test));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package _VisualDVM.TestingSystem.Common.Test;
|
||||
import _VisualDVM.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<>();
|
||||
}
|
||||
135
src/_VisualDVM/TestingSystem/Common/Test/Test.java
Normal file
135
src/_VisualDVM/TestingSystem/Common/Test/Test.java
Normal file
@@ -0,0 +1,135 @@
|
||||
package _VisualDVM.TestingSystem.Common.Test;
|
||||
import Common.CommonConstants;
|
||||
import Common.Utils.CommonUtils;
|
||||
import Common.Visual.CommonUI;
|
||||
import _VisualDVM.Current;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import Common.Database.Objects.riDBObject;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.Visual.UI;
|
||||
import _VisualDVM.ProjectData.Files.FileState;
|
||||
import _VisualDVM.ProjectData.Files.FileType;
|
||||
import _VisualDVM.ProjectData.Files.ProjectFile;
|
||||
import _VisualDVM.ProjectData.LanguageName;
|
||||
import _VisualDVM.Repository.RepositoryRefuseException;
|
||||
import Visual_DVM_2021.Passes.All.UnzipFolderPass;
|
||||
import Visual_DVM_2021.Passes.All.ZipFolderPass;
|
||||
import com.sun.org.glassfish.gmbal.Description;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Vector;
|
||||
public class Test extends riDBObject {
|
||||
@Description("DEFAULT 0")
|
||||
public int min_dim = 0; //мин размерность теста.
|
||||
@Description("DEFAULT 0")
|
||||
public int max_dim = 0; //макс размерность теста.
|
||||
@Description("DEFAULT ''")
|
||||
public String args = ""; //аргументы командной строки. на всякий случай поле зарезервирую. пусть будут.
|
||||
@Description("DEFAULT -1")
|
||||
public int group_id = CommonConstants.Nan;
|
||||
@Override
|
||||
public void SynchronizeFields(DBObject src) {
|
||||
super.SynchronizeFields(src);
|
||||
Test t = (Test) src;
|
||||
min_dim = t.min_dim;
|
||||
max_dim = t.max_dim;
|
||||
args = t.args;
|
||||
group_id = t.group_id;
|
||||
}
|
||||
@Description("DEFAULT ''")
|
||||
public String files = ""; //файлы теста
|
||||
//--------------------------------------------->>>
|
||||
@Description("IGNORE")
|
||||
public String temp_project_name = "";
|
||||
@Description("IGNORE")
|
||||
public byte[] project_archive_bytes = null;
|
||||
//--------------------------------------------->>>
|
||||
public Test(Test test) {
|
||||
this.SynchronizeFields(test);
|
||||
}
|
||||
public Test() {
|
||||
}
|
||||
@Override
|
||||
public void select(boolean flag) {
|
||||
super.select(flag);
|
||||
if (CommonUI.isActive())
|
||||
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));
|
||||
}
|
||||
//--
|
||||
public File getTempArchive() {
|
||||
return new File(Global.TempDirectory, temp_project_name + ".zip");
|
||||
}
|
||||
public File getTempProject() {
|
||||
return new File(Global.TempDirectory, temp_project_name);
|
||||
}
|
||||
public boolean unpackProjectOnServer() throws Exception {
|
||||
File tmpArchive = new File(Global.TempDirectory, temp_project_name + ".zip");
|
||||
File tmpProject = new File(Global.TempDirectory, temp_project_name);
|
||||
File testProject = new File(Global.TestsDirectory, String.valueOf(id));
|
||||
File testArchive = new File(Global.TestsDirectory, id + ".zip");
|
||||
//--
|
||||
if (tmpArchive.exists())
|
||||
FileUtils.forceDelete(tmpArchive);
|
||||
if (tmpProject.exists())
|
||||
FileUtils.forceDelete(tmpProject);
|
||||
if (testProject.exists())
|
||||
FileUtils.forceDelete(testProject);
|
||||
if (testArchive.exists())
|
||||
FileUtils.forceDelete(testArchive);
|
||||
//--
|
||||
CommonUtils.bytesToFile(project_archive_bytes, tmpArchive); // распаковка байтов.
|
||||
//--
|
||||
UnzipFolderPass unzipFolderPass = new UnzipFolderPass();
|
||||
if (!unzipFolderPass.Do(
|
||||
tmpArchive.getAbsolutePath(),
|
||||
Global.TempDirectory.getAbsolutePath())) {
|
||||
return false;
|
||||
}
|
||||
//--
|
||||
FileUtils.moveDirectory(tmpProject, testProject);
|
||||
//--
|
||||
ZipFolderPass zip = new ZipFolderPass();
|
||||
if (!zip.Do(testProject.getAbsolutePath(), testArchive.getAbsolutePath()))
|
||||
throw new RepositoryRefuseException("Не удалось переписать архив проекта");
|
||||
return true;
|
||||
}
|
||||
public String getFilesForTable() {
|
||||
return files.replace("\n", ";");
|
||||
}
|
||||
public LinkedHashMap<LanguageName, Vector<ProjectFile>> getPrograms() {
|
||||
LinkedHashMap<LanguageName, Vector<ProjectFile>> res = new LinkedHashMap<>();
|
||||
//--
|
||||
res.put(LanguageName.fortran, new Vector<>());
|
||||
res.put(LanguageName.c, new Vector<>());
|
||||
res.put(LanguageName.cpp, new Vector<>());
|
||||
//--
|
||||
String[] files_names = files.split("\n");
|
||||
for (String file_name : files_names) {
|
||||
ProjectFile file = new ProjectFile(new File(file_name));
|
||||
//--
|
||||
if (!file.state.equals(FileState.Excluded) &&
|
||||
file.fileType.equals(FileType.program) &&
|
||||
(!file.languageName.equals(LanguageName.n)))
|
||||
res.get(file.languageName).add(file);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
126
src/_VisualDVM/TestingSystem/Common/Test/TestDBTable.java
Normal file
126
src/_VisualDVM/TestingSystem/Common/Test/TestDBTable.java
Normal file
@@ -0,0 +1,126 @@
|
||||
package _VisualDVM.TestingSystem.Common.Test;
|
||||
import _VisualDVM.Current;
|
||||
import Common.Database.Tables.iDBTable;
|
||||
import Common.Visual.DataSetControlForm;
|
||||
import Common.Visual.Windows.Dialog.DBObjectDialog;
|
||||
import _VisualDVM.TestingSystem.Common.Group.Group;
|
||||
import _VisualDVM.TestingSystem.Common.Test.UI.TestFields;
|
||||
|
||||
import java.util.Vector;
|
||||
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.min_dim;
|
||||
case 4:
|
||||
return object.max_dim;
|
||||
case 5:
|
||||
return object.getFilesForTable();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String[] getUIColumnNames() {
|
||||
return new String[]{
|
||||
"имя",
|
||||
"min_dim",
|
||||
"max_dim",
|
||||
"файлы"
|
||||
};
|
||||
}
|
||||
@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.sMinDim.setValue(Result.min_dim);
|
||||
fields.sMaxDim.setValue(Result.max_dim);
|
||||
}
|
||||
@Override
|
||||
public void ProcessResult() {
|
||||
Result.description = fields.tfName.getText();
|
||||
Result.min_dim = (int) fields.sMinDim.getValue();
|
||||
Result.max_dim = (int) fields.sMaxDim.getValue();
|
||||
if (!edit) {
|
||||
Result.sender_name = Current.getAccount().name;
|
||||
Result.sender_address = Current.getAccount().email;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
public boolean containsTestWithDescription(String description_in) {
|
||||
for (Test test : Data.values()) {
|
||||
if (test.description.equalsIgnoreCase(description_in))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public Test getTestByDescription(int group_id_in, String description_in) {
|
||||
for (Test test : Data.values()) {
|
||||
if (test.sender_address.equals("vmk-post@yandex.ru")&&
|
||||
(test.group_id==group_id_in)&&(test.description.equalsIgnoreCase(description_in)))
|
||||
return test;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public Vector<Test> getSelectedGroupTests(Group group) {
|
||||
Vector<Test> allTests = new Vector<>();
|
||||
Vector<Test> selectedTests = new Vector<>();
|
||||
//--
|
||||
for (Test test : Data.values()) {
|
||||
if (test.group_id == group.id) {
|
||||
allTests.add(test);
|
||||
if (test.isSelected()) selectedTests.add(test);
|
||||
}
|
||||
}
|
||||
return selectedTests.isEmpty()?allTests:selectedTests;
|
||||
}
|
||||
}
|
||||
22
src/_VisualDVM/TestingSystem/Common/Test/TestType.java
Normal file
22
src/_VisualDVM/TestingSystem/Common/Test/TestType.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package _VisualDVM.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 "?";
|
||||
}
|
||||
}
|
||||
}
|
||||
12
src/_VisualDVM/TestingSystem/Common/Test/TestsMenuBar.java
Normal file
12
src/_VisualDVM/TestingSystem/Common/Test/TestsMenuBar.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package _VisualDVM.TestingSystem.Common.Test;
|
||||
import Common.Visual.Menus.DataMenuBar;
|
||||
import _VisualDVM.TestingSystem.Common.Test.UI.AddTestMenu;
|
||||
import _VisualDVM.TestingSystem.Common.Test.UI.EditTestMenu;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
public class TestsMenuBar extends DataMenuBar {
|
||||
public TestsMenuBar() {
|
||||
super("тесты");
|
||||
addMenus(new AddTestMenu(), new EditTestMenu());
|
||||
addPasses(PassCode_2021.DownloadTest,PassCode_2021.DeleteTest);
|
||||
}
|
||||
}
|
||||
13
src/_VisualDVM/TestingSystem/Common/Test/UI/AddTestMenu.java
Normal file
13
src/_VisualDVM/TestingSystem/Common/Test/UI/AddTestMenu.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package _VisualDVM.TestingSystem.Common.Test.UI;
|
||||
import _VisualDVM.Visual.Menus.VisualiserMenu;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
public class AddTestMenu extends VisualiserMenu {
|
||||
public AddTestMenu() {
|
||||
super("Добавление теста", "/icons/RedAdd.png", false);
|
||||
add(Pass_2021.passes.get(PassCode_2021.CreateTestFromProject).createMenuItem());
|
||||
add(Pass_2021.passes.get(PassCode_2021.CreateTestFromDirectory).createMenuItem());
|
||||
add(Pass_2021.passes.get(PassCode_2021.CreateTestsFromFiles).createMenuItem());
|
||||
add(Pass_2021.passes.get(PassCode_2021.CreateTestFromSelectedFiles).createMenuItem());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package _VisualDVM.TestingSystem.Common.Test.UI;
|
||||
import _VisualDVM.Visual.Menus.VisualiserMenu;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
public class EditTestMenu extends VisualiserMenu {
|
||||
public EditTestMenu() {
|
||||
super("Редактирование теста", "/icons/Edit.png", false);
|
||||
add(Pass_2021.passes.get(PassCode_2021.EditTest).createMenuItem());
|
||||
add(Pass_2021.passes.get(PassCode_2021.ReplaceTestProject).createMenuItem());
|
||||
}
|
||||
}
|
||||
73
src/_VisualDVM/TestingSystem/Common/Test/UI/TestFields.form
Normal file
73
src/_VisualDVM/TestingSystem/Common/Test/UI/TestFields.form
Normal file
@@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="_VisualDVM.TestingSystem.Common.Test.UI.TestFields">
|
||||
<grid id="27dc6" binding="content" layout-manager="GridLayoutManager" row-count="4" 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="3" 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="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="2b54" class="javax.swing.JSpinner" binding="sMaxDim">
|
||||
<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">
|
||||
<preferred-size width="50" height="-1"/>
|
||||
<maximum-size width="50" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="82807" 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="c59e6" class="javax.swing.JSpinner" binding="sMinDim">
|
||||
<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>
|
||||
24
src/_VisualDVM/TestingSystem/Common/Test/UI/TestFields.java
Normal file
24
src/_VisualDVM/TestingSystem/Common/Test/UI/TestFields.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package _VisualDVM.TestingSystem.Common.Test.UI;
|
||||
import Common.Visual.TextField.StyledTextField;
|
||||
import Common.Visual.Windows.Dialog.DialogFields;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
public class TestFields implements DialogFields {
|
||||
public JTextField tfName;
|
||||
private JPanel content;
|
||||
public JSpinner sMinDim;
|
||||
public JSpinner sMaxDim;
|
||||
@Override
|
||||
public Component getContent() {
|
||||
return content;
|
||||
}
|
||||
private void createUIComponents() {
|
||||
// TODO: place custom component creation code here
|
||||
tfName = new StyledTextField();
|
||||
}
|
||||
public TestFields(){
|
||||
sMinDim.setModel(new SpinnerNumberModel(1, 0, 16,1));
|
||||
sMaxDim.setModel(new SpinnerNumberModel(1, 0, 16,1));
|
||||
}
|
||||
}
|
||||
97
src/_VisualDVM/TestingSystem/Common/TestingBar.java
Normal file
97
src/_VisualDVM/TestingSystem/Common/TestingBar.java
Normal file
@@ -0,0 +1,97 @@
|
||||
package _VisualDVM.TestingSystem.Common;
|
||||
import Common.Utils.CommonUtils;
|
||||
import Common.Visual.CommonUI;
|
||||
import _VisualDVM.Global;
|
||||
import Common.Visual.Controls.MenuBarButton;
|
||||
import _VisualDVM.Visual.Menus.VisualiserMenuBar;
|
||||
import Common.Visual.Fonts.VisualiserFonts;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
public class TestingBar extends VisualiserMenuBar {
|
||||
// public JLabel KernelsLabel;
|
||||
public JButton autorefreshButton;
|
||||
JSpinner sCheckTime;
|
||||
// JSpinner sKernels;
|
||||
JLabel serverAdminLabel;
|
||||
public TestingBar() {
|
||||
//-
|
||||
// KernelsLabel = addLabel("", "/icons/Kernels.png");
|
||||
// KernelsLabel.setHorizontalTextPosition(JLabel.LEFT);
|
||||
// KernelsLabel.setToolTipText("количество ядер, задействованное при тестировании");
|
||||
/*
|
||||
add(sKernels = new JSpinner());
|
||||
sKernels.setPreferredSize(new Dimension(60, 26));
|
||||
sKernels.setMaximumSize(new Dimension(60, 26));
|
||||
sKernels.setModel(new SpinnerNumberModel(Global.properties.TestingKernels, 1,
|
||||
Utils.getTestingMaxKernels(),
|
||||
1));
|
||||
sKernels.setValue(Global.properties.TestingKernels);
|
||||
UI.MakeSpinnerRapid(sKernels, e -> {
|
||||
Global.properties.updateField("TestingKernels", sKernels.getValue());
|
||||
});
|
||||
*/
|
||||
addLabel(" ");
|
||||
//--
|
||||
add(new MenuBarButton() {
|
||||
{
|
||||
setText("оповещение по email");
|
||||
setToolTipText("Оповещение о прогрессе выполнения пакета тестов");
|
||||
Mark();
|
||||
addActionListener(e -> {
|
||||
Global.properties.switchAndUpdateFlag("EmailOnTestingProgress");
|
||||
Mark();
|
||||
});
|
||||
}
|
||||
public void Mark() {
|
||||
setIcon(CommonUtils.getIcon(Global.properties.EmailOnTestingProgress ? "/icons/Pick.png" : "/icons/NotPick.png"));
|
||||
}
|
||||
});
|
||||
//--
|
||||
add(autorefreshButton = new MenuBarButton() {
|
||||
{
|
||||
setText("проверка раз в");
|
||||
setToolTipText("автоматическое обновление состояния пакета задач");
|
||||
Mark();
|
||||
addActionListener(e -> {
|
||||
Global.properties.switchAndUpdateFlag("AutoCheckTesting");
|
||||
//-
|
||||
if (Global.properties.AutoCheckTesting)
|
||||
TestingServer.TimerOn();
|
||||
else
|
||||
TestingServer.TimerOff();
|
||||
//-
|
||||
Mark();
|
||||
});
|
||||
}
|
||||
public void Mark() {
|
||||
setIcon(CommonUtils.getIcon(Global.properties.AutoCheckTesting ? "/icons/Pick.png" : "/icons/NotPick.png"));
|
||||
}
|
||||
});
|
||||
//--
|
||||
add(sCheckTime = new JSpinner());
|
||||
sCheckTime.setPreferredSize(new Dimension(60, 26));
|
||||
sCheckTime.setMaximumSize(new Dimension(60, 26));
|
||||
sCheckTime.setModel(new SpinnerNumberModel(Global.properties.CheckTestingIntervalSeconds, 10, 3600, 1));
|
||||
sCheckTime.setValue(Global.properties.CheckTestingIntervalSeconds);
|
||||
CommonUI.MakeSpinnerRapid(sCheckTime, e -> {
|
||||
Global.properties.updateField("CheckTestingIntervalSeconds", sCheckTime.getValue());
|
||||
if (Global.properties.AutoCheckTesting) TestingServer.ResetTimer();
|
||||
});
|
||||
add(new JLabel(" сек ") {
|
||||
{
|
||||
setFont(CommonUI.getTheme().Fonts.get(VisualiserFonts.TreeItalic));
|
||||
}
|
||||
});
|
||||
addSeparator();
|
||||
serverAdminLabel = addLabel(" управление сервером ");
|
||||
addPasses(PassCode_2021.StartTestingServer, PassCode_2021.ShutdownTestingServer, PassCode_2021.PublishTestingServer);
|
||||
}
|
||||
public void ShowAutoCheckTesting() {
|
||||
autorefreshButton.setIcon(CommonUtils.getIcon(Global.properties.AutoCheckTesting ? "/icons/Pick.png" : "/icons/NotPick.png"));
|
||||
}
|
||||
public void showServerAdminLabel(boolean flag) {
|
||||
serverAdminLabel.setVisible(flag);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package _VisualDVM.TestingSystem.Common.TestingPackage;
|
||||
import Common.Utils.CommonUtils;
|
||||
import _VisualDVM.Constants;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import Common.Database.Objects.riDBObject;
|
||||
import _VisualDVM.TestingSystem.Common.Configuration.Configuration;
|
||||
import _VisualDVM.TestingSystem.Common.Configuration.Json.ConfigurationsJson;
|
||||
import _VisualDVM.TestingSystem.Common.TasksPackageState;
|
||||
import com.sun.org.glassfish.gmbal.Description;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Vector;
|
||||
public abstract class TestingPackage<J> extends riDBObject {
|
||||
public String PID = "";
|
||||
public int tasksCount = 0; //Общее число задач
|
||||
//--
|
||||
public int kernels = 1;
|
||||
public int needsEmail = 0;
|
||||
//---
|
||||
public String version = ""; //версия тестируемого объекта
|
||||
public String drv = ""; //пусть к исполняемому файлы тестируемого объекта
|
||||
//--
|
||||
public int progress = 0; //прогресс выполнения
|
||||
public long StartDate = 0;
|
||||
public long ChangeDate = 0;
|
||||
@Description("DEFAULT 0")
|
||||
public int connectionErrosCount = 0;
|
||||
public TasksPackageState state = TasksPackageState.Draft;
|
||||
@Description("DEFAULT ''")
|
||||
public String packedConfigurationsJson = "";
|
||||
//--
|
||||
@Override
|
||||
public void SynchronizeFields(DBObject src) {
|
||||
super.SynchronizeFields(src);
|
||||
TestingPackage tp = (TestingPackage) src;
|
||||
//--
|
||||
tasksCount = tp.tasksCount;
|
||||
needsEmail = tp.needsEmail;
|
||||
version = tp.version;
|
||||
drv = tp.drv;
|
||||
PID = tp.PID;
|
||||
kernels = tp.kernels;
|
||||
progress = tp.progress;
|
||||
StartDate = tp.StartDate;
|
||||
ChangeDate = tp.ChangeDate;
|
||||
connectionErrosCount = tp.connectionErrosCount;
|
||||
state = tp.state;
|
||||
//--
|
||||
packedConfigurationsJson= tp.packedConfigurationsJson;
|
||||
}
|
||||
public TestingPackage(TestingPackage p) {
|
||||
SynchronizeFields(p);
|
||||
}
|
||||
public TestingPackage() {
|
||||
}
|
||||
public File getLocalWorkspace() {
|
||||
return new File(getHomeDirectory(), String.valueOf(id));
|
||||
}
|
||||
public boolean isLoaded() {
|
||||
return new File(getLocalWorkspace(), Constants.LOADED).exists();
|
||||
}
|
||||
//json где хранятся задачи----------------------------------
|
||||
@Description("IGNORE")
|
||||
public J package_json = null;
|
||||
public abstract Class getJsonClass();
|
||||
public abstract File getHomeDirectory();
|
||||
public File getJsonFile() {
|
||||
return new File(getLocalWorkspace(), "package_json");
|
||||
}
|
||||
public File getLoadedFile() {
|
||||
return new File(getLocalWorkspace(), Constants.LOADED);
|
||||
}
|
||||
public void saveJson() throws Exception {
|
||||
CommonUtils.jsonToFile(package_json, getJsonFile());
|
||||
}
|
||||
public void readJson() throws Exception {
|
||||
package_json = (J) CommonUtils.jsonFromFile(getJsonFile(), getJsonClass());
|
||||
}
|
||||
public void destructor() {
|
||||
package_json = null;
|
||||
}
|
||||
//----------------------------------------------------------
|
||||
public void saveConfigurationsAsJson(Vector<? extends Configuration> configurations) {
|
||||
packedConfigurationsJson = CommonUtils.gson.toJson(new ConfigurationsJson(configurations));
|
||||
}
|
||||
//определить завершен пакет с ошибками или нет.
|
||||
public void checkFinishState() throws Exception{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package _VisualDVM.TestingSystem.Common.TestingPackageToKill;
|
||||
import Common.CommonConstants;
|
||||
import Common.Database.Objects.iDBObject;
|
||||
public class TestingPackageToKill extends iDBObject {
|
||||
public int packageId = CommonConstants.Nan;
|
||||
public int type = 0; // 0 - dvm /1 - sapfor
|
||||
public TestingPackageToKill() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package _VisualDVM.TestingSystem.Common.TestingPackageToKill;
|
||||
import Common.Database.Tables.iDBTable;
|
||||
public class TestingPackagesToKillDBTable extends iDBTable<TestingPackageToKill> {
|
||||
public TestingPackagesToKillDBTable() {
|
||||
super(TestingPackageToKill.class);
|
||||
}
|
||||
}
|
||||
244
src/_VisualDVM/TestingSystem/Common/TestingPlanner.java
Normal file
244
src/_VisualDVM/TestingSystem/Common/TestingPlanner.java
Normal file
@@ -0,0 +1,244 @@
|
||||
package _VisualDVM.TestingSystem.Common;
|
||||
import Common.CommonConstants;
|
||||
import Common.Utils.CommonUtils;
|
||||
import _VisualDVM.Constants;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.Utils;
|
||||
import _VisualDVM.GlobalData.Machine.Machine;
|
||||
import _VisualDVM.GlobalData.Machine.MachineType;
|
||||
import _VisualDVM.GlobalData.User.User;
|
||||
import _VisualDVM.Repository.EmailMessage;
|
||||
import _VisualDVM.Repository.Server.ServerCode;
|
||||
import _VisualDVM.TestingSystem.Common.TestingPackage.TestingPackage;
|
||||
import _VisualDVM.TestingSystem.Common.TestingPackageToKill.TestingPackageToKill;
|
||||
import _VisualDVM.Repository.RepositoryClient;
|
||||
import Common.Utils.Loggable;
|
||||
import javafx.util.Pair;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Date;
|
||||
import java.util.Vector;
|
||||
public abstract class TestingPlanner<P extends TestingPackage> extends RepositoryClient {
|
||||
protected P testingPackage;
|
||||
protected File packageLocalWorkspace = null;
|
||||
protected String serverName = "";
|
||||
protected File supervisorHome = null;
|
||||
protected Machine machine = null;
|
||||
protected User user = null;
|
||||
//----
|
||||
protected void UpdatePackageState(TasksPackageState state_in) throws Exception {
|
||||
testingPackage.state = state_in;
|
||||
testingPackage.ChangeDate = new Date().getTime();
|
||||
ServerCommand(ServerCode.EditObject, testingPackage);
|
||||
switch (testingPackage.state) {
|
||||
case Done:
|
||||
case DoneWithErrors:
|
||||
case Aborted:
|
||||
case CompilationExecution:
|
||||
case RunningExecution:
|
||||
EmailPackage();
|
||||
break;
|
||||
}
|
||||
}
|
||||
protected void UpdatePackageState() throws Exception {
|
||||
testingPackage.ChangeDate = new Date().getTime();
|
||||
ServerCommand(ServerCode.EditObject, testingPackage);
|
||||
switch (testingPackage.state) {
|
||||
case Done:
|
||||
case DoneWithErrors:
|
||||
case Aborted:
|
||||
case CompilationExecution:
|
||||
case RunningExecution:
|
||||
EmailPackage();
|
||||
break;
|
||||
}
|
||||
}
|
||||
void UpdatePackage() throws Exception {
|
||||
testingPackage.ChangeDate = new Date().getTime();
|
||||
ServerCommand(ServerCode.EditObject, testingPackage);
|
||||
}
|
||||
public abstract String packageDescription();
|
||||
void EmailPackage() throws Exception {
|
||||
if (testingPackage.needsEmail == 1) {
|
||||
EmailMessage message = new EmailMessage();
|
||||
message.subject = "Состояние пакета тестирования "+packageDescription()+ " "+
|
||||
CommonUtils.Brackets(testingPackage.id) + " изменилось на " + CommonUtils.Brackets(testingPackage.state.getDescription());
|
||||
message.text = testingPackage.description;
|
||||
message.targets.add(testingPackage.sender_address);
|
||||
ServerCommand(ServerCode.Email, message);
|
||||
}
|
||||
}
|
||||
//---
|
||||
protected abstract ServerCode getActivePackagesCode();
|
||||
protected abstract ServerCode getCheckIfNeedsKillCode();
|
||||
protected abstract TasksPackageState getStateAfterStart();
|
||||
protected void InitSessionCredentials() {
|
||||
}
|
||||
protected abstract void TestsSynchronize() throws Exception;
|
||||
protected abstract void PackageWorkspaceCreation() throws Exception;
|
||||
protected void AnalyseResults() throws Exception {
|
||||
UpdatePackageState(TasksPackageState.Done);
|
||||
};
|
||||
protected abstract void PackageStart() throws Exception;
|
||||
protected abstract boolean CheckNextState() throws Exception;
|
||||
protected abstract void DownloadResults() throws Exception;
|
||||
protected abstract void Kill() throws Exception;
|
||||
protected boolean Connect() {
|
||||
return true;
|
||||
}
|
||||
protected void Disconnect() {
|
||||
}
|
||||
protected void MachineConnectionError() {
|
||||
}
|
||||
protected void PerformPackage(TestingPackage package_in) throws Exception {
|
||||
testingPackage = (P) package_in;
|
||||
//--
|
||||
Print(testingPackage.id + ":" + testingPackage.state.getDescription());
|
||||
//--
|
||||
if (testingPackage.connectionErrosCount >= 10) {
|
||||
Print(testingPackage.id + " had 10 connection errors. stop");
|
||||
UpdatePackageState(TasksPackageState.ConnectionError);
|
||||
MachineConnectionError();
|
||||
} else {
|
||||
//--
|
||||
InitSessionCredentials();
|
||||
if (testingPackage.state.equals(TasksPackageState.Analysis)) {
|
||||
AnalyseResults(); //todo ввести состояние DoneWithErrors
|
||||
} else {
|
||||
try {
|
||||
if (Connect()) {
|
||||
int ptk_id = (int) ServerCommand(getCheckIfNeedsKillCode(), testingPackage.id);
|
||||
if (ptk_id != CommonConstants.Nan) {
|
||||
Print("package " + testingPackage.id + " NEEDS TO KILL");
|
||||
Kill();
|
||||
UpdatePackageState(TasksPackageState.Aborted);
|
||||
ServerCommand(ServerCode.DeleteObjectByPK, new Pair(TestingPackageToKill.class, ptk_id));
|
||||
} else {
|
||||
//--
|
||||
System.out.println(testingPackage.id+":"+testingPackage.state.getDescription());
|
||||
switch (testingPackage.state) {
|
||||
case TestsSynchronize:
|
||||
TestsSynchronize();
|
||||
UpdatePackageState(TasksPackageState.PackageWorkspaceCreation);
|
||||
break;
|
||||
case PackageWorkspaceCreation:
|
||||
PackageWorkspaceCreation();
|
||||
UpdatePackageState(TasksPackageState.PackageStart);
|
||||
break;
|
||||
case PackageStart:
|
||||
PackageStart();
|
||||
testingPackage.StartDate = new Date().getTime();
|
||||
UpdatePackageState(getStateAfterStart());
|
||||
break;
|
||||
case RunningEnd:
|
||||
DownloadResults();
|
||||
UpdatePackageState(TasksPackageState.Analysis);
|
||||
break;
|
||||
default:
|
||||
if (CheckNextState()) UpdatePackage();
|
||||
break;
|
||||
}
|
||||
//--
|
||||
}
|
||||
} else {
|
||||
testingPackage.connectionErrosCount++;
|
||||
UpdatePackage();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Print("Ошибка сеанса. Соединение будет разорвано.");
|
||||
ex.printStackTrace();
|
||||
Print(ex.getMessage());
|
||||
//
|
||||
testingPackage.connectionErrosCount++;
|
||||
UpdatePackage();
|
||||
} finally {
|
||||
Disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
//--
|
||||
testingPackage.destructor();
|
||||
testingPackage = null;
|
||||
System.gc();
|
||||
//--
|
||||
}
|
||||
@Override
|
||||
public void perform() throws Exception {
|
||||
testingPackage = null;
|
||||
Vector<P> activePackages = (Vector<P>) ServerCommand(getActivePackagesCode());
|
||||
for (P activePackage : activePackages)
|
||||
PerformPackage(activePackage);
|
||||
}
|
||||
protected void Finalize(String reason) {
|
||||
Print(reason);
|
||||
File stateFile = new File(supervisorHome, Constants.ABORTED);
|
||||
try {
|
||||
FileUtils.writeStringToFile(stateFile, reason);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
System.exit(0);
|
||||
}
|
||||
//---------------------------------------------
|
||||
public String getPlanner() {
|
||||
return String.join("/", user.workspace, "modules", "planner");
|
||||
}
|
||||
//---
|
||||
public TestingPlanner(){}
|
||||
public TestingPlanner(String... args) {
|
||||
//---
|
||||
String machineAddress = args[0];
|
||||
int machinePort = Integer.parseInt(args[1]);
|
||||
String userName = args[2];
|
||||
String userPassword = args[3];
|
||||
String userWorkspace = args[4];
|
||||
String testingSystemRoot = args[5];
|
||||
serverName = args[6];
|
||||
supervisorHome = CommonUtils.getHomeDirectory(); //при инициализации это текущая папка.
|
||||
//---
|
||||
CommonUtils.MainLog = new Loggable() {
|
||||
@Override
|
||||
public String getLogHomePath() {
|
||||
return supervisorHome.getAbsolutePath();
|
||||
}
|
||||
@Override
|
||||
public String getLogName() {
|
||||
return Global.mode.toString();
|
||||
}
|
||||
};
|
||||
CommonUtils.MainLog.ClearLog();
|
||||
//--
|
||||
CommonUtils.setHomePath(testingSystemRoot);
|
||||
Global.CheckTestingSystemDirectories();
|
||||
//---
|
||||
machine = new Machine(machineAddress, machineAddress, machinePort, MachineType.Server);
|
||||
user = new User(userName, userPassword, userWorkspace);
|
||||
//---
|
||||
Print("machineAddress=" + CommonUtils.Brackets(machineAddress));
|
||||
Print("machinePort=" + CommonUtils.Brackets(String.valueOf(machinePort)));
|
||||
Print("userName=" + CommonUtils.Brackets(userName));
|
||||
Print("userPassword=" + CommonUtils.Brackets(userPassword));
|
||||
Print("userWorkspace=" + CommonUtils.Brackets(userWorkspace));
|
||||
Print("root=" + CommonUtils.Brackets(CommonUtils.getHomePath()));
|
||||
Print("serverName=" + serverName);
|
||||
Print("=====");
|
||||
//----
|
||||
Utils.createEmptyFile(Constants.STARTED);
|
||||
}
|
||||
/*
|
||||
void CheckLocal() {
|
||||
local = false;
|
||||
try {
|
||||
InetAddress address = InetAddress.getByName(machine.address);
|
||||
InetAddress localAddress = InetAddress.getByName("alex-freenas.ddns.net");
|
||||
Print("machine ip=" + Utils.Brackets(address.getHostAddress()));
|
||||
Print("server ip=" + Utils.Brackets(localAddress.getHostAddress()));
|
||||
local = localAddress.getHostAddress().equals(address.getHostAddress());
|
||||
//todo в этом случае отдельный режим без ssh
|
||||
} catch (Exception ex) {
|
||||
Global.Log.PrintException(ex);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
652
src/_VisualDVM/TestingSystem/Common/TestingServer.java
Normal file
652
src/_VisualDVM/TestingSystem/Common/TestingServer.java
Normal file
@@ -0,0 +1,652 @@
|
||||
package _VisualDVM.TestingSystem.Common;
|
||||
import Common.CommonConstants;
|
||||
import Common.Utils.CommonUtils;
|
||||
import _VisualDVM.Constants;
|
||||
import Common.Database.Objects.DBObject;
|
||||
import _VisualDVM.Global;
|
||||
import Common.Utils.TextLog;
|
||||
import _VisualDVM.Utils;
|
||||
import _VisualDVM.GlobalData.Account.Account;
|
||||
import _VisualDVM.ProjectData.LanguageName;
|
||||
import _VisualDVM.Repository.Component.Sapfor.Sapfor;
|
||||
import _VisualDVM.Repository.EmailMessage;
|
||||
import _VisualDVM.Repository.RepositoryRefuseException;
|
||||
import _VisualDVM.Repository.RepositoryServer;
|
||||
import _VisualDVM.Repository.Server.ServerCode;
|
||||
import _VisualDVM.Repository.Server.ServerExchangeUnit_2021;
|
||||
import _VisualDVM.TestingSystem.Common.Group.Group;
|
||||
import _VisualDVM.TestingSystem.Common.MachineProcess.MachineProcess;
|
||||
import _VisualDVM.TestingSystem.Common.MachineProcess.MachineProcessSet;
|
||||
import _VisualDVM.TestingSystem.Common.Test.Test;
|
||||
import _VisualDVM.TestingSystem.Common.Test.TestType;
|
||||
import _VisualDVM.TestingSystem.Common.TestingPackageToKill.TestingPackageToKill;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMPackage.DVMPackage;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMPackage.DVMPackage_json;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMTestingChecker;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.Json.SapforPackage_json;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforConfiguration.SapforConfiguration;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforPackage.SapforPackage;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforSettings.SapforSettings;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforSettingsCommand.SapforSettingsCommand;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforTestingPlanner;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.ServerSapfor.ServerSapfor;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.ServerSapfor.ServerSapforState;
|
||||
import Visual_DVM_2021.Passes.All.DownloadRepository;
|
||||
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.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Vector;
|
||||
public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
public String name = "?";
|
||||
public static MachineProcessSet machinesProcesses = new MachineProcessSet();
|
||||
@Override
|
||||
public void afterPublishAction(DBObject object) throws Exception {
|
||||
if (object instanceof Test) {
|
||||
Test test = (Test) object;
|
||||
if (!test.unpackProjectOnServer()) {
|
||||
db.Delete(test);
|
||||
throw new RepositoryRefuseException(
|
||||
"Не удалось прикрепить проект к тесту с id " + test.id
|
||||
+ "\nТест будет удален"
|
||||
);
|
||||
}
|
||||
} else if (object instanceof DVMPackage) {
|
||||
DVMPackage dvmPackage = (DVMPackage) object;
|
||||
//--
|
||||
Utils.CheckAndCleanDirectory(dvmPackage.getLocalWorkspace());
|
||||
//--
|
||||
dvmPackage.saveJson();
|
||||
dvmPackage.package_json = null; // объект больше не нужен.
|
||||
//--
|
||||
} else if (object instanceof SapforPackage) {
|
||||
((SapforPackage) object).init();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void afterDeleteAction(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)
|
||||
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 DVMPackage) {
|
||||
DVMPackage dvmPackage = (DVMPackage) object;
|
||||
File workspace = dvmPackage.getLocalWorkspace();
|
||||
Utils.forceDeleteWithCheck(workspace);
|
||||
} else if (object instanceof SapforPackage) {
|
||||
SapforPackage sapforPackage = (SapforPackage) object;
|
||||
File workspace = sapforPackage.getLocalWorkspace();
|
||||
Utils.forceDeleteWithCheck(workspace);
|
||||
} else if (object instanceof SapforSettings) {
|
||||
SapforSettings sapforSettings = (SapforSettings) object;
|
||||
Vector<SapforSettingsCommand> commands = new Vector<>();
|
||||
for (SapforSettingsCommand command : db.sapforSettingsCommands.Data.values()) {
|
||||
if (command.sapforsettings_id== sapforSettings.id)
|
||||
commands.add(command);
|
||||
}
|
||||
for (SapforSettingsCommand command : commands) {
|
||||
db.Delete(command);
|
||||
}
|
||||
}
|
||||
}
|
||||
//-->>>
|
||||
@Override
|
||||
protected void beforePublishAction(DBObject object) throws Exception {
|
||||
if (object instanceof ServerSapfor) {
|
||||
int current_version = getSapforActualVersion();
|
||||
int max_installed_version = db.getInstalledSapforMaxVersion();
|
||||
if (max_installed_version == current_version)
|
||||
throw new RepositoryRefuseException("Актуальная версия SAPFOR " + max_installed_version + " уже установлена");
|
||||
}
|
||||
}
|
||||
public TestingServer() {
|
||||
super(TestsDatabase.class);
|
||||
name = CommonUtils.getDateName("testingServer");
|
||||
System.out.println("ServerName=" + CommonUtils.Brackets(name));
|
||||
}
|
||||
//основа
|
||||
@Override
|
||||
public int getPort() {
|
||||
return Global.properties.TestingServerPort;
|
||||
}
|
||||
//---
|
||||
@Override
|
||||
protected void startAdditionalThreads() {
|
||||
testingThread.start();
|
||||
}
|
||||
DVMTestingChecker dvmTestingChecker = new DVMTestingChecker();
|
||||
SapforTestingPlanner sapforTestingPlanner = new SapforTestingPlanner();
|
||||
//--
|
||||
protected Thread testingThread = new Thread(() -> {
|
||||
while (true) {
|
||||
dvmTestingChecker.Perform();
|
||||
sapforTestingPlanner.Perform();
|
||||
CommonUtils.sleep(5000);
|
||||
}
|
||||
});
|
||||
//------>>>
|
||||
public static Timer checkTimer = null;
|
||||
public static void TimerOn() {
|
||||
checkTimer = new Timer(Global.properties.CheckTestingIntervalSeconds * 1000, e -> {
|
||||
Pass_2021.passes.get(PassCode_2021.ActualizePackages).Do();
|
||||
});
|
||||
checkTimer.start();
|
||||
}
|
||||
public static void TimerOff() {
|
||||
if (checkTimer != null)
|
||||
checkTimer.stop();
|
||||
}
|
||||
public static void ResetTimer() {
|
||||
TimerOff();
|
||||
TimerOn();
|
||||
}
|
||||
@Override
|
||||
protected void Session() throws Exception {
|
||||
Test test;
|
||||
int test_id;
|
||||
switch (code) {
|
||||
case PerformAutoSapforTesting:
|
||||
Print("Запустить автоматическое тестирование SAPFOR");
|
||||
TextLog Log = new TextLog();
|
||||
SapforPackage autoPackage = tryAutoSapforTesting(Log);
|
||||
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||
EmailMessage message = Log.isEmpty() ?
|
||||
new EmailMessage(
|
||||
"Запущено автоматическое тестирование версии " + request.arg + " системы SAPFOR",
|
||||
"Пакет "+ CommonUtils.Brackets(autoPackage.id), new Vector<>()) :
|
||||
new EmailMessage(
|
||||
"Не удалось запустить автоматическое тестирование версии " + request.arg + " системы SAPFOR",
|
||||
Log.toString(),
|
||||
new Vector<>()
|
||||
);
|
||||
Email(message);
|
||||
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, "", CommonUtils.fileToBytes(test.getArchive()));
|
||||
} else
|
||||
throw new RepositoryRefuseException("Теста с именем " + request.arg + " не существует");
|
||||
break;
|
||||
case ReceiveTestsDatabase:
|
||||
Print("Получить базу данных тестов");
|
||||
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||
response.object = CommonUtils.fileToBytes(db.getFile());
|
||||
break;
|
||||
//---
|
||||
case RefreshDVMTests:
|
||||
Print("Синхронизировать репозиторий тестов ");
|
||||
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||
RefreshDVMTests((Account) request.object, Integer.parseInt(request.arg));
|
||||
break;
|
||||
case DVMPackageNeedsKill:
|
||||
Print("Проверить нуждается ли пакет DVM в убийстве");
|
||||
DVMPackageNeedsKill();
|
||||
break;
|
||||
case UpdateActiveDVMPackages:
|
||||
Print("Получить данные по пакетам DVM");
|
||||
UpdateActiveDVMPackages();
|
||||
break;
|
||||
case GetFirstActiveSapforPackages:
|
||||
Print("Получить первый активный пакет задач SAPFOR");
|
||||
GetFirstActiveSapforPackages();
|
||||
break;
|
||||
case SapforPackageNeedsKill:
|
||||
Print("Проверить нуждает ли пакет SAPFOR в убийстве");
|
||||
SapforPackageNeedsKill();
|
||||
break;
|
||||
case UpdateActiveSapforPackages:
|
||||
Print("Получить данные по пакетам Sapfor");
|
||||
UpdateActiveSapforPackages();
|
||||
break;
|
||||
case DownloadDVMPackage:
|
||||
Print("Загрузить пакет DVM");
|
||||
DownloadDVMPackage();
|
||||
break;
|
||||
case DownloadDVMPackages:
|
||||
Print("Загрузить пакеты DVM");
|
||||
DownloadDVMPackages();
|
||||
break;
|
||||
case DownloadSapforPackage:
|
||||
Print("Загрузить пакет SAPFOR");
|
||||
DownloadSapforPackage();
|
||||
break;
|
||||
case ReplaceTestCode:
|
||||
Print("Заменить код теста");
|
||||
ReplaceTestCode();
|
||||
break;
|
||||
case ReplaceTestsCodes:
|
||||
Print("Заменить код тестов");
|
||||
ReplaceTestsCodes();
|
||||
break;
|
||||
case GetSapforPackagesJson:
|
||||
Print("Получить информацию о задачах пакетов SAPFOR");
|
||||
GetSapforPackagesJson();
|
||||
break;
|
||||
case GetDVMPackagesJson:
|
||||
Print("Получить информацию о задачах пакетов DVM");
|
||||
GetDVMPackagesJson();
|
||||
break;
|
||||
case GetFirstActiveDVMPackageForMachineURL:
|
||||
Print("Получить первый активный пакет задач DVM на машине с адресом");
|
||||
GetFirstActiveDVMPackageForMachineURL();
|
||||
break;
|
||||
case GetServerName:
|
||||
Print("Получить имя сервера");
|
||||
GetServerName();
|
||||
break;
|
||||
case StartNecessaryMachines:
|
||||
Print("Проверка процессов машин");
|
||||
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||
StartNecessaryMachines();
|
||||
break;
|
||||
case GetSapforForCompilation:
|
||||
Print("Получить первую активную версию Sapfor для сборки");
|
||||
GetSapforForCompilation();
|
||||
break;
|
||||
case GetMaxSapforVersion:
|
||||
Print("Получить максимальную установленную версию Sapfor");
|
||||
GetSapforMaxVersion();
|
||||
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")
|
||||
&& CommonUtils.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 void RefreshDVMTests(Account account, int sapfor_id) throws Exception {
|
||||
ServerSapfor sapfor = null;
|
||||
if (!db.serverSapfors.containsKey(sapfor_id))
|
||||
throw new RepositoryRefuseException("Версия SAPFOR с ключом " + sapfor_id + " не найдена.");
|
||||
sapfor = db.serverSapfors.get(sapfor_id);
|
||||
DownloadRepository downloadRepository = new DownloadRepository();
|
||||
if (!downloadRepository.Do())
|
||||
throw new RepositoryRefuseException("Не удалось обновить репозиторий");
|
||||
//-->>
|
||||
Vector<Pair<Group, Vector<File>>> groups = new Vector<>();
|
||||
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));
|
||||
//-теперь создать тесты.
|
||||
//--
|
||||
for (Pair<Group, Vector<File>> p : groups)
|
||||
db.RefreshGroup(account, sapfor, p);
|
||||
}
|
||||
private void GetFirstActiveSapforPackages() throws Exception {
|
||||
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||
response.object = db.getFirstActiveSapforPackagesCopies();
|
||||
}
|
||||
void GetSapforMaxVersion() throws Exception {
|
||||
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||
response.object = db.getInstalledSapforMaxVersion();
|
||||
}
|
||||
void UpdateActiveDVMPackages() throws Exception {
|
||||
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||
Vector<Pair<Integer, Long>> keys_pairs = (Vector<Pair<Integer, Long>>) request.object;
|
||||
Vector<DVMPackage> res = new Vector<>();
|
||||
//--
|
||||
for (Pair<Integer, Long> p : keys_pairs) {
|
||||
if (db.dvmPackages.containsKey(p.getKey())) {
|
||||
DVMPackage actual = db.dvmPackages.get(p.getKey());
|
||||
if (actual.ChangeDate != p.getValue())
|
||||
res.add(new DVMPackage(actual));
|
||||
}
|
||||
}
|
||||
response.object = res;
|
||||
}
|
||||
private void UpdateActiveSapforPackages() {
|
||||
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||
Vector<Pair<Integer, Long>> keys_pairs = (Vector<Pair<Integer, Long>>) request.object;
|
||||
Vector<SapforPackage> res = new Vector<>();
|
||||
//--
|
||||
for (Pair<Integer, Long> p : keys_pairs) {
|
||||
if (db.sapforPackages.containsKey(p.getKey())) {
|
||||
SapforPackage actual = db.sapforPackages.get(p.getKey());
|
||||
if (actual.ChangeDate != p.getValue())
|
||||
res.add(new SapforPackage(actual));
|
||||
}
|
||||
}
|
||||
response.object = res;
|
||||
}
|
||||
private void DVMPackageNeedsKill() {
|
||||
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||
response.object = CommonConstants.Nan;
|
||||
int packageId = (int) request.object;
|
||||
for (TestingPackageToKill packageToKill : db.testingPackagesToKill.Data.values()) {
|
||||
if ((packageToKill.packageId == packageId) && (packageToKill.type == 0)) {
|
||||
response.object = packageToKill.id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void SapforPackageNeedsKill() throws Exception {
|
||||
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||
response.object = CommonConstants.Nan;
|
||||
int packageId = (int) request.object;
|
||||
for (TestingPackageToKill packageToKill : db.testingPackagesToKill.Data.values()) {
|
||||
if ((packageToKill.packageId == packageId) && (packageToKill.type == 1)) {
|
||||
response.object = packageToKill.id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void DownloadDVMPackage() throws Exception {
|
||||
int dvmPackage_id = (int) request.object;
|
||||
if (!db.dvmPackages.containsKey(dvmPackage_id))
|
||||
throw new RepositoryRefuseException("Не найдено пакета тестирования DVM с ключом " + dvmPackage_id);
|
||||
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||
DVMPackage dvmPackage = db.dvmPackages.get(dvmPackage_id);
|
||||
File workspace = dvmPackage.getLocalWorkspace();
|
||||
File results_zip = new File(workspace, "results.zip");
|
||||
File package_json = dvmPackage.getJsonFile();
|
||||
response.object = new Pair(CommonUtils.fileToBytes(results_zip), CommonUtils.fileToBytes(package_json));
|
||||
}
|
||||
private void DownloadDVMPackages() throws Exception {
|
||||
Vector<Integer> ids = (Vector<Integer>) request.object;
|
||||
Vector<Pair<Integer, Pair<byte[], byte[]>>> res = new Vector<>();
|
||||
for (int dvmPackage_id : ids) {
|
||||
if (!db.dvmPackages.containsKey(dvmPackage_id))
|
||||
throw new RepositoryRefuseException("Не найдено пакета тестирования DVM с ключом " + dvmPackage_id);
|
||||
DVMPackage dvmPackage = db.dvmPackages.get(dvmPackage_id);
|
||||
File workspace = dvmPackage.getLocalWorkspace();
|
||||
File results_zip = new File(workspace, "results.zip");
|
||||
File package_json = dvmPackage.getJsonFile();
|
||||
res.add(new Pair<>(dvmPackage_id, new Pair(CommonUtils.fileToBytes(results_zip), CommonUtils.fileToBytes(package_json))));
|
||||
}
|
||||
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||
response.object = res;
|
||||
}
|
||||
private void DownloadSapforPackage() throws Exception {
|
||||
int sapforPackage_id = (int) request.object;
|
||||
if (!db.sapforPackages.containsKey(sapforPackage_id))
|
||||
throw new RepositoryRefuseException("Не найдено пакета тестирования SAPFOR с ключом " + sapforPackage_id);
|
||||
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||
SapforPackage sapforPackage = db.sapforPackages.get(sapforPackage_id);
|
||||
File workspace = sapforPackage.getLocalWorkspace();
|
||||
File results_zip = Utils.getTempFileName("results");
|
||||
ZipFolderPass zipFolderPass = new ZipFolderPass();
|
||||
zipFolderPass.Do(workspace.getAbsolutePath(), results_zip.getAbsolutePath());
|
||||
if (results_zip.exists())
|
||||
response.object = CommonUtils.fileToBytes(results_zip);
|
||||
else
|
||||
throw new RepositoryRefuseException("Не удалось заархивировать пакет тестирования SAPFOR с ключом " + sapforPackage_id);
|
||||
}
|
||||
private void ReplaceTestCode() throws Exception {
|
||||
Test test = (Test) request.object;
|
||||
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||
//---
|
||||
if (!test.unpackProjectOnServer()) {
|
||||
db.Delete(test);
|
||||
throw new RepositoryRefuseException(
|
||||
"Не удалось прикрепить проект к тесту с id " + test.id
|
||||
+ "\nТест будет удален"
|
||||
);
|
||||
} else db.Update(test); //обновить список файлов и размерность.
|
||||
}
|
||||
private void ReplaceTestsCodes() throws Exception {
|
||||
Vector<Test> tests = (Vector<Test>) request.object;
|
||||
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||
for (Test test : tests) {
|
||||
if (!test.unpackProjectOnServer()) {
|
||||
db.Delete(test);
|
||||
throw new RepositoryRefuseException(
|
||||
"Не удалось прикрепить проект к тесту с id " + test.id
|
||||
+ "\nТест будет удален"
|
||||
);
|
||||
} else db.Update(test); //обновить список файлов и размерность.
|
||||
}
|
||||
}
|
||||
private void GetDVMPackagesJson() throws Exception {
|
||||
Vector<Integer> packages_ids = (Vector<Integer>) request.object;
|
||||
Vector<DVMPackage_json> jsons = new Vector<>();
|
||||
for (int package_id : packages_ids) {
|
||||
if (!db.dvmPackages.containsKey(package_id))
|
||||
throw new RepositoryRefuseException("Пакета задач DVM " + CommonUtils.Brackets(package_id) + " не существует.");
|
||||
DVMPackage dvmPackage = db.dvmPackages.get(package_id);
|
||||
File json = dvmPackage.getJsonFile();
|
||||
if (!json.exists())
|
||||
throw new RepositoryRefuseException("Не найден JSON файл для пакета задач DVM " + CommonUtils.Brackets(package_id));
|
||||
jsons.add((DVMPackage_json) CommonUtils.jsonFromFile(json, DVMPackage_json.class));
|
||||
}
|
||||
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||
response.object = jsons;
|
||||
}
|
||||
private void GetSapforPackagesJson() throws Exception {
|
||||
Vector<Integer> packages_ids = (Vector<Integer>) request.object;
|
||||
Vector<SapforPackage_json> jsons = new Vector<>();
|
||||
for (int package_id : packages_ids) {
|
||||
if (!db.sapforPackages.containsKey(package_id))
|
||||
throw new RepositoryRefuseException("Пакета задач SAPFOR " + CommonUtils.Brackets(package_id) + " не существует.");
|
||||
SapforPackage sapforPackage = db.sapforPackages.get(package_id);
|
||||
File json = sapforPackage.getJsonFile();
|
||||
if (!json.exists())
|
||||
throw new RepositoryRefuseException("Не найден JSON файл для пакета задач SAPFOR " + CommonUtils.Brackets(package_id));
|
||||
jsons.add((SapforPackage_json) CommonUtils.jsonFromFile(json, SapforPackage_json.class));
|
||||
}
|
||||
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||
response.object = jsons;
|
||||
}
|
||||
private void GetServerName() throws Exception {
|
||||
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||
response.object = name;
|
||||
}
|
||||
//--
|
||||
private void GetFirstActiveDVMPackageForMachineURL() {
|
||||
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||
response.object = db.getFirstActiveDVMPackageCopyForMachineURL(request.arg);
|
||||
}
|
||||
void StartNecessaryMachines() {
|
||||
try {
|
||||
Vector<String> aborted = new Vector<>();
|
||||
for (MachineProcess process : machinesProcesses.Data.values()) {
|
||||
if (process.isAborted()) {
|
||||
aborted.add(process.id);
|
||||
}
|
||||
}
|
||||
//---
|
||||
for (String key : aborted) {
|
||||
machinesProcesses.Data.remove(key);
|
||||
}
|
||||
//---
|
||||
LinkedHashMap<String, MachineProcess> processes_to_start = new LinkedHashMap<>();
|
||||
//1. Получить список всех пакетов, которые активны, и взять из них машины.
|
||||
for (DVMPackage dvmPackage : db.dvmPackages.Data.values()) {
|
||||
if (dvmPackage.state.isActive()) {
|
||||
//-
|
||||
if (!machinesProcesses.hasProcessForPackage(dvmPackage)) {
|
||||
MachineProcess new_process = new MachineProcess(dvmPackage);
|
||||
processes_to_start.put(new_process.getUniqueKey(), new_process);
|
||||
}
|
||||
}
|
||||
}
|
||||
//запуск.
|
||||
for (MachineProcess process : processes_to_start.values()) {
|
||||
process.Start();
|
||||
if (Utils.checkFileCreation(process.getStartedFile())) {
|
||||
machinesProcesses.Data.put(process.id, process);
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
void GetSapforActualVersion() throws Exception {
|
||||
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||
File versionFile = new File(Global.TempDirectory, "version.h");
|
||||
if (versionFile.exists())
|
||||
FileUtils.forceDelete(versionFile);
|
||||
//1. Получить версию из репозитория.
|
||||
Utils.startScript(Global.TempDirectory,
|
||||
Global.TempDirectory,
|
||||
"get_version",
|
||||
"wget --user dvmhuser --password dvmh2013 -P " +
|
||||
CommonUtils.DQuotes(Global.TempDirectory.getAbsolutePath()) +
|
||||
" http://svn.dvm-system.org/svn/dvmhrepo/sapfor/experts/Sapfor_2017/_src/Utils/version.h"
|
||||
).waitFor();
|
||||
if (!versionFile.exists())
|
||||
throw new RepositoryRefuseException("Не удалось загрузить текущую версию SAPFOR из репозитория!");
|
||||
int current_version = Sapfor.readVersionFromCode(versionFile);
|
||||
int max_installed_version = db.getInstalledSapforMaxVersion();
|
||||
if (max_installed_version == current_version)
|
||||
throw new RepositoryRefuseException("Версия " + max_installed_version + " уже установлена");
|
||||
}
|
||||
//---
|
||||
int getSapforActualVersion() throws Exception {
|
||||
File versionFile = new File(Global.TempDirectory, "version.h");
|
||||
if (versionFile.exists())
|
||||
FileUtils.forceDelete(versionFile);
|
||||
//1. Получить версию из репозитория.
|
||||
Utils.startScript(Global.TempDirectory,
|
||||
Global.TempDirectory,
|
||||
"get_version",
|
||||
"wget --user dvmhuser --password dvmh2013 -P " +
|
||||
CommonUtils.DQuotes(Global.TempDirectory.getAbsolutePath()) +
|
||||
" http://svn.dvm-system.org/svn/dvmhrepo/sapfor/experts/Sapfor_2017/_src/Utils/version.h"
|
||||
).waitFor();
|
||||
if (!versionFile.exists())
|
||||
throw new RepositoryRefuseException("Не удалось загрузить текущую версию SAPFOR из репозитория!");
|
||||
return Sapfor.readVersionFromCode(versionFile);
|
||||
}
|
||||
void GetSapforForCompilation() throws Exception {
|
||||
//1. Проверить наличие заказов от пользователя
|
||||
ServerSapfor serverSapfor = db.getSapforCopyForCompilation();
|
||||
if (serverSapfor == null) {
|
||||
//2 если нет. проверить есть ли свежие версии.
|
||||
int max_version = db.getInstalledSapforMaxVersion();
|
||||
int current_version = getSapforActualVersion();
|
||||
if (current_version > max_version) {
|
||||
serverSapfor = new ServerSapfor();
|
||||
serverSapfor.sender_name = "server";
|
||||
serverSapfor.sender_address = Constants.MailAddress;
|
||||
serverSapfor.state = ServerSapforState.Queued;
|
||||
db.Insert(serverSapfor);
|
||||
}
|
||||
}
|
||||
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||
response.object = serverSapfor;
|
||||
}
|
||||
SapforPackage tryAutoSapforTesting(TextLog Log) throws Exception {
|
||||
//--
|
||||
Account account = new Account();
|
||||
account.name = "server";
|
||||
account.email = Constants.MailAddress;
|
||||
//-
|
||||
int sapforId = Integer.parseInt(request.arg);
|
||||
System.out.println("Sapfor_id = "+request.arg);
|
||||
|
||||
if (!db.serverSapfors.containsKey(sapforId)) {
|
||||
Log.Writeln_("Версия SAPFOR " + sapforId + " не существует.");
|
||||
return null;
|
||||
}
|
||||
ServerSapfor sapfor = db.serverSapfors.get(sapforId);
|
||||
if (!sapfor.state.equals(ServerSapforState.Done)) {
|
||||
Log.Writeln_("Выбранная версия SAPFOR " + sapforId + " не собрана!");
|
||||
return null;
|
||||
}
|
||||
Vector<SapforConfiguration> configurations = db.sapforConfigurations.getAutoConfigurations();
|
||||
if (configurations.isEmpty()) {
|
||||
Log.Writeln_("Не найдено конфигураций для автоматического тестирования!");
|
||||
return null;
|
||||
}
|
||||
SapforPackage target = new SapforPackage(account,
|
||||
sapfor,
|
||||
configurations,
|
||||
1,
|
||||
Log);
|
||||
//-
|
||||
if (target.tasksCount == 0) {
|
||||
Log.Writeln_("Не сформировано ни одной новой задачи.");
|
||||
return null;
|
||||
}
|
||||
beforePublishAction(target);
|
||||
db.InsertS(target);
|
||||
afterPublishAction(target);
|
||||
//--
|
||||
return target;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
332
src/_VisualDVM/TestingSystem/Common/TestsDatabase.java
Normal file
332
src/_VisualDVM/TestingSystem/Common/TestsDatabase.java
Normal file
@@ -0,0 +1,332 @@
|
||||
package _VisualDVM.TestingSystem.Common;
|
||||
import Common.CommonConstants;
|
||||
import Common.Utils.CommonUtils;
|
||||
import _VisualDVM.Constants;
|
||||
import Common.Database.SQLITE.SQLiteDatabase;
|
||||
import _VisualDVM.Global;
|
||||
import Common.Utils.TextLog;
|
||||
import _VisualDVM.Utils;
|
||||
import _VisualDVM.GlobalData.Account.Account;
|
||||
import _VisualDVM.Repository.Component.Sapfor.Sapfor;
|
||||
import _VisualDVM.Repository.RepositoryRefuseException;
|
||||
import _VisualDVM.TestingSystem.Common.Group.Group;
|
||||
import _VisualDVM.TestingSystem.Common.Group.GroupsDBTable;
|
||||
import _VisualDVM.TestingSystem.Common.Test.Test;
|
||||
import _VisualDVM.TestingSystem.Common.Test.TestDBTable;
|
||||
import _VisualDVM.TestingSystem.Common.TestingPackageToKill.TestingPackagesToKillDBTable;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMConfiguration.DVMConfigurationDBTable;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMPackage.DVMPackage;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMPackage.DVMPackageDBTable;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMSettings.DVMSettingsDBTable;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMTasks.DVMRunTasksSet;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforConfiguration.SapforConfigurationDBTable;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforPackage.SapforPackage;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforPackage.SapforPackageDBTable;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforSettings.SapforSettingsDBTable;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.SapforSettingsCommand.SapforSettingsCommandsDBTable;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.ServerSapfor.ServerSapfor;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.ServerSapfor.ServerSapforState;
|
||||
import _VisualDVM.TestingSystem.SAPFOR.ServerSapfor.ServerSapforsDBTable;
|
||||
import Visual_DVM_2021.Passes.All.ZipFolderPass;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import javafx.util.Pair;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Vector;
|
||||
public class TestsDatabase extends SQLiteDatabase {
|
||||
public DVMConfigurationDBTable dvm_configurations;
|
||||
public TestDBTable tests;
|
||||
public GroupsDBTable groups;
|
||||
public DVMPackageDBTable dvmPackages;
|
||||
public SapforPackageDBTable sapforPackages;
|
||||
//--
|
||||
public TestingPackagesToKillDBTable testingPackagesToKill;
|
||||
//--
|
||||
public SapforConfigurationDBTable sapforConfigurations;
|
||||
//----
|
||||
public ServerSapforsDBTable serverSapfors;
|
||||
//---
|
||||
public DVMRunTasksSet dvmRunTasks = new DVMRunTasksSet(); //задачи текущего пакета тестирования DVM
|
||||
public SapforSettingsDBTable sapforSettings;
|
||||
public SapforSettingsCommandsDBTable sapforSettingsCommands;
|
||||
//--
|
||||
public DVMSettingsDBTable dvmSettings;
|
||||
public TestsDatabase() {
|
||||
super(Paths.get(System.getProperty("user.dir"), "Data", Constants.tests_db_name + ".sqlite").toFile());
|
||||
}
|
||||
@Override
|
||||
protected void initAllTables() throws Exception {
|
||||
addTable(dvm_configurations = new DVMConfigurationDBTable());
|
||||
addTable(groups = new GroupsDBTable());
|
||||
addTable(tests = new TestDBTable());
|
||||
addTable(dvmPackages = new DVMPackageDBTable());
|
||||
addTable(sapforPackages = new SapforPackageDBTable());
|
||||
addTable(testingPackagesToKill = new TestingPackagesToKillDBTable());
|
||||
//-
|
||||
addTable(sapforConfigurations = new SapforConfigurationDBTable());
|
||||
addTable(serverSapfors = new ServerSapforsDBTable());
|
||||
addTable(sapforSettings = new SapforSettingsDBTable());
|
||||
addTable(sapforSettingsCommands = new SapforSettingsCommandsDBTable());
|
||||
addTable(dvmSettings=new DVMSettingsDBTable());
|
||||
}
|
||||
@Override
|
||||
public PassCode_2021 getSynchronizePassCode() {
|
||||
return PassCode_2021.SynchronizeTests;
|
||||
}
|
||||
public Vector<SapforPackage> getFirstActiveSapforPackagesCopies() {
|
||||
Vector<SapforPackage> res = new Vector<>();
|
||||
Vector<SapforPackage> packages = new Vector<>();
|
||||
SapforPackage activePackage = null;
|
||||
//1. получить активные пакеты.
|
||||
for (SapforPackage p : sapforPackages.Data.values()) {
|
||||
switch (p.state) {
|
||||
case Done:
|
||||
case Aborted:
|
||||
case Draft:
|
||||
case ConnectionError:
|
||||
case DoneWithErrors:
|
||||
break;
|
||||
default:
|
||||
packages.add(p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
//2. отсортировать по приоритету.
|
||||
packages.sort(new Comparator<SapforPackage>() {
|
||||
@Override
|
||||
public int compare(SapforPackage o1, SapforPackage o2) {
|
||||
return Integer.compare(o1.state.ordinal(), o2.state.ordinal());
|
||||
}
|
||||
});
|
||||
if (!packages.isEmpty()) {
|
||||
activePackage = packages.lastElement();
|
||||
if (activePackage.state.equals(TasksPackageState.Queued)) {
|
||||
activePackage.state = TasksPackageState.TestsSynchronize;
|
||||
try {
|
||||
Update(activePackage);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
res.add(new SapforPackage(activePackage));
|
||||
; //копия чтобы не было конфликта доступа с нитью планировщика.
|
||||
}
|
||||
return res;
|
||||
}
|
||||
public Vector<DVMPackage> getFirstActiveDVMPackagesCopies() {
|
||||
Vector<DVMPackage> res = new Vector<>();
|
||||
//--
|
||||
LinkedHashMap<String, Vector<DVMPackage>> packagesByMachines = new LinkedHashMap<>();
|
||||
//----
|
||||
//1. Получить список активных пакетов по машинам.
|
||||
for (DVMPackage dvmPackage : dvmPackages.Data.values()) {
|
||||
switch (dvmPackage.state) {
|
||||
case Done:
|
||||
case DoneWithErrors:
|
||||
case Aborted:
|
||||
case Draft:
|
||||
case ConnectionError:
|
||||
break;
|
||||
default:
|
||||
//активен.
|
||||
Vector<DVMPackage> packages = null;
|
||||
//--
|
||||
if (packagesByMachines.containsKey(dvmPackage.machine_address)) {
|
||||
packages = packagesByMachines.get(dvmPackage.machine_address);
|
||||
} else {
|
||||
packages = new Vector<>();
|
||||
packagesByMachines.put(dvmPackage.machine_address, packages);
|
||||
}
|
||||
packages.add(dvmPackage);
|
||||
break;
|
||||
}
|
||||
}
|
||||
//2. Выбрать для каждой машины наиболее приоритетный пакет.
|
||||
for (String machine : packagesByMachines.keySet()) {
|
||||
Vector<DVMPackage> packages = packagesByMachines.get(machine);
|
||||
if (!packages.isEmpty()) {
|
||||
packages.sort(new Comparator<DVMPackage>() {
|
||||
@Override
|
||||
public int compare(DVMPackage o1, DVMPackage o2) {
|
||||
return Integer.compare(o1.state.ordinal(), o2.state.ordinal());
|
||||
}
|
||||
});
|
||||
//-
|
||||
DVMPackage activePackage = packages.lastElement();
|
||||
if (activePackage.state.equals(TasksPackageState.Queued)) {
|
||||
activePackage.state = TasksPackageState.TestsSynchronize;
|
||||
try {
|
||||
Update(activePackage);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
res.add(new DVMPackage(activePackage)); //копия чтобы не было конфликта доступа с нитью планировщика.
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
//--
|
||||
public void SaveTestFromSingleFile(ServerSapfor sapfor, Group group, Test test, File file) throws Exception {
|
||||
File testDirectory = new File(Global.TestsDirectory, String.valueOf(test.id));
|
||||
Utils.CheckAndCleanDirectory(testDirectory);
|
||||
File testFile = Paths.get(testDirectory.getAbsolutePath(), file.getName()).toFile();
|
||||
FileUtils.copyFile(file, testFile);
|
||||
//----
|
||||
//архивация.
|
||||
File archive = test.getArchive();
|
||||
if (archive.exists())
|
||||
FileUtils.forceDelete(archive);
|
||||
//----------->>
|
||||
ZipFolderPass zip = new ZipFolderPass();
|
||||
zip.Do(testDirectory.getAbsolutePath(), archive.getAbsolutePath());
|
||||
//---
|
||||
//Определение размерности
|
||||
switch (group.language) {
|
||||
case fortran:
|
||||
// временная папка для анализа. чтобы не засорять нормальную.
|
||||
File tempProject = Utils.getTempFileName("test");
|
||||
FileUtils.forceMkdir(tempProject);
|
||||
FileUtils.copyDirectory(testDirectory, tempProject);
|
||||
//--
|
||||
if (Sapfor.getMinMaxDim(Sapfor.getTempCopy(new File(sapfor.call_command)), tempProject, test)) {
|
||||
Update(test);
|
||||
} else
|
||||
throw new RepositoryRefuseException("Не удалось определить размерность теста " + CommonUtils.Brackets(test.description));
|
||||
break;
|
||||
case c:
|
||||
test.max_dim = Utils.getCTestMaxDim(testFile);
|
||||
Update(test);
|
||||
break;
|
||||
}
|
||||
}
|
||||
//---
|
||||
public void CreateTestFromSingleFile(Account account, ServerSapfor sapfor, Group group, File file, String testDescription) throws Exception {
|
||||
Test test = new Test();
|
||||
test.description = testDescription;
|
||||
test.sender_name = account.name;
|
||||
test.sender_address = account.email;
|
||||
test.group_id = group.id;
|
||||
test.files = file.getName();
|
||||
Insert(test);
|
||||
//->>
|
||||
SaveTestFromSingleFile(sapfor, group, test, file);
|
||||
}
|
||||
public void RefreshGroup(Account account, ServerSapfor sapfor, Pair<Group, Vector<File>> groupData) throws Exception {
|
||||
Group group = groupData.getKey();
|
||||
Vector<File> files = groupData.getValue();
|
||||
//--
|
||||
Group oldGroup = groups.getGroupByDescription(group.language, group.description);
|
||||
if (oldGroup == null) {
|
||||
Insert(group);
|
||||
for (File file : files) {
|
||||
String testDescription = CommonUtils.getNameWithoutExtension(file.getName()) + "_" + group.language.getDVMCompile();
|
||||
CreateTestFromSingleFile(account, sapfor, group, file, testDescription);
|
||||
}
|
||||
} else {
|
||||
for (File file : files) {
|
||||
String testDescription = CommonUtils.getNameWithoutExtension(file.getName()) + "_" + group.language.getDVMCompile();
|
||||
Test oldTest = tests.getTestByDescription(oldGroup.id, testDescription);
|
||||
if (oldTest == null) {
|
||||
CreateTestFromSingleFile(account, sapfor, oldGroup, file, testDescription);
|
||||
} else {
|
||||
SaveTestFromSingleFile(sapfor, group, oldTest, file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public Vector<DVMPackage> getFirstActiveDVMPackageCopyForMachineURL(String arg) {
|
||||
Vector<DVMPackage> res = new Vector<>();
|
||||
Vector<DVMPackage> machinePackages = new Vector<>();
|
||||
//--
|
||||
//1. Получить список активных пакетов для машины.
|
||||
for (DVMPackage dvmPackage : dvmPackages.Data.values()) {
|
||||
switch (dvmPackage.state) {
|
||||
case Done:
|
||||
case DoneWithErrors:
|
||||
case Aborted:
|
||||
case Draft:
|
||||
case ConnectionError:
|
||||
break;
|
||||
default:
|
||||
if (dvmPackage.getMachine().getURL().equals(arg))
|
||||
machinePackages.add(dvmPackage);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!machinePackages.isEmpty()) {
|
||||
machinePackages.sort(new Comparator<DVMPackage>() {
|
||||
@Override
|
||||
public int compare(DVMPackage o1, DVMPackage o2) {
|
||||
return Integer.compare(o1.state.ordinal(), o2.state.ordinal());
|
||||
}
|
||||
});
|
||||
//-
|
||||
DVMPackage activePackage = machinePackages.lastElement();
|
||||
if (activePackage.state.equals(TasksPackageState.Queued)) {
|
||||
activePackage.state = TasksPackageState.TestsSynchronize;
|
||||
try {
|
||||
Update(activePackage);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
res.add(new DVMPackage(activePackage));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
public ServerSapfor getSapforCopyForCompilation() {
|
||||
for (ServerSapfor serverSapfor : serverSapfors.Data.values()) {
|
||||
if (serverSapfor.state.equals(ServerSapforState.Queued)) {
|
||||
return new ServerSapfor(serverSapfor);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
public Integer getInstalledSapforMaxVersion() {
|
||||
int max_version = CommonConstants.Nan;
|
||||
for (ServerSapfor sapfor : serverSapfors.Data.values()) {
|
||||
if (sapfor.state.equals(ServerSapforState.Done)) {
|
||||
int version = CommonConstants.Nan;
|
||||
try {
|
||||
version = Integer.parseInt(sapfor.version);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
if (version > max_version) max_version = version;
|
||||
}
|
||||
}
|
||||
return max_version;
|
||||
}
|
||||
public boolean hasActiveSapfors() {
|
||||
for (ServerSapfor serverSapfor : serverSapfors.Data.values()) {
|
||||
if (serverSapfor.state.isActive())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void UnselectAllGTC() {
|
||||
groups.CheckAll(false);
|
||||
tests.CheckAll(false);
|
||||
dvm_configurations.CheckAll(false);
|
||||
}
|
||||
|
||||
public void CheckTestsPackagesDependencies(Vector<Integer> testsIds, TextLog Log){
|
||||
//определить есть ли активные пакеты в которые входят упомянутые тесты
|
||||
//если есть выписать группа/тест причина - находится в активном пакете
|
||||
}
|
||||
|
||||
public void RefreshTestNameInConfigurations(Integer testId){
|
||||
//обновить имя теста во всех конфигурация
|
||||
}
|
||||
public void DeleteTestFromConfigurations(Integer testId){
|
||||
//обновить имя теста во всех конфигурация
|
||||
}
|
||||
//todo возможно рассмотреть вариант с синхроннизацией тестов для пакетов через команду серверу а не в нити
|
||||
//во избежание конфликта доступа,или удалением тестов во время копирования(?)
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package _VisualDVM.TestingSystem.Common.ThreadsPlanner;
|
||||
import Common.Utils.CommonUtils;
|
||||
import Common.Utils.InterruptThread;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Vector;
|
||||
public abstract class ThreadsPlanner {
|
||||
//-->
|
||||
protected Thread interruptThread = new InterruptThread(5000, () -> {
|
||||
try {
|
||||
Interrupt();
|
||||
} catch (Exception exception) {
|
||||
CommonUtils.MainLog.PrintException(exception);
|
||||
}
|
||||
System.exit(0);
|
||||
return null;
|
||||
});
|
||||
protected int maxKernels;
|
||||
protected int kernels;
|
||||
//---
|
||||
protected int threadMaxId = 0;
|
||||
protected int wait_ms;
|
||||
protected int done_threads = 0;
|
||||
protected int progress = 0;
|
||||
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() {
|
||||
CommonUtils.MainLog.Print("Planner started");
|
||||
try {
|
||||
//--
|
||||
while (!waitingThreads.isEmpty() || !activeThreads.isEmpty()) {
|
||||
CommonUtils.MainLog.Print(getThreadsSummary());
|
||||
checkActiveThreads();
|
||||
tryStartThreads();
|
||||
Thread.sleep(wait_ms);
|
||||
}
|
||||
//--
|
||||
} catch (Exception exception) {
|
||||
CommonUtils.MainLog.PrintException(exception);
|
||||
} finally {
|
||||
CommonUtils.MainLog.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++;
|
||||
done_threads++;
|
||||
}
|
||||
}
|
||||
activeThreads.removeAll(toExclude);
|
||||
//--
|
||||
double progress = ((double)done_threads/threads.size())*100.0;
|
||||
CommonUtils.MainLog.Print("done_threads="+done_threads+";all_threads="+threads.size()+";progress="+progress);
|
||||
File progress_file = new File("progress");
|
||||
try {
|
||||
FileUtils.writeStringToFile(progress_file, String.valueOf(((int)progress)));
|
||||
}
|
||||
catch (Exception exception){
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
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++;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user