Exemple #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeAbleToStartInHAMode() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBeAbleToStartInHAMode()
        {
            // Given
            int       clusterPort = PortAuthority.allocatePort();
            NeoServer server      = EnterpriseServerBuilder.serverOnRandomPorts().usingDataDir(Folder.Root.AbsolutePath).withProperty(mode.name(), "HA").withProperty(server_id.name(), "1").withProperty(cluster_server.name(), ":" + clusterPort).withProperty(initial_hosts.name(), ":" + clusterPort).persistent().build();

            try
            {
                server.Start();
                server.Database;

                assertThat(server.Database.Graph, @is(instanceOf(typeof(HighlyAvailableGraphDatabase))));

                HTTP.Response haEndpoint = HTTP.GET(GetHaEndpoint(server));
                assertEquals(200, haEndpoint.Status());
                assertThat(haEndpoint.RawContent(), containsString("master"));

                HTTP.Response discovery = HTTP.GET(server.BaseUri().toASCIIString());
                assertEquals(200, discovery.Status());
            }
            finally
            {
                server.Stop();
            }
        }
Exemple #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldShowServerMetrics() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldShowServerMetrics()
        {
            // Given
            File      metrics = Folder.file("metrics");
            NeoServer server  = EnterpriseServerBuilder.serverOnRandomPorts().usingDataDir(Folder.databaseDir().AbsolutePath).withProperty(MetricsSettings.metricsEnabled.name(), "true").withProperty(MetricsSettings.csvEnabled.name(), "true").withProperty(MetricsSettings.csvPath.name(), metrics.Path).withProperty(MetricsSettings.csvInterval.name(), "100ms").persistent().build();

            try
            {
                // when
                server.Start();

                string host = "http://localhost:" + server.BaseUri().Port + ServerSettings.rest_api_path.DefaultValue + "/transaction/commit";

                for (int i = 0; i < 5; i++)
                {
                    ClientResponse r = Client.create().resource(host).accept(APPLICATION_JSON).type(APPLICATION_JSON).post(typeof(ClientResponse), "{ 'statements': [ { 'statement': 'CREATE ()' } ] }");
                    assertEquals(200, r.Status);
                }

                // then
                AssertMetricsExists(metrics, ServerMetrics.THREAD_JETTY_ALL);
                AssertMetricsExists(metrics, ServerMetrics.THREAD_JETTY_IDLE);
            }
            finally
            {
                server.Stop();
            }
        }
Exemple #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeAbleToRestartServer() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBeAbleToRestartServer()
        {
            // Given
            string dataDirectory1 = _baseDir.directory("data1").AbsolutePath;
            string dataDirectory2 = _baseDir.directory("data2").AbsolutePath;

            Config config = Config.fromFile(EnterpriseServerBuilder.serverOnRandomPorts().withDefaultDatabaseTuning().usingDataDir(dataDirectory1).createConfigFiles()).withHome(_baseDir.directory()).withSetting(GraphDatabaseSettings.logs_directory, _baseDir.directory("logs").Path).build();

            // When
            NeoServer server = _cleanup.add(new OpenEnterpriseNeoServer(config, GraphDbDependencies()));

            server.Start();

            assertNotNull(server.Database.Graph);
            assertEquals(config.Get(GraphDatabaseSettings.database_path).AbsolutePath, server.Database.Location.AbsolutePath);

            // Change the database location
            config.Augment(GraphDatabaseSettings.data_directory, dataDirectory2);
            ServerManagement bean = new ServerManagement(server);

            bean.RestartServer();

            // Then
            assertNotNull(server.Database.Graph);
            assertEquals(config.Get(GraphDatabaseSettings.database_path).AbsolutePath, server.Database.Location.AbsolutePath);
        }
Exemple #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @BeforeClass public static void setupServer() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public static void SetupServer()
        {
            Server = EnterpriseServerBuilder.serverOnRandomPorts().usingDataDir(StaticFolder.Root.AbsolutePath).build();

            suppressAll().call((Callable <Void>)() =>
            {
                Server.start();
                return(null);
            });
            FunctionalTestHelper = new FunctionalTestHelper(Server);
        }
Exemple #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static org.neo4j.server.enterprise.OpenEnterpriseNeoServer createServer(java.io.File databaseDir, boolean persistent) throws java.io.IOException
        private static OpenEnterpriseNeoServer CreateServer(File databaseDir, bool persistent)
        {
            EnterpriseServerBuilder builder = EnterpriseServerBuilder.serverOnRandomPorts().usingDataDir(databaseDir.AbsolutePath);

            if (persistent)
            {
                builder = ( EnterpriseServerBuilder )builder.Persistent();
            }
            builder.WithDefaultDatabaseTuning();
            OpenEnterpriseNeoServer server = builder.Build();

            server.Start();
            return(server);
        }
Exemple #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRequireAuthorizationForHAStatusEndpoints() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldRequireAuthorizationForHAStatusEndpoints()
        {
            // Given
            int       clusterPort = PortAuthority.allocatePort();
            NeoServer server      = EnterpriseServerBuilder.serverOnRandomPorts().withProperty(GraphDatabaseSettings.auth_enabled.name(), "true").usingDataDir(Folder.Root.AbsolutePath).withProperty(mode.name(), "HA").withProperty(server_id.name(), "1").withProperty(cluster_server.name(), ":" + clusterPort).withProperty(initial_hosts.name(), ":" + clusterPort).persistent().build();

            try
            {
                server.Start();
                server.Database;

                assertThat(server.Database.Graph, @is(instanceOf(typeof(HighlyAvailableGraphDatabase))));

                Client         client = Client.create();
                ClientResponse r      = client.resource(GetHaEndpoint(server)).accept(APPLICATION_JSON).get(typeof(ClientResponse));
                assertEquals(401, r.Status);
            }
            finally
            {
                server.Stop();
            }
        }
Exemple #7
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: protected org.neo4j.server.NeoServer getNeoServer(String customPageSwapperName) throws java.io.IOException
        protected internal override NeoServer GetNeoServer(string customPageSwapperName)
        {
            CommunityServerBuilder builder = EnterpriseServerBuilder.serverOnRandomPorts().withProperty(GraphDatabaseSettings.pagecache_swapper.name(), customPageSwapperName);

            return(builder.Build());
        }