<commit_before>package integration

import (
	"os"

	influxdb "github.com/influxdb/influxdb/client"
	. "github.com/influxdb/influxdb/integration/helpers"
	. "launchpad.net/gocheck"
)

type RemoveNodeSuite struct {
	serverProcesses []*Server
}

var _ = Suite(&RemoveNodeSuite{})

func (self *RemoveNodeSuite) SetUpSuite(c *C) {
}

func (self *RemoveNodeSuite) TearDownSuite(c *C) {
	for _, s := range self.serverProcesses {
		s.Stop()
	}
}

func (self *RemoveNodeSuite) TestRemovingNode(c *C) {
	err := os.RemoveAll("/tmp/influxdb/test")
	c.Assert(err, IsNil)
	s1 := NewServer("integration/test_rf_1.toml", c)
	defer s1.Stop()
	s1.WaitForServerToStart()

	s2 := NewServer("integration/test_rf_2.toml", c)
	s2.WaitForServerToStart()

	client := s1.GetClient("", c)
	servers, err := client.Servers()
	c.Assert(err, IsNil)
	c.Assert(servers, HasLen, 2)

	s2.Stop()

	c.Assert(client.RemoveServer(2), IsNil)

	servers, err = client.Servers()
	c.Assert(err, IsNil)
	c.Assert(servers, HasLen, 1)

	c.Assert(client.CreateDatabase("test"), IsNil)
	series := CreatePoints("test_replication_factor_1", 1, 1)
	client = s1.GetClient("test", c)
	c.Assert(client.WriteSeries(series), IsNil)

	s1.WaitForServerToSync()
}

func (self *RemoveNodeSuite) TestRemovingNodeAndShards(c *C) {
	err := os.RemoveAll("/tmp/influxdb/test")
	c.Assert(err, IsNil)
	s1 := NewServer("integration/test_replication_1.toml", c)
	defer s1.Stop()
	s1.WaitForServerToStart()

	s2 := NewServer("integration/test_replication_2.toml", c)
	s2.WaitForServerToStart()

	client := s1.GetClient("", c)
	servers, err := client.Servers()
	c.Assert(err, IsNil)
	c.Assert(servers, HasLen, 2)

	c.Assert(client.CreateDatabase("test"), IsNil)
	space := &influxdb.ShardSpace{Name: "test_space", RetentionPolicy: "1h", Database: "test", Regex: "/test_removing_node_and_shards/", ReplicationFactor: 2}<commit_msg>Fix the name of the config files in the integration test suite<commit_after>package integration

import (
	"os"

	influxdb "github.com/influxdb/influxdb/client"
	. "github.com/influxdb/influxdb/integration/helpers"
	. "launchpad.net/gocheck"
)

type RemoveNodeSuite struct {
	serverProcesses []*Server
}

var _ = Suite(&RemoveNodeSuite{})

func (self *RemoveNodeSuite) SetUpSuite(c *C) {
}

func (self *RemoveNodeSuite) TearDownSuite(c *C) {
	for _, s := range self.serverProcesses {
		s.Stop()
	}
}

func (self *RemoveNodeSuite) TestRemovingNode(c *C) {
	err := os.RemoveAll("/tmp/influxdb/test")
	c.Assert(err, IsNil)
	s1 := NewServer("integration/test_rf_1.toml", c)
	defer s1.Stop()
	s1.WaitForServerToStart()

	s2 := NewServer("integration/test_rf_2.toml", c)
	s2.WaitForServerToStart()

	client := s1.GetClient("", c)
	servers, err := client.Servers()
	c.Assert(err, IsNil)
	c.Assert(servers, HasLen, 2)

	s2.Stop()

	c.Assert(client.RemoveServer(2), IsNil)

	servers, err = client.Servers()
	c.Assert(err, IsNil)
	c.Assert(servers, HasLen, 1)

	c.Assert(client.CreateDatabase("test"), IsNil)
	series := CreatePoints("test_replication_factor_1", 1, 1)
	client = s1.GetClient("test", c)
	c.Assert(client.WriteSeries(series), IsNil)

	s1.WaitForServerToSync()
}

func (self *RemoveNodeSuite) TestRemovingNodeAndShards(c *C) {
	err := os.RemoveAll("/tmp/influxdb/test")
	c.Assert(err, IsNil)
	s1 := NewServer("integration/test_rf_1.toml", c)
	defer s1.Stop()
	s1.WaitForServerToStart()

	s2 := NewServer("integration/test_rf_2.toml", c)
	s2.WaitForServerToStart()

	client := s1.GetClient("", c)
	servers, err := client.Servers()
	c.Assert(err, IsNil)
	c.Assert(servers, HasLen, 2)

	c.Assert(client.CreateDatabase("test"), IsNil)
	space := &influxdb.ShardSpace{Name: "test_space", RetentionPolicy: "1h", Database: "test", Regex: "/test_removing_node_and_shards/", ReplicationFactor: 2}
{'fraction_non_alphanumeric': 0.15852682145716573, 'fraction_numerical': 0.014945289564985321, 'mean_word_length': 5.484429065743945, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2339515', 'n_tokens_mistral': 1494, 'n_tokens_neox': 1456, 'n_words': 262}