промежуточный. на стороне сервера реализовано создание тестов на основе версий.

This commit is contained in:
2025-02-11 21:28:35 +03:00
parent 4ef8d4b52c
commit 25eabf6852
6 changed files with 144 additions and 64 deletions

15
.idea/workspace.xml generated
View File

@@ -8,15 +8,12 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment=""> <list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/CompareDVMRunTasks.java" beforeDir="false" /> <change beforePath="$PROJECT_DIR$/properties" beforeDir="false" afterPath="$PROJECT_DIR$/properties" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/DownloadDVMPackage.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/DownloadDVMPackage.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/TestPass.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/TestPass.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Passes/PassCode.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Passes/PassCode.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/_VisualDVM/Repository/Component/Visualiser.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Repository/Component/Visualiser.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/DVM/DVMTasks/UI/DVMRunTasksForm.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/DVM/DVMTasks/UI/DVMRunTasksForm.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/Common/Test/UI/TestsForm.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/Common/Test/UI/TestsForm.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/DVM/RemoteDVMTestingPlanner.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/DVM/RemoteDVMTestingPlanner.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/Common/TestingServer.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/Common/TestingServer.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Visual/Interface/TestingWindow.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Visual/Interface/TestingWindow.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/_VisualDVM/Visual/Menus/MainMenuBar/MainMenuBar.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Visual/Menus/MainMenuBar/MainMenuBar.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Visual/Windows/DVMRunTasksComparisonForm.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Visual/Windows/TestingForm.form" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Visual/Windows/TestingForm.form" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Visual/Windows/TestingForm.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Visual/Windows/TestingForm.java" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />

View File

@@ -1,42 +1,39 @@
package _VisualDVM.Passes.All; package _VisualDVM.Passes.All;
import Common.Passes.Pass; import Common.Utils.Utils_;
import Common.Visual.UI;
import _VisualDVM.Global; import _VisualDVM.Global;
import _VisualDVM.Passes.PassCode;
import _VisualDVM.Passes.Server.TestingServerPass; import _VisualDVM.Passes.Server.TestingServerPass;
import _VisualDVM.Repository.Server.ServerCode; import _VisualDVM.Repository.Server.ServerCode;
import _VisualDVM.TestingSystem.Common.Test.Test; import _VisualDVM.TestingSystem.Common.Group.Group;
import _VisualDVM.TestingSystem.SAPFOR.SapforPackage.SapforPackage;
import java.io.File;
import java.util.Vector;
public class TestPass extends TestingServerPass { public class TestPass extends TestingServerPass {
/* Group group;
LinkedHashMap<Integer,SapforConfiguration> unpackConfigurationsOld(SapforPackage sapforPackage){ SapforPackage sapforPackage;
LinkedHashMap<Integer,SapforConfiguration> res = new LinkedHashMap<>();
Vector<String> names = Utils.unpack_s(sapforPackage.configurationsNames,";");
for (String name: names) {
SapforConfiguration configuration = Global.testingServer.db.sapforConfigurations.getConfigurationByDescription(name);
if ((configuration!=null)&&!res.containsKey(configuration.id)){
res.put(configuration.id,configuration);
}
}
return res;
}
@Override @Override
protected void body() throws Exception { protected boolean canStart(Object... args) throws Exception {
// LinkedHashMap<Integer> if (Global.testingServer.db.CheckCurrent(Log, Group.class, SapforPackage.class)){
for (SapforPackage sapforPackage: Global.testingServer.db.sapforPackages.Data.values()){ group = Global.testingServer.db.groups.getUI().getCurrent();
LinkedHashMap<Integer,SapforConfiguration> configurations = unpackConfigurationsOld(sapforPackage); sapforPackage = Global.testingServer.db.sapforPackages.getUI().getCurrent();
sapforPackage.saveConfigurationsAsJson(new Vector<>(configurations.values())); return SendRequest(ServerCode.TestCode, group.id+"\n"+sapforPackage.id, null, 0 );
Global.testingServer.db.Update(sapforPackage);
} }
return false;
} }
*/
@Override @Override
protected void body() throws Exception { protected void body() throws Exception {
if (!SendRequest(ServerCode.TestCode));
/* Vector<String> res = (Vector<String>) request.server_response.object;
for (Test test: Global.testingServer.db.tests.Data.values()){ System.out.println("--");
if (!SendRequest(ServerCode.DownloadTest, String.valueOf(test.id))){ for (String path: res){
UI.Info(String.valueOf(test.id)); System.out.println(Utils_.Brackets(path));
}; }
} System.out.println("--");
*/ }
@Override
protected void performFinish() throws Exception {
Global.mainModule.getPass(PassCode.SynchronizeTests).Do();
} }
} }

View File

@@ -62,7 +62,7 @@ public class Visualiser extends Component {
//http://www.seostella.com/ru/article/2012/02/05/formatirovanie-daty-v-java.html //http://www.seostella.com/ru/article/2012/02/05/formatirovanie-daty-v-java.html
@Override @Override
public void GetVersionInfo() { public void GetVersionInfo() {
version = 1151; version = 1153;
String pattern = "MMM dd yyyy HH:mm:ss"; String pattern = "MMM dd yyyy HH:mm:ss";
DateFormat df = new SimpleDateFormat(pattern, Locale.ENGLISH); DateFormat df = new SimpleDateFormat(pattern, Locale.ENGLISH);
date_text = df.format(getClassBuildTime()); date_text = df.format(getClassBuildTime());

View File

@@ -87,5 +87,9 @@ public class TestsForm extends DataSetControlForm<Test> {
new HeaderTextFilter<>(dataSource, 2, 65) new HeaderTextFilter<>(dataSource, 2, 65)
); );
} }
@Override
protected void MouseAction2() throws Exception {
Global.mainModule.getPass(PassCode.DownloadTest).Do();
}
}; };

View File

@@ -5,6 +5,7 @@ import Common.Database.Objects.riDBObject;
import Common.Database.RepositoryRefuseException; import Common.Database.RepositoryRefuseException;
import Common.Utils.TextLog; import Common.Utils.TextLog;
import Common.Utils.Utils_; import Common.Utils.Utils_;
import Common.Utils.Vector_;
import _VisualDVM.Constants; import _VisualDVM.Constants;
import _VisualDVM.Global; import _VisualDVM.Global;
import _VisualDVM.GlobalData.Account.Account; import _VisualDVM.GlobalData.Account.Account;
@@ -29,10 +30,12 @@ import _VisualDVM.TestingSystem.DVM.DVMPackage.DVMPackage_json;
import _VisualDVM.TestingSystem.DVM.DVMSettings.DVMSettings; import _VisualDVM.TestingSystem.DVM.DVMSettings.DVMSettings;
import _VisualDVM.TestingSystem.DVM.DVMTestingChecker; import _VisualDVM.TestingSystem.DVM.DVMTestingChecker;
import _VisualDVM.TestingSystem.SAPFOR.Json.SapforPackage_json; import _VisualDVM.TestingSystem.SAPFOR.Json.SapforPackage_json;
import _VisualDVM.TestingSystem.SAPFOR.Json.SapforVersion_json;
import _VisualDVM.TestingSystem.SAPFOR.SapforConfiguration.SapforConfiguration; import _VisualDVM.TestingSystem.SAPFOR.SapforConfiguration.SapforConfiguration;
import _VisualDVM.TestingSystem.SAPFOR.SapforPackage.SapforPackage; import _VisualDVM.TestingSystem.SAPFOR.SapforPackage.SapforPackage;
import _VisualDVM.TestingSystem.SAPFOR.SapforSettings.SapforSettings; import _VisualDVM.TestingSystem.SAPFOR.SapforSettings.SapforSettings;
import _VisualDVM.TestingSystem.SAPFOR.SapforSettingsCommand.SapforSettingsCommand; import _VisualDVM.TestingSystem.SAPFOR.SapforSettingsCommand.SapforSettingsCommand;
import _VisualDVM.TestingSystem.SAPFOR.SapforTask.SapforTask;
import _VisualDVM.TestingSystem.SAPFOR.SapforTestingPlanner; import _VisualDVM.TestingSystem.SAPFOR.SapforTestingPlanner;
import _VisualDVM.TestingSystem.SAPFOR.ServerSapfor.ServerSapfor; import _VisualDVM.TestingSystem.SAPFOR.ServerSapfor.ServerSapfor;
import _VisualDVM.TestingSystem.SAPFOR.ServerSapfor.ServerSapforState; import _VisualDVM.TestingSystem.SAPFOR.ServerSapfor.ServerSapforState;
@@ -104,8 +107,8 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
} }
} }
@Override @Override
protected void afterCloneAction(riDBObject src, riDBObject dst) throws Exception{ protected void afterCloneAction(riDBObject src, riDBObject dst) throws Exception {
if (src instanceof SapforSettings){ if (src instanceof SapforSettings) {
Vector<PassCode> codes = new Vector<>(); Vector<PassCode> codes = new Vector<>();
for (SapforSettingsCommand command : db.sapforSettingsCommands.Data.values()) for (SapforSettingsCommand command : db.sapforSettingsCommands.Data.values())
if (command.sapforsettings_id == src.id) codes.add(command.passCode); if (command.sapforsettings_id == src.id) codes.add(command.passCode);
@@ -133,8 +136,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
db.Update(sapforConfiguration); db.Update(sapforConfiguration);
} }
} }
} } else if (object instanceof DVMSettings) {
else if (object instanceof DVMSettings) {
DVMSettings dvmSettings = (DVMSettings) object; DVMSettings dvmSettings = (DVMSettings) object;
//- //-
for (DVMConfiguration dvmConfiguration : db.dvmConfigurations.Data.values()) { for (DVMConfiguration dvmConfiguration : db.dvmConfigurations.Data.values()) {
@@ -142,8 +144,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
db.Update(dvmConfiguration); db.Update(dvmConfiguration);
} }
} }
} } else if (object instanceof SapforSettings) {
else if (object instanceof SapforSettings) {
SapforSettings sapforSettings = (SapforSettings) object; SapforSettings sapforSettings = (SapforSettings) object;
for (SapforConfiguration sapforConfiguration : db.sapforConfigurations.Data.values()) { for (SapforConfiguration sapforConfiguration : db.sapforConfigurations.Data.values()) {
if (sapforConfiguration.tryUpdateSettings(sapforSettings)) { if (sapforConfiguration.tryUpdateSettings(sapforSettings)) {
@@ -170,8 +171,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
} }
} }
//-- //--
} } else if (object instanceof Group) {
else if (object instanceof Group) {
Group group = (Group) object; Group group = (Group) object;
LinkedHashMap<Integer, Test> groupTests = db.getMapByFKi(group, Test.class); LinkedHashMap<Integer, Test> groupTests = db.getMapByFKi(group, Test.class);
//-- //--
@@ -193,7 +193,6 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
Utils_.forceDeleteWithCheck(group_test.getArchive()); Utils_.forceDeleteWithCheck(group_test.getArchive());
Utils_.forceDeleteWithCheck(group_test.getServerPath()); Utils_.forceDeleteWithCheck(group_test.getServerPath());
} }
//-- //--
} else if (object instanceof ServerSapfor) { } else if (object instanceof ServerSapfor) {
Utils_.forceDeleteWithCheck( Utils_.forceDeleteWithCheck(
@@ -208,9 +207,9 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
} else if (object instanceof SapforPackage) { } else if (object instanceof SapforPackage) {
SapforPackage sapforPackage = (SapforPackage) object; SapforPackage sapforPackage = (SapforPackage) object;
//-- //--
for (SapforConfiguration sapforConfiguration: db.sapforConfigurations.Data.values()){ for (SapforConfiguration sapforConfiguration : db.sapforConfigurations.Data.values()) {
if (sapforConfiguration.ethalon_id==sapforPackage.id){ if (sapforConfiguration.ethalon_id == sapforPackage.id) {
sapforConfiguration.ethalon_id= CommonConstants.Nan; sapforConfiguration.ethalon_id = CommonConstants.Nan;
db.Update(sapforConfiguration); db.Update(sapforConfiguration);
} }
} }
@@ -257,7 +256,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
//основа //основа
@Override @Override
public int getPort() { public int getPort() {
return Constants.TestingServerPort; return Constants.TestingServerPort;
} }
@Override @Override
protected void startAdditionalThreads() { protected void startAdditionalThreads() {
@@ -281,7 +280,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
"Не удалось запустить автоматическое тестирование версии " + request.arg + " системы SAPFOR", "Не удалось запустить автоматическое тестирование версии " + request.arg + " системы SAPFOR",
Log.toString() Log.toString()
); );
for (String address: Constants.admins_mails){ for (String address : Constants.admins_mails) {
Email(message, address); Email(message, address);
} }
break; break;
@@ -375,7 +374,8 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
GetSapforMaxVersion(); GetSapforMaxVersion();
break; break;
case TestCode: case TestCode:
checkUnpackedTests(); Print("Получить финальные версии пакета тестирования SAPFOR");
JoinSapforPackageToGroup();
break; break;
default: default:
throw new RepositoryRefuseException("Неподдерживаемый код: " + code); throw new RepositoryRefuseException("Неподдерживаемый код: " + code);
@@ -745,18 +745,101 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
//-- //--
return target; return target;
} }
public void checkUnpackedTests() throws Exception{ public void checkUnpackedTests() throws Exception {
for (Test test: db.tests.Data.values()){ for (Test test : db.tests.Data.values()) {
File testHome = test.getServerPath(); File testHome = test.getServerPath();
if (!testHome.exists()){ if (!testHome.exists()) {
throw new RepositoryRefuseException(test.id+" не существует папка"); throw new RepositoryRefuseException(test.id + " не существует папка");
} }
File testArchive = test.getArchive(); File testArchive = test.getArchive();
if (!testArchive.exists()){ if (!testArchive.exists()) {
throw new RepositoryRefuseException(test.id+" не существует архив"); throw new RepositoryRefuseException(test.id + " не существует архив");
} }
} }
response = new ServerExchangeUnit_2021(ServerCode.OK); response = new ServerExchangeUnit_2021(ServerCode.OK);
} }
public Vector<String> getSapforTaskResults(SapforTask task) throws Exception {
Vector<String> res = new Vector<>();
//--
if (!task.variants.isEmpty()) {
for (SapforVersion_json version_json : task.variants) {
res.add(version_json.version);
}
} else {
if (!task.versions.isEmpty()) {
res.add(task.versions.lastElement().version);
}
}
return res;
}
private void JoinSapforPackageToGroup() throws Exception {
String[] packed = request.arg.split("\n");
int groupId = Integer.parseInt(packed[0]);
int packageId = Integer.parseInt(packed[1]);
if (!db.sapforPackages.containsKey(packageId))
throw new RepositoryRefuseException("Пакета с ключом " + packageId + " не существует!");
if (!db.groups.containsKey(groupId))
throw new RepositoryRefuseException("Группы с ключом " + groupId + " не существует!");
//--
SapforPackage sapforPackage = db.sapforPackages.get(packageId);
Group group = db.groups.get(groupId);
//--
SapforPackage_json json = Utils_.jsonFromFile(sapforPackage.getJsonFile(), SapforPackage_json.class);
LinkedHashMap<String, File> versions = new LinkedHashMap<>();
Vector<String> paths = new Vector<>();
for (SapforTask task : json.tasks) {
File task_root = Paths.get(
sapforPackage.getLocalWorkspace().getAbsolutePath(),
String.valueOf(task.set_id),
String.valueOf(task.sapfor_configuration_id)
).toFile();
for (String path : getSapforTaskResults(task)) {
File versionProject = Paths.get(task_root.getAbsolutePath(), path).toFile();
Vector<String> name_parts = new Vector_<>(
String.valueOf(task.id),
task.test_description,
versionProject.getName()
);
versions.put(String.join("_", name_parts),versionProject);
paths.add(versionProject.getAbsolutePath());
}
}
ZipFolderPass zip = new ZipFolderPass();
//создание тестов.
for (String description : versions.keySet()) {
File src = versions.get(description);
File [] files = src.listFiles(pathname -> !pathname.isDirectory());
if (files!=null && files.length>0){
//--
Vector<String> filesNames = new Vector<>();
for (File file: files)
filesNames.add(file.getName());
//--
Test test = new Test();
test.group_id = group.id;
test.description = description;
test.files = String.join("\n", filesNames);
db.Insert(test);
//---
File testProject = new File(Global.TestsDirectory, String.valueOf(test.id));
File testArchive = new File(Global.TestsDirectory, test.id + ".zip");
//---
if (testProject.exists())
FileUtils.forceDelete(testProject);
if (testArchive.exists())
FileUtils.forceDelete(testArchive);
//---
FileUtils.moveDirectory(src, testProject);
//---
if (!zip.Do(testProject.getAbsolutePath(), testArchive.getAbsolutePath())) {
db.Delete(test);
throw new RepositoryRefuseException("Не удалось переписать архив проекта");
}
}
}
//-
response = new ServerExchangeUnit_2021(ServerCode.OK);
response.object= paths;
}
} }

View File

@@ -60,8 +60,7 @@ public class MainMenuBar extends VisualiserMenuBar {
addPasses(PassCode.ShowInstruction); addPasses(PassCode.ShowInstruction);
//- //-
setPreferredSize(new Dimension(0, 30)); setPreferredSize(new Dimension(0, 30));
//--- //--
/*
add(new MenuBarButton() { add(new MenuBarButton() {
{ {
setIcon("/Common/icons/Apply.png"); setIcon("/Common/icons/Apply.png");
@@ -71,7 +70,7 @@ public class MainMenuBar extends VisualiserMenuBar {
}); });
} }
}); });
*/ //--
add(new JSeparator()); add(new JSeparator());
add(MachineButton = new MenuBarButton() { add(MachineButton = new MenuBarButton() {
{ {