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(timeout = 120_000) public void shouldBeAbleToStartAndStopWithoutSuccessfulJoin() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBeAbleToStartAndStopWithoutSuccessfulJoin()
        {
            // Random members that does not exists, discovery will never succeed
            string initialHosts = "localhost:" + PortAuthority.allocatePort() + ",localhost:" + PortAuthority.allocatePort();
            Config config       = Config.defaults();

            config.augment(initial_discovery_members, initialHosts);
            config.Augment(CausalClusteringSettings.discovery_listen_address, "localhost:" + PortAuthority.allocatePort());

            JobScheduler jobScheduler = createInitialisedScheduler();
            InitialDiscoveryMembersResolver initialDiscoveryMemberResolver = new InitialDiscoveryMembersResolver(new NoOpHostnameResolver(), config);

            CoreTopologyService service = _discoveryServiceType.createFactory().coreTopologyService(config, new MemberId(System.Guid.randomUUID()), jobScheduler, NullLogProvider.Instance, NullLogProvider.Instance, initialDiscoveryMemberResolver, new TopologyServiceNoRetriesStrategy(), new Monitors());

            service.init();
            service.start();
            service.stop();
            service.shutdown();
        }
Exemple #3
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 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void oldIncompatibleBackupsThrows() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void OldIncompatibleBackupsThrows()
        {
            // Prepare an "old" backup
            PrepareNeoStoreFile(StandardV2_3.STORE_VERSION);

            // Start database to backup
            int backupPort          = PortAuthority.allocatePort();
            GraphDatabaseService db = StartGraphDatabase(backupPort);

            try
            {
                Expected.expect(typeof(BackupTool.ToolFailureException));
                Expected.expectMessage("Failed to perform backup because existing backup is from a different version.");

                // Perform backup
                _backupTool.executeBackup(new HostnamePort("localhost", backupPort), _backupDir, ConsistencyCheck.NONE, Config.defaults(GraphDatabaseSettings.record_format, StandardV3_4.NAME), 20L * 60L * 1000L, false);
            }
            finally
            {
                Db.shutdown();
            }
        }
Exemple #5
0
        private void ShouldGatherForensicsInFullBackupRequest(bool forensics)
        {
            // GIVEN
            Response <Void> response = Response.empty();
            StoreId         storeId  = response.StoreId;
            string          host     = "localhost";
            int             port     = PortAuthority.allocatePort();
            LifeSupport     life     = new LifeSupport();

            LogEntryReader <ReadableClosablePositionAwareChannel> reader = new VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel>();
            NullLogProvider    logProvider        = NullLogProvider.Instance;
            ResponseUnpacker   responseUnpacker   = mock(typeof(ResponseUnpacker));
            ByteCounterMonitor byteCounterMonitor = mock(typeof(ByteCounterMonitor));
            RequestMonitor     requestMonitor     = mock(typeof(RequestMonitor));
            BackupClient       client             = new BackupClient(host, port, null, logProvider, storeId, 10_000, responseUnpacker, byteCounterMonitor, requestMonitor, reader);

            life.Add(client);
            ControlledBackupInterface backup = new ControlledBackupInterface();
            HostnamePort hostnamePort        = new HostnamePort(host, port);

            life.Add(new BackupServer(backup, hostnamePort, logProvider, byteCounterMonitor, requestMonitor));
            life.Start();

            try
            {
                // WHEN
                StoreWriter writer = mock(typeof(StoreWriter));
                client.FullBackup(writer, forensics);

                // THEN
                assertEquals(forensics, backup.ReceivedForensics);
            }
            finally
            {
                life.Shutdown();
            }
        }
Exemple #6
0
 internal TestCatchupServer(FileSystemAbstraction fileSystem, GraphDatabaseAPI graphDb) : base(ChildInitializer(fileSystem, graphDb), _logProvider, _logProvider, new ListenSocketAddress("localhost", PortAuthority.allocatePort()), "fake-catchup-server")
 {
 }
Exemple #7
0
 private static Server CreateServer()
 {
     return(new Server(_channel =>
     {
     }, FormattedLogProvider.withDefaultLogLevel(Level.DEBUG).toOutputStream(System.out), FormattedLogProvider.withDefaultLogLevel(Level.DEBUG).toOutputStream(System.out), new ListenSocketAddress("localhost", PortAuthority.allocatePort()), "serverName"));
 }