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

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">
<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$/src/_VisualDVM/Passes/All/CompareDVMRunTasks.java" beforeDir="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/PassCode.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Passes/PassCode.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/DVM/RemoteDVMTestingPlanner.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/DVM/RemoteDVMTestingPlanner.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/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" />
<change beforePath="$PROJECT_DIR$/properties" beforeDir="false" afterPath="$PROJECT_DIR$/properties" 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/Repository/Component/Visualiser.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Repository/Component/Visualiser.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/Common/TestingServer.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/Common/TestingServer.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" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />

View File

@@ -1,42 +1,39 @@
package _VisualDVM.Passes.All;
import Common.Passes.Pass;
import Common.Visual.UI;
import Common.Utils.Utils_;
import _VisualDVM.Global;
import _VisualDVM.Passes.PassCode;
import _VisualDVM.Passes.Server.TestingServerPass;
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 {
/*
LinkedHashMap<Integer,SapforConfiguration> unpackConfigurationsOld(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;
}
Group group;
SapforPackage sapforPackage;
@Override
protected void body() throws Exception {
// LinkedHashMap<Integer>
for (SapforPackage sapforPackage: Global.testingServer.db.sapforPackages.Data.values()){
LinkedHashMap<Integer,SapforConfiguration> configurations = unpackConfigurationsOld(sapforPackage);
sapforPackage.saveConfigurationsAsJson(new Vector<>(configurations.values()));
Global.testingServer.db.Update(sapforPackage);
protected boolean canStart(Object... args) throws Exception {
if (Global.testingServer.db.CheckCurrent(Log, Group.class, SapforPackage.class)){
group = Global.testingServer.db.groups.getUI().getCurrent();
sapforPackage = Global.testingServer.db.sapforPackages.getUI().getCurrent();
return SendRequest(ServerCode.TestCode, group.id+"\n"+sapforPackage.id, null, 0 );
}
return false;
}
*/
@Override
protected void body() throws Exception {
if (!SendRequest(ServerCode.TestCode));
/*
for (Test test: Global.testingServer.db.tests.Data.values()){
if (!SendRequest(ServerCode.DownloadTest, String.valueOf(test.id))){
UI.Info(String.valueOf(test.id));
};
}
*/
Vector<String> res = (Vector<String>) request.server_response.object;
System.out.println("--");
for (String path: res){
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
@Override
public void GetVersionInfo() {
version = 1151;
version = 1153;
String pattern = "MMM dd yyyy HH:mm:ss";
DateFormat df = new SimpleDateFormat(pattern, Locale.ENGLISH);
date_text = df.format(getClassBuildTime());

View File

@@ -87,5 +87,9 @@ public class TestsForm extends DataSetControlForm<Test> {
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.Utils.TextLog;
import Common.Utils.Utils_;
import Common.Utils.Vector_;
import _VisualDVM.Constants;
import _VisualDVM.Global;
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.DVMTestingChecker;
import _VisualDVM.TestingSystem.SAPFOR.Json.SapforPackage_json;
import _VisualDVM.TestingSystem.SAPFOR.Json.SapforVersion_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.SapforTask.SapforTask;
import _VisualDVM.TestingSystem.SAPFOR.SapforTestingPlanner;
import _VisualDVM.TestingSystem.SAPFOR.ServerSapfor.ServerSapfor;
import _VisualDVM.TestingSystem.SAPFOR.ServerSapfor.ServerSapforState;
@@ -104,8 +107,8 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
}
}
@Override
protected void afterCloneAction(riDBObject src, riDBObject dst) throws Exception{
if (src instanceof SapforSettings){
protected void afterCloneAction(riDBObject src, riDBObject dst) throws Exception {
if (src instanceof SapforSettings) {
Vector<PassCode> codes = new Vector<>();
for (SapforSettingsCommand command : db.sapforSettingsCommands.Data.values())
if (command.sapforsettings_id == src.id) codes.add(command.passCode);
@@ -133,8 +136,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
db.Update(sapforConfiguration);
}
}
}
else if (object instanceof DVMSettings) {
} else if (object instanceof DVMSettings) {
DVMSettings dvmSettings = (DVMSettings) object;
//-
for (DVMConfiguration dvmConfiguration : db.dvmConfigurations.Data.values()) {
@@ -142,8 +144,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
db.Update(dvmConfiguration);
}
}
}
else if (object instanceof SapforSettings) {
} else if (object instanceof SapforSettings) {
SapforSettings sapforSettings = (SapforSettings) object;
for (SapforConfiguration sapforConfiguration : db.sapforConfigurations.Data.values()) {
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;
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.getServerPath());
}
//--
} else if (object instanceof ServerSapfor) {
Utils_.forceDeleteWithCheck(
@@ -208,9 +207,9 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
} else if (object instanceof SapforPackage) {
SapforPackage sapforPackage = (SapforPackage) object;
//--
for (SapforConfiguration sapforConfiguration: db.sapforConfigurations.Data.values()){
if (sapforConfiguration.ethalon_id==sapforPackage.id){
sapforConfiguration.ethalon_id= CommonConstants.Nan;
for (SapforConfiguration sapforConfiguration : db.sapforConfigurations.Data.values()) {
if (sapforConfiguration.ethalon_id == sapforPackage.id) {
sapforConfiguration.ethalon_id = CommonConstants.Nan;
db.Update(sapforConfiguration);
}
}
@@ -257,7 +256,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
//основа
@Override
public int getPort() {
return Constants.TestingServerPort;
return Constants.TestingServerPort;
}
@Override
protected void startAdditionalThreads() {
@@ -281,7 +280,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
"Не удалось запустить автоматическое тестирование версии " + request.arg + " системы SAPFOR",
Log.toString()
);
for (String address: Constants.admins_mails){
for (String address : Constants.admins_mails) {
Email(message, address);
}
break;
@@ -375,7 +374,8 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
GetSapforMaxVersion();
break;
case TestCode:
checkUnpackedTests();
Print("Получить финальные версии пакета тестирования SAPFOR");
JoinSapforPackageToGroup();
break;
default:
throw new RepositoryRefuseException("Неподдерживаемый код: " + code);
@@ -745,18 +745,101 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
//--
return target;
}
public void checkUnpackedTests() throws Exception{
for (Test test: db.tests.Data.values()){
public void checkUnpackedTests() throws Exception {
for (Test test : db.tests.Data.values()) {
File testHome = test.getServerPath();
if (!testHome.exists()){
throw new RepositoryRefuseException(test.id+" не существует папка");
if (!testHome.exists()) {
throw new RepositoryRefuseException(test.id + " не существует папка");
}
File testArchive = test.getArchive();
if (!testArchive.exists()){
throw new RepositoryRefuseException(test.id+" не существует архив");
if (!testArchive.exists()) {
throw new RepositoryRefuseException(test.id + " не существует архив");
}
}
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);
//-
setPreferredSize(new Dimension(0, 30));
//---
/*
//--
add(new MenuBarButton() {
{
setIcon("/Common/icons/Apply.png");
@@ -71,7 +70,7 @@ public class MainMenuBar extends VisualiserMenuBar {
});
}
});
*/
//--
add(new JSeparator());
add(MachineButton = new MenuBarButton() {
{