промежуточный. проверка инициализации при тестировании..
This commit is contained in:
5
.idea/workspace.xml
generated
5
.idea/workspace.xml
generated
@@ -7,7 +7,12 @@
|
||||
</component>
|
||||
<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$/properties" beforeDir="false" afterPath="$PROJECT_DIR$/properties" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/GlobalData/User/User.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/GlobalData/User/User.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Repository/Component/Visualiser.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Repository/Component/Visualiser.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/TestingSystem/DVM/RemoteDVMTestingPlanner.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/DVM/RemoteDVMTestingPlanner.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/TestingSystem/DVM/UserConnection.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/DVM/UserConnection.java" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
"Mode": "Normal",
|
||||
"ServerAddress": "alex-freenas.ddns.net",
|
||||
"ServerUserName": "testuser",
|
||||
"ServerUserSHHPort": 2000,
|
||||
"ServerUserSHHPort": 23,
|
||||
"ComponentsServerPort": 7995,
|
||||
"TestingServerPort": 7998,
|
||||
"TestingServerPort": 7996,
|
||||
"SocketTimeout": 5000,
|
||||
"OldServer": false,
|
||||
"SMTPHost": "smtp.mail.ru",
|
||||
|
||||
@@ -15,6 +15,11 @@ public class User extends iDBObject {
|
||||
public UserAuthentication authentication = UserAuthentication.password;
|
||||
public String workspace = ""; //рабочая папка визуализатора пользователя на машине. полный путь.
|
||||
public UserState state = UserState.initial;
|
||||
/*
|
||||
@Description("DEFAULT '?'")
|
||||
public String email = "?";
|
||||
*/
|
||||
//--
|
||||
public User(Machine machine_in, String login_in, String password_in) {
|
||||
machine_id = machine_in.id;
|
||||
login = login_in;
|
||||
|
||||
@@ -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 = 1100;
|
||||
version = 1101;
|
||||
String pattern = "MMM dd yyyy HH:mm:ss";
|
||||
DateFormat df = new SimpleDateFormat(pattern, Locale.ENGLISH);
|
||||
date_text = df.format(getClassBuildTime());
|
||||
|
||||
@@ -39,6 +39,8 @@ public class RemoteDVMTestingPlanner extends DVMTestingPlanner {
|
||||
try {
|
||||
user.connection = new UserConnection(machine, user);
|
||||
Print("Соединение c " + machine.getURL() + " " + user.login + " успешно установлено.");
|
||||
Print("Проверка инициализации..");
|
||||
user.connection.CheckUserInitialization();
|
||||
} catch (Exception ex) {
|
||||
Print(ex.toString());
|
||||
user.connection = null;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package TestingSystem.DVM;
|
||||
import Common.Constants;
|
||||
import Common.Current;
|
||||
import Common.Global;
|
||||
import Common.Utils.Utils;
|
||||
import GlobalData.Machine.Machine;
|
||||
@@ -32,7 +33,13 @@ public class UserConnection {
|
||||
PipedInputStream pout = null;
|
||||
InputStreamReader fromServer = null;
|
||||
//---
|
||||
public UserConnection(Machine machine, User user) throws Exception {
|
||||
Machine machine = null;
|
||||
User user = null;
|
||||
//---
|
||||
public UserConnection(Machine machine_in, User user_in) throws Exception {
|
||||
machine = machine_in;
|
||||
user = user_in;
|
||||
//--
|
||||
session = (jsch = new JSch()).getSession(user.login, machine.address, machine.port);
|
||||
session.setPassword(user.password);
|
||||
session.setConfig("StrictHostKeyChecking", "no");
|
||||
@@ -101,19 +108,6 @@ public class UserConnection {
|
||||
jsch = null;
|
||||
System.gc();
|
||||
}
|
||||
//--
|
||||
//todo из за мусора результатом пользоваться в общем случае невозможно.
|
||||
//следует перенаправлять вывод в какой нибудь временный файл на сервере.
|
||||
/*
|
||||
public String ShellCommand(String command) throws Exception {
|
||||
StringBuilder result = new StringBuilder();
|
||||
pin.write((command + "\r\n").getBytes());
|
||||
ShellParser.ReadInvitation(fromServer); //первое приглашение после эхо. возможен мусор.
|
||||
result.append(ShellParser.getCommandResult(fromServer)); //возможный результат и второе приглашение.
|
||||
String[] data = result.toString().split("\n");
|
||||
return (data.length > 0) ? data[data.length - 1] : result.toString();
|
||||
}
|
||||
*/
|
||||
public void getSingleFile(String src, String dst) throws Exception {
|
||||
sftpChannel.get(src, dst);
|
||||
}
|
||||
@@ -467,8 +461,8 @@ public class UserConnection {
|
||||
System.gc();
|
||||
}
|
||||
public void waitForFileCreation(RemoteFile file) throws Exception {
|
||||
while (!Exists(file)){
|
||||
System.out.println(file.full_name +" NOT FOUND");
|
||||
while (!Exists(file)) {
|
||||
System.out.println(file.full_name + " NOT FOUND");
|
||||
Utils.sleep(1000);
|
||||
}
|
||||
}
|
||||
@@ -477,7 +471,7 @@ public class UserConnection {
|
||||
commands_.add("cd " + Utils.DQuotes(directory.full_name));
|
||||
for (int i = 0; i < commands.length; ++i) {
|
||||
if (i == commands.length - 1) {
|
||||
commands_.add(commands[i] + " 1>"+Utils.DQuotes(outFileName));
|
||||
commands_.add(commands[i] + " 1>" + Utils.DQuotes(outFileName));
|
||||
} else {
|
||||
commands_.add(commands[i]);
|
||||
}
|
||||
@@ -493,9 +487,43 @@ public class UserConnection {
|
||||
sftpChannel.rm(outFile.full_name);
|
||||
ShellConnect();
|
||||
pin.write(("nohup " + start_command + " &\r\n").getBytes());
|
||||
|
||||
waitForFileCreation(outFile);
|
||||
ShellDisconnect();
|
||||
return readFromFile(outFile).replace("\n","").replace("\r","");
|
||||
return readFromFile(outFile).replace("\n", "").replace("\r", "");
|
||||
}
|
||||
//--
|
||||
public void CheckUserInitialization() throws Exception {
|
||||
RemoteFile userWorkspace = new RemoteFile(user.workspace, true);
|
||||
if (!Exists(userWorkspace)){
|
||||
System.out.println("создание папки пользователя");
|
||||
sftpChannel.mkdir(userWorkspace.full_name);
|
||||
//--
|
||||
RemoteFile modulesDirectory= new RemoteFile(userWorkspace, "modules");
|
||||
RemoteFile projectsDirectory = new RemoteFile(userWorkspace, "projects");
|
||||
RemoteFile testsDirectory = new RemoteFile(userWorkspace, "tests");
|
||||
//--
|
||||
Vector<RemoteFile> subdirectories = new Vector<>();
|
||||
subdirectories.add(modulesDirectory);
|
||||
subdirectories.add(projectsDirectory);
|
||||
subdirectories.add(testsDirectory);
|
||||
System.out.println("создание рабочих подпапок");
|
||||
for (RemoteFile remoteFile : subdirectories)
|
||||
sftpChannel.mkdir(remoteFile.full_name);
|
||||
//--
|
||||
System.out.println("закачка кода модулей");
|
||||
for (String resource_name : Constants.resourses_names) {
|
||||
System.out.println(resource_name);
|
||||
putResource(modulesDirectory, resource_name);
|
||||
}
|
||||
//-
|
||||
System.out.println("Сборка модулей...");
|
||||
String modules_log = compileModules(modulesDirectory);
|
||||
if (!modules_log.isEmpty())
|
||||
throw new PassException(modules_log);
|
||||
/*
|
||||
RemoteFile info = new RemoteFile(userWorkspace, user.email);
|
||||
user.connection.writeToFile("", info);
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user