NodeDeployTask { @VisibleForTesting String qsubScript(String nodeName, String nodeConfigFileName, int numberOfCpus) { StringBuilder sb = new StringBuilder(); sb.append("#PBS -N ").append(nodeName).append("\n") .append("#PBS -l nodes=1:ppn=").append(numberOfCpus).append("\n") .append("#PBS -q ").append(queueName).append("\n") .append("#PBS -p 0\n") .append("#PBS -j oe\n") .append("#PBS -m b\n") .append("#PBS -m e\n") .append("#PBS -m a\n") .append("#PBS -V\n") .append("#PBS -o out/").append(nodeName).append(".out\n") .append("#PBS -e err/").append(nodeName).append(".err\n"); if (isValidEmail(email)) { sb.append("#PBS -M ").append(email).append("\n"); } sb.append("\n").append("workingDir=/home/torque/tmp/${USER}.${PBS_JOBID}\n").append("cp -r ~/jppf-node $workingDir/jppf-node\n").append("cd $workingDir/jppf-node\n").append("chmod +x startNode.sh\n").append("./startNode.sh ").append(nodeConfigFileName).append(" true false ").append("\"").append(jvmOptions).append("\"").append("\n"); return sb.toString(); } NodeDeployTask(TorqueNodeDeployment torqueNodeDeployment, int nodeNumber,
            TorqueNodeConfiguration nodeConfiguration, TorqueConfiguration torqueConfiguration); void execute(); String base64Encode(String toEncode);  }
@Test public void qsubScript() throws Exception { String qsubScript = nodeDeployTask.qsubScript("NodeName", "node-config.properties", NUMBER_OF_CPUS); assertThat(qsubScript, containsString("#PBS -l nodes=1:ppn=42")); assertThat(qsubScript, containsString("#PBS -q myqueue")); assertThat(qsubScript, containsString("#PBS -o out/NodeName.out")); assertThat(qsubScript, containsString("#PBS -M test@example.com")); assertThat(qsubScript, containsString("./startNode.sh node-config.properties")); }
@Test public void qsubScript_defaultValues() throws Exception { torqueConfiguration = TorqueConfiguration.buildFromConfig(buildConfig(false)); nodeDeployTask = new NodeDeployTask(torqueNodeDeployment, 10, torqueNodeConfiguration, torqueConfiguration); String qsubScript = nodeDeployTask.qsubScript("NodeName", "node-config.properties", NUMBER_OF_CPUS); assertThat(qsubScript, containsString("#PBS -l nodes=1:ppn=42")); assertThat(qsubScript, containsString("#PBS -q superfast")); assertThat(qsubScript, containsString("#PBS -o out/NodeName.out")); assertThat(qsubScript, containsString("#PBS -M test@example.com")); assertThat(qsubScript, containsString("./startNode.sh node-config.properties")); }