Ejemplo n.º 1
0
        private void PrepareForSparkTest(ITestCluster testCluster)
        {
            const string replicationConfigStr = "{'class' : 'SimpleStrategy', 'replication_factor' : 2}";

            using (var cluster = Cluster.Builder().AddContactPoint(TestClusterManager.InitialContactPoint).Build())
            {
                WaitForWorkers(1);

                var session = cluster.Connect();

                Trace.TraceInformation("GraphMultiNodeTests: Altering keyspace for dse_leases");
                session.Execute(
                    "ALTER KEYSPACE dse_leases WITH REPLICATION = {'class': 'NetworkTopologyStrategy', 'GraphAnalytics': '2'}");

                Trace.TraceInformation("GraphMultiNodeTests: Bootstrapping node 2");
                testCluster.BootstrapNode(2, false);
                Trace.TraceInformation("GraphMultiNodeTests: Setting workload");
                testCluster.SetNodeWorkloads(2, new[] { "graph", "spark" });
                Trace.TraceInformation("GraphMultiNodeTests: Starting node 2");
                testCluster.Start(2);
                Trace.TraceInformation("Waiting additional time for new node to be ready");
                Thread.Sleep(15000);
                WaitForWorkers(2);

                Trace.TraceInformation("GraphMultiNodeTests: Creating graph");
                session.ExecuteGraph(new SimpleGraphStatement(
                                         "system.graph(name)" +
                                         ".option('graph.replication_config').set(replicationConfig)" +
                                         ".option('graph.system_replication_config').set(replicationConfig)" +
                                         ".ifNotExists()" +
                                         (!TestClusterManager.SupportsNextGenGraph() ? string.Empty : ".engine(Classic)") +
                                         ".create()",
                                         new { name = GraphMultiNodeTests.GraphName, replicationConfig = replicationConfigStr }));
                Trace.TraceInformation("GraphMultiNodeTests: Created graph");

                var graphStatements = new StringBuilder();
                graphStatements.Append(BaseIntegrationTest.MakeStrict + "\n");
                graphStatements.Append(BaseIntegrationTest.AllowScans + "\n");
                graphStatements.Append(BaseIntegrationTest.ClassicSchemaGremlinQuery + "\n");
                graphStatements.Append(BaseIntegrationTest.ClassicLoadGremlinQuery);
                session.ExecuteGraph(new SimpleGraphStatement(graphStatements.ToString()).SetGraphName(GraphMultiNodeTests.GraphName));
            }
        }