сохранение и публикация файлов вывода при установке сапфора на сервере.

возможность указать автоматическую сборку сапфора после публикации компонента.
This commit is contained in:
2023-11-14 00:56:05 +03:00
parent 362d6b56ee
commit 38eea01f5c
14 changed files with 102 additions and 69 deletions

10
.idea/workspace.xml generated
View File

@@ -9,8 +9,18 @@
<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/Common/Constants.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/Constants.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Repository/Component/UI/PublishFields.form" beforeDir="false" afterPath="$PROJECT_DIR$/src/Repository/Component/UI/PublishFields.form" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Repository/Component/UI/PublishFields.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Repository/Component/UI/PublishFields.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Repository/RepositoryServer.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Repository/RepositoryServer.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Repository/Server/ComponentsServer.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Repository/Server/ComponentsServer.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Repository/Server/ServerCode.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Repository/Server/ServerCode.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/TestingSystem/TestingServer.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/TestingServer.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/InstallServerSapfor.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/InstallServerSapfor.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/PublishComponent.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/PublishComponent.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/SSH/ConnectionPass.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/SSH/ConnectionPass.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/UI/Interface/TestingWindow.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/UI/Interface/TestingWindow.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/UI/Main/MainForm.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/UI/Main/MainForm.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/UI/Main/TestingForm.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/UI/Main/TestingForm.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />

View File

@@ -11,6 +11,7 @@ public class Constants {
public static final String REPOSITORY_AUTHENTICATION = "--username dvmhuser --password dvmh2013 --non-interactive";
public static final String DVM_REPOSITORY = "http://svn.dvm-system.org/svn/dvmhrepo/dvm";
public static final String SAPFOR_REPOSITORY = "http://svn.dvm-system.org/svn/dvmhrepo/sapfor";
public static final String SAPFOR_REPOSITORY_BIN = "/sapfor/experts/Sapfor_2017/_bin";
//--
//-файлы-признаки
public static final String LOADED = "LOADED";

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="Repository.Component.UI.PublishFields">
<grid id="27dc6" binding="content" layout-manager="GridLayoutManager" row-count="7" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="27dc6" binding="content" layout-manager="GridLayoutManager" row-count="8" column-count="3" 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"/>
@@ -23,7 +23,7 @@
</component>
<scrollpane id="b33e5">
<constraints>
<grid row="6" column="0" row-span="1" col-span="3" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="7" column="0" row-span="1" col-span="3" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
@@ -39,7 +39,7 @@
</scrollpane>
<component id="fbdf3" class="javax.swing.JLabel">
<constraints>
<grid row="5" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="6" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="2"/>
@@ -49,7 +49,7 @@
</component>
<component id="21340" class="javax.swing.JCheckBox" binding="cbForceMail">
<constraints>
<grid row="1" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="2" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="0"/>
@@ -60,7 +60,7 @@
</component>
<component id="148fa" class="javax.swing.JCheckBox" binding="cbUpdateMinimalVersion">
<constraints>
<grid row="2" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="3" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="0"/>
@@ -71,7 +71,7 @@
</component>
<component id="b1e6f" class="javax.swing.JLabel">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
<grid row="4" 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="0"/>
@@ -80,7 +80,7 @@
</component>
<component id="7e269" class="javax.swing.JLabel" binding="lMinimalVersion">
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="1"/>
@@ -89,12 +89,12 @@
</component>
<hspacer id="37705">
<constraints>
<grid row="3" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="4" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="128e5" class="javax.swing.JLabel">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="0"/>
@@ -103,13 +103,24 @@
</component>
<component id="84e2b" class="javax.swing.JLabel" binding="lPublishingVersion">
<constraints>
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="1"/>
<text value="?"/>
</properties>
</component>
<component id="b01cb" class="javax.swing.JCheckBox" binding="cbAssemblyOnServer">
<constraints>
<grid row="1" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Times New Roman" size="16" style="0"/>
<selected value="true"/>
<text value="Собрать на сервере"/>
<verticalAlignment value="3"/>
</properties>
</component>
</children>
</grid>
</form>

View File

@@ -14,6 +14,7 @@ public class PublishFields implements DialogFields {
public JCheckBox cbUpdateMinimalVersion;
public JLabel lMinimalVersion;
public JLabel lPublishingVersion;
public JCheckBox cbAssemblyOnServer;
public PublishFields() {
cbNeedsBroadcast.addActionListener(new ActionListener() {
@Override

View File

@@ -135,12 +135,14 @@ public abstract class RepositoryServer<D extends Database> {
multipart.addBodyPart(attachmentBodyPart);
}
for (File f : directAttachements) {
if (f.exists()) {
MimeBodyPart attachmentBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource(f);
attachmentBodyPart.setDataHandler(new DataHandler(source));
attachmentBodyPart.setFileName(f.getName());
multipart.addBodyPart(attachmentBodyPart);
}
}
message.setContent(multipart);
Transport.send(message);
System.out.println("message sent");

View File

@@ -1,5 +1,4 @@
package Repository.Server;
import Common.Constants;
import Common.Database.DBObject;
import Common.Global;
import Common.Utils.Utils;
@@ -75,13 +74,6 @@ public class ComponentsServer extends RepositoryServer<BugReportsDatabase> {
Account account = null;
if (!Global.properties.OldServer) {
switch (code) {
case Patch:
Print("Очистка файлов в багрепортах");
for (BugReport bug: db.bugReports.Data.values()){
}
response = new ServerExchangeUnit_2021(ServerCode.OK);
break;
//<editor-fold desc="Регистрация">
case CheckSubscriberRole:
Print("Проверить роль пользователя");
@@ -419,7 +411,6 @@ public class ComponentsServer extends RepositoryServer<BugReportsDatabase> {
//bonus backup
if (rightNow.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY) {
Vector<String> targets = new Vector<>();
targets.add(Constants.MailAddress);
targets.addAll(Arrays.asList(Global.admins_mails));
EmailMessage message = new EmailMessage(
"db backup",

View File

@@ -73,5 +73,6 @@ public enum ServerCode {
GetFirstActiveSapforTasksPackage,
DownloadSapforTasksPackage,
Patch,
EmailSapforAssembly,
OLD
}

View File

@@ -10,6 +10,7 @@ import GlobalData.Tasks.TaskState;
import GlobalData.User.User;
import ProjectData.LanguageName;
import ProjectData.Project.db_project_info;
import Repository.EmailMessage;
import Repository.RepositoryRefuseException;
import Repository.RepositoryServer;
import Repository.Server.ServerCode;
@@ -39,6 +40,7 @@ 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;
@@ -313,51 +315,25 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
return (SapforTasksResults_json) Utils.jsonFromFile(
results_file, SapforTasksResults_json.class);
}
//надо в другое место.
/*
public Vector<String> CompareSapforPackages(SapforTasksPackage package1, SapforTasksPackage package2) throws Exception {
Vector<String> comparisonLog = new Vector<>();
// чтобы сравнивать. должен быть идентичный список тестов. (без учета последовательности)
// идентичный набор проходов (с учетом последовательности)
//идентичный набор флагов (?) без учета последовательности.
// то есть должны отличаться только тестируемые версии САПФОР.
SapforTasksResults_json results1_json = getSapforPackageResults(package1);
SapforTasksResults_json results2_json = getSapforPackageResults(package2);
if (results1_json.tasks.size() != results2_json.tasks.size()) {
comparisonLog.add("Количество задач в пакетах не совпадает.");
comparisonLog.add(package1.id + ": " + results1_json.tasks.size() + "/" + package2.id + ": " + results2_json.tasks.size());
return comparisonLog;
}
//подходит если все задачи из первого пакета содержатся во втором, и размер одинаковый.
Vector<SapforTask> sortedTasks2 = new Vector<>();
for (SapforTask task1 : results1_json.tasks) {
//на
boolean match = false;
for (SapforTask task2 : results2_json.tasks) {
if (task1.isComparable(task2)) {
match = true;
sortedTasks2.add(task2);
break;
}
}
if (!match) {
comparisonLog.add("Найдена не совпадающая задача.");
return comparisonLog;
}
}
for (SapforTask task1 : results1_json.tasks) {
for (SapforTask task2 : sortedTasks2) {
task1.Compare(task2, comparisonLog);
}
}
return comparisonLog;
}
*/
@Override
protected void Session() throws Exception {
DBObject dbObject = null;
Test test = null;
switch (code) {
case EmailSapforAssembly:
Print("Сообщить о сборке SAPFOR для пользователя " + request.arg);
Vector<String> assembly_info = (Vector<String>) request.object;
File out = Paths.get(Global.RepoDirectory.getAbsolutePath(), Constants.SAPFOR_REPOSITORY_BIN, Constants.out_file).toFile();
File err = Paths.get(Global.RepoDirectory.getAbsolutePath(), Constants.SAPFOR_REPOSITORY_BIN, Constants.err_file).toFile();
Vector<String> targets = new Vector<>(Arrays.asList(Global.admins_mails));
EmailMessage message = new EmailMessage(
"Выполнена сборка системы SAPFOR",
"Версия: " + assembly_info.get(0) + "\n" + "Статус: " + assembly_info.get(1),
targets
);
Email(message, out, err);
response = new ServerExchangeUnit_2021(ServerCode.OK);
break;
case PublishSapforPackageTasks:
Print("Опубликовать задачи SAPFOR для пользователя " + request.arg);
SetCurrentAccountDB(request.arg);

View File

@@ -1,5 +1,6 @@
package Visual_DVM_2021.Passes.All;
import Common.Constants;
import Common.Current;
import Common.Global;
import Common.Utils.Utils;
import GlobalData.RemoteFile.RemoteFile;
@@ -12,6 +13,7 @@ import Visual_DVM_2021.Passes.SSH.ConnectionPass;
import Visual_DVM_2021.Passes.TestingSystemPass;
import java.util.Date;
import java.util.Vector;
public class InstallServerSapfor extends ConnectionPass<Object> {
boolean result;
ServerSapfor serverSapfor;
@@ -49,7 +51,7 @@ public class InstallServerSapfor extends ConnectionPass<Object> {
protected void ServerAction() throws Exception {
RemoteFile testingSystemHome = new RemoteFile(sftpChannel.pwd(), "testing_system", true);
RemoteFile repo = new RemoteFile(testingSystemHome.full_name, "Repo", true);
RemoteFile repoSapforHome = new RemoteFile(repo.full_name + "/sapfor/experts/Sapfor_2017/_bin", true);
RemoteFile repoSapforHome = new RemoteFile(repo.full_name + Constants.SAPFOR_REPOSITORY_BIN, true);
//--
ShowMessage1("Синхронизация ветви DVM...");
ShellCommand("cd " + Utils.DQuotes(repo.full_name), "svn checkout " + Constants.REPOSITORY_AUTHENTICATION + " " + Constants.DVM_REPOSITORY + "\n");
@@ -61,8 +63,7 @@ public class InstallServerSapfor extends ConnectionPass<Object> {
if (Exists(repoSapforHome.full_name, repo_bin.name))
sftpChannel.rm(repo_bin.full_name);
//--
performScript(repoSapforHome, "cmake ../", "make -j 4" );
// ShellCommand("cd " + Utils.DQuotes(repoSapforHome.full_name), "cmake ../", "make -j 4");
performScript(repoSapforHome, "cmake ../", "make -j 4");
result = Exists(repoSapforHome.full_name, "Sapfor_F");
if (result) {
RemoteFile sapforsDirectory = new RemoteFile(testingSystemHome.full_name, "Sapfors", true);
@@ -93,6 +94,22 @@ public class InstallServerSapfor extends ConnectionPass<Object> {
}
}.Do();
}
new TestingSystemPass() {
@Override
public String getDescription() {
return "Рассылка выходных файлов сборки SAPFOR";
}
@Override
protected void ServerAction() throws Exception {
Vector<String> info = new Vector<>();
info.add(result ? serverSapfor.version : "?");
info.add(result ? "Успешно" : "С ошибками");
Command(new ServerExchangeUnit_2021(ServerCode.EmailSapforAssembly,
Current.getAccount().email,
info
));
}
}.Do();
}
@Override
protected boolean validate() {

View File

@@ -1,9 +1,11 @@
package Visual_DVM_2021.Passes.All;
import Common.Current;
import Common.Global;
import Common.UI.UI;
import Common.Utils.Utils;
import GlobalData.Account.AccountRole;
import Repository.Component.Component;
import Repository.Component.ComponentType;
import Repository.Component.UI.PublishForm;
import Repository.EmailMessage;
import Repository.RepositoryServer;
@@ -50,6 +52,13 @@ public class PublishComponent extends ComponentsRepositoryPass<Component> {
if (!target.isValidVersion(Log, "публикуемого")) {
return false;
}
if (target.getComponentType().equals(ComponentType.Sapfor_F)) {
f.fields.cbAssemblyOnServer.setVisible(true);
f.fields.cbAssemblyOnServer.setSelected(true);
} else {
f.fields.cbAssemblyOnServer.setVisible(false);
f.fields.cbAssemblyOnServer.setSelected(false);
}
if (f.ShowDialog(code().getDescription())) {
target.needs_update_minimal_version = f.fields.cbUpdateMinimalVersion.isSelected();
return true;
@@ -103,6 +112,12 @@ public class PublishComponent extends ComponentsRepositoryPass<Component> {
if (f.fields.cbForceMail.isSelected())
message.addAttachement(target.getFile());
Pass_2021.passes.get(PassCode_2021.Email).Do(message);
//---
if (target.getComponentType().equals(ComponentType.Sapfor_F) && f.fields.cbAssemblyOnServer.isSelected()) {
UI.getMainWindow().FocusTesting();
UI.getMainWindow().getTestingWindow().FocusSapforTesting();
passes.get(PassCode_2021.InstallServerSapfor).Do();
}
}
}
@Override

View File

@@ -9,6 +9,7 @@ import ProjectData.Project.db_project_info;
import Visual_DVM_2021.Passes.PassException;
import Visual_DVM_2021.Passes.Pass_2021;
import com.jcraft.jsch.*;
import javafx.util.Pair;
import java.io.*;
import java.net.SocketException;
@@ -387,7 +388,7 @@ public abstract class ConnectionPass<T> extends Pass_2021<T> {
if (!Exists(dir.parent, dir.name)) sftpChannel.mkdir(dir.full_name);
}
//--
public void performScript(RemoteFile directory, String... commands) throws Exception {
public Pair<RemoteFile, RemoteFile> performScript(RemoteFile directory, String... commands) throws Exception {
RemoteFile script_file = new RemoteFile(directory.full_name, Constants.script);
RemoteFile out = new RemoteFile(directory.full_name, Constants.out_file);
RemoteFile err = new RemoteFile(directory.full_name, Constants.err_file);
@@ -405,6 +406,8 @@ public abstract class ConnectionPass<T> extends Pass_2021<T> {
//--
ShellCommand("cd " + Utils.DQuotes(directory.full_name),
script_file.full_name + " 1>" + Constants.out_file + " 2>" + Constants.err_file);
return new Pair<>(out, err);
}
}

View File

@@ -18,4 +18,5 @@ public interface TestingWindow extends VisualizerForm {
void ShowCurrentSapforPackageVersion();
void ShowNoSapforPackageVersionEtalon();
void ShowNoSapforPackageVersion();
void FocusSapforTesting();
}

View File

@@ -241,7 +241,7 @@ public class MainForm extends Form implements MainWindow {
}
@Override
public void FocusTesting() {
globalTabs.setSelectedIndex(3);
globalTabs.setSelectedIndex(4);
}
@Override
public TestingWindow getTestingWindow() {

View File

@@ -175,4 +175,8 @@ public class TestingForm implements FormWithSplitters, TestingWindow {
Global.testingServer.account_db.sapforTasksPackages.mountUI(sapforTasksPackagesPanel);
Global.testingServer.account_db.sapforTasks.mountUI(sapforTasksPanel);
}
@Override
public void FocusSapforTesting() {
testingTabs.setSelectedIndex(1);
}
}