<commit_before>/*
 * Copyright 2012 The Clustermeister Team.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.github.nethad.clustermeister.provisioning.ec2;

import com.github.nethad.clustermeister.api.impl.FileConfiguration;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.domain.LoginCredentials;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author daniel
 */
@Ignore("Depends on local configuration.")
public class AmazonEC2JPPFDeployerTest {
	static final String AMAZON_SETTINGS = "/home/daniel/clustermeister-amazonapi.properties";
	static final String driverNodeID = "eu-west-1/i-28b4f361";
	static final String nodeNodeID = "eu-west-1/i-14c98e5d";
	static final String privateKeyFile = "/home/daniel/Desktop/EC2/EC2_keypair.pem";
	static final String userName = "ec2-user";
	
	static AmazonInstanceManager nodeManager;
	static AmazonEC2JPPFDriverDeployer driverDeployer;
	static AmazonEC2JPPFNodeDeployer nodeDeployer1;
	static AmazonEC2JPPFNodeDeployer nodeDeployer2;
	static NodeMetadata metadata;
	static LoginCredentials loginCredentials;
	
	private final static Logger logger = 
			LoggerFactory.getLogger(AmazonEC2JPPFDeployerTest.class);
	
	@BeforeClass
	public static void setUpClass() throws Exception {
		FileConfiguration config = 
				new FileConfiguration(AMAZON_SETTINGS);
		nodeManager = new AmazonInstanceManager(config);
		nodeManager.init();
		logger.info("Resuming node {}", driverNodeID);
		metadata = nodeManager.resumeNode(driverNodeID);
		logger.info("Node {} resumed at {}", driverNodeID, 
				metadata.getPublicAddresses().iterator().next());
		
		loginCredentials = new LoginCredentials(userName, null, getPrivateKey(), true);
		
		driverDeployer = new AmazonEC2JPPFDriverDeployer(nodeManager.getContext(), 
				metadata, loginCredentials);
		String driverPublicIP = metadata.getPublicAddresses().iterator().next();
		String driverPrivateIP = metadata.getPrivateAddresses().iterator().next();
		
		nodeDeployer1 = new AmazonEC2JPPFNodeDeployer(nodeManager.getContext(), 
				metadata, loginCredentials, driverPrivateIP);
		
		logger.info("Resuming node {}", nodeNodeID);
		metadata = nodeManager.resumeNode(nodeNodeID);
		logger.info("Node {} resumed at {}", nodeNodeID, 
				metadata.getPublicAddresses().iterator().next());
		nodeDeployer2 = new AmazonEC2JPPFNodeDeployer(nodeManager.getContext(), 
				metadata, loginCredentials, driverPublicIP);
		
	}

	

	@AfterClass
	public static void tearDownClass() throws Exception {
//		nodeManager.suspendNode(nodeNodeID);
//		nodeManager.suspendNode(driverNodeID);
		nodeManager.close();
	}
	
	@Test
	public void testSomeMethod() {
		driverDeployer.run();
		logger.info("Driver running");
		nodeDeployer1.run();
		logger.info("Node1 running");<commit_msg>renamed variable from nodeManager to instanceManager<commit_after>/*
 * Copyright 2012 The Clustermeister Team.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.github.nethad.clustermeister.provisioning.ec2;

import com.github.nethad.clustermeister.api.impl.FileConfiguration;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.domain.LoginCredentials;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author daniel
 */
@Ignore("Depends on local configuration.")
public class AmazonEC2JPPFDeployerTest {
	static final String AMAZON_SETTINGS = "/home/daniel/clustermeister-amazonapi.properties";
	static final String driverNodeID = "eu-west-1/i-28b4f361";
	static final String nodeNodeID = "eu-west-1/i-14c98e5d";
	static final String privateKeyFile = "/home/daniel/Desktop/EC2/EC2_keypair.pem";
	static final String userName = "ec2-user";
	
	static AmazonInstanceManager instanceManager;
	static AmazonEC2JPPFDriverDeployer driverDeployer;
	static AmazonEC2JPPFNodeDeployer nodeDeployer1;
	static AmazonEC2JPPFNodeDeployer nodeDeployer2;
	static NodeMetadata metadata;
	static LoginCredentials loginCredentials;
	
	private final static Logger logger = 
			LoggerFactory.getLogger(AmazonEC2JPPFDeployerTest.class);
	
	@BeforeClass
	public static void setUpClass() throws Exception {
		FileConfiguration config = 
				new FileConfiguration(AMAZON_SETTINGS);
		instanceManager = new AmazonInstanceManager(config);
		instanceManager.init();
		logger.info("Resuming node {}", driverNodeID);
		metadata = instanceManager.resumeNode(driverNodeID);
		logger.info("Node {} resumed at {}", driverNodeID, 
				metadata.getPublicAddresses().iterator().next());
		
		loginCredentials = new LoginCredentials(userName, null, getPrivateKey(), true);
		
		driverDeployer = new AmazonEC2JPPFDriverDeployer(instanceManager.getContext(), 
				metadata, loginCredentials);
		String driverPublicIP = metadata.getPublicAddresses().iterator().next();
		String driverPrivateIP = metadata.getPrivateAddresses().iterator().next();
		
		nodeDeployer1 = new AmazonEC2JPPFNodeDeployer(instanceManager.getContext(), 
				metadata, loginCredentials, driverPrivateIP);
		
		logger.info("Resuming node {}", nodeNodeID);
		metadata = instanceManager.resumeNode(nodeNodeID);
		logger.info("Node {} resumed at {}", nodeNodeID, 
				metadata.getPublicAddresses().iterator().next());
		nodeDeployer2 = new AmazonEC2JPPFNodeDeployer(instanceManager.getContext(), 
				metadata, loginCredentials, driverPublicIP);
		
	}

	

	@AfterClass
	public static void tearDownClass() throws Exception {
//		nodeManager.suspendNode(nodeNodeID);
//		nodeManager.suspendNode(driverNodeID);
		instanceManager.close();
	}
	
	@Test
	public void testSomeMethod() {
		driverDeployer.run();
		logger.info("Driver running");
		nodeDeployer1.run();
		logger.info("Node1 running");
{'fraction_non_alphanumeric': 0.09965010496850944, 'fraction_numerical': 0.011476557032890133, 'mean_word_length': 5.357651245551601, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4640564', 'n_tokens_mistral': 2233, 'n_tokens_neox': 2120, 'n_words': 512}