<commit_before>package com.tinkerpop.blueprints.impls.orient;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.junit.*;

import com.orientechnologies.orient.client.remote.OServerAdmin;
import com.orientechnologies.orient.core.Orient;
import com.orientechnologies.orient.server.OServer;
import com.orientechnologies.orient.server.OServerMain;
import com.tinkerpop.blueprints.Vertex;

public class OrientGraphMultithreadRemoteTest {
  private static OServer     server;
  private static String      oldOrientDBHome;

  private static String      serverHome;

  private OrientGraphFactory graphFactory;

  @BeforeClass
  public static void startEmbeddedServer() throws Exception {
    final String buildDirectory = System.getProperty("buildDirectory", ".");
    serverHome = buildDirectory + "/" + OrientGraphMultithreadRemoteTest.class.getSimpleName();

    File file = new File(serverHome);
    deleteDirectory(file);

    file = new File(serverHome);
    Assert.assertTrue(file.mkdir());

    oldOrientDBHome = System.getProperty("ORIENTDB_HOME");
    System.setProperty("ORIENTDB_HOME", serverHome);

    server = OServerMain.create();
    server.startup(OrientGraphMultithreadRemoteTest.class.getResourceAsStream("/embedded-server-config.xml"));
    server.activate();

  }

  @AfterClass
  public static void stopEmbeddedServer() throws Exception {
    server.shutdown();
    Thread.sleep(1000);

    if (oldOrientDBHome != null)
      System.setProperty("ORIENTDB_HOME", oldOrientDBHome);
    else
      System.clearProperty("ORIENTDB_HOME");

    final File file = new File(serverHome);
    deleteDirectory(file);

    Orient.instance().startup();
  }

  @Before
  public void before() {
    final String url = "remote:localhost:3080/" + OrientGraphMultithreadRemoteTest.class.getSimpleName();

    try {
      final OServerAdmin serverAdmin = new OServerAdmin(url);
      serverAdmin.connect("root", "root");
      if (!serverAdmin.existsDatabase(OrientGraphTest.getStorageType()))
        serverAdmin.createDatabase("graph", OrientGraphTest.getStorageType());

      serverAdmin.close();

    } catch (IOException e) {
      throw new IllegalStateException(e);
    }

    graphFactory = new OrientGraphFactory(url);
    graphFactory.setupPool(5, 256);

  }

  @Test
  @Ignore
  public void testThreadingInsert() throws InterruptedException {
    List<Thread> threads = new ArrayList<Thread>();
    int threadCount = 8;<commit_msg>reestored default timeout for remote multihread test overridden by console  test<commit_after>package com.tinkerpop.blueprints.impls.orient;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.junit.*;

import com.orientechnologies.orient.client.remote.OServerAdmin;
import com.orientechnologies.orient.core.Orient;
import com.orientechnologies.orient.core.config.OGlobalConfiguration;
import com.orientechnologies.orient.server.OServer;
import com.orientechnologies.orient.server.OServerMain;
import com.tinkerpop.blueprints.Vertex;

public class OrientGraphMultithreadRemoteTest {
  private static OServer     server;
  private static String      oldOrientDBHome;

  private static String      serverHome;

  private OrientGraphFactory graphFactory;

  @BeforeClass
  public static void startEmbeddedServer() throws Exception {
    OGlobalConfiguration.NETWORK_LOCK_TIMEOUT.setValue(15000);
    final String buildDirectory = System.getProperty("buildDirectory", ".");
    serverHome = buildDirectory + "/" + OrientGraphMultithreadRemoteTest.class.getSimpleName();

    File file = new File(serverHome);
    deleteDirectory(file);

    file = new File(serverHome);
    Assert.assertTrue(file.mkdir());

    oldOrientDBHome = System.getProperty("ORIENTDB_HOME");
    System.setProperty("ORIENTDB_HOME", serverHome);

    server = OServerMain.create();
    server.startup(OrientGraphMultithreadRemoteTest.class.getResourceAsStream("/embedded-server-config.xml"));
    server.activate();

  }

  @AfterClass
  public static void stopEmbeddedServer() throws Exception {
    server.shutdown();
    Thread.sleep(1000);

    if (oldOrientDBHome != null)
      System.setProperty("ORIENTDB_HOME", oldOrientDBHome);
    else
      System.clearProperty("ORIENTDB_HOME");

    final File file = new File(serverHome);
    deleteDirectory(file);

    Orient.instance().startup();
  }

  @Before
  public void before() {
    final String url = "remote:localhost:3080/" + OrientGraphMultithreadRemoteTest.class.getSimpleName();

    try {
      final OServerAdmin serverAdmin = new OServerAdmin(url);
      serverAdmin.connect("root", "root");
      if (!serverAdmin.existsDatabase(OrientGraphTest.getStorageType()))
        serverAdmin.createDatabase("graph", OrientGraphTest.getStorageType());

      serverAdmin.close();

    } catch (IOException e) {
      throw new IllegalStateException(e);
    }

    graphFactory = new OrientGraphFactory(url);
    graphFactory.setupPool(5, 256);

  }

  @Test
//  @Ignore
  public void testThreadingInsert() throws InterruptedException {
    List<Thread> threads = new ArrayList<Thread>();
    int threadCount = 8;
{'fraction_non_alphanumeric': 0.1047271329746349, 'fraction_numerical': 0.00595695618754804, 'mean_word_length': 4.478947368421053, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '835810', 'n_tokens_mistral': 1517, 'n_tokens_neox': 1455, 'n_words': 294}