Esempio n. 1
0
func (s *TestSuite) TestBinlogFileNumberDistance(c *C) {
	c1 := inst.BinlogCoordinates{LogFile: "mysql-bin.00017", LogPos: 104}
	fileNum, numLen := c1.FileNumber()

	c.Assert(fileNum, Equals, 17)
	c.Assert(numLen, Equals, 5)
}
Esempio n. 2
0
func (s *TestSuite) TestBinlogFileNumber(c *C) {
	c1 := inst.BinlogCoordinates{LogFile: "mysql-bin.00017", LogPos: 104}
	c2 := inst.BinlogCoordinates{LogFile: "mysql-bin.00022", LogPos: 104}

	c.Assert(c1.FileNumberDistance(&c1), Equals, 0)
	c.Assert(c1.FileNumberDistance(&c2), Equals, 5)
	c.Assert(c2.FileNumberDistance(&c1), Equals, -5)
}
Esempio n. 3
0
func (s *TestSuite) TestBinlogPrevious(c *C) {
	c1 := inst.BinlogCoordinates{LogFile: "mysql-bin.00017", LogPos: 104}
	cres, err := c1.PreviousFileCoordinates()

	c.Assert(err, IsNil)
	c.Assert(c1.Type, Equals, cres.Type)
	c.Assert(cres.LogFile, Equals, "mysql-bin.00016")

	c2 := inst.BinlogCoordinates{LogFile: "mysql-bin.00100", LogPos: 104}
	cres, err = c2.PreviousFileCoordinates()

	c.Assert(err, IsNil)
	c.Assert(c1.Type, Equals, cres.Type)
	c.Assert(cres.LogFile, Equals, "mysql-bin.00099")

	c3 := inst.BinlogCoordinates{LogFile: "mysql.00.prod.com.00100", LogPos: 104}
	cres, err = c3.PreviousFileCoordinates()

	c.Assert(err, IsNil)
	c.Assert(c1.Type, Equals, cres.Type)
	c.Assert(cres.LogFile, Equals, "mysql.00.prod.com.00099")

	c4 := inst.BinlogCoordinates{LogFile: "mysql.00.prod.com.00000", LogPos: 104}
	_, err = c4.PreviousFileCoordinates()

	c.Assert(err, Not(IsNil))
}
Esempio n. 4
0
func (s *TestSuite) TestBinlogCoordinates(c *C) {
	c1 := inst.BinlogCoordinates{LogFile: "mysql-bin.00017", LogPos: 104}
	c2 := inst.BinlogCoordinates{LogFile: "mysql-bin.00017", LogPos: 104}
	c3 := inst.BinlogCoordinates{LogFile: "mysql-bin.00017", LogPos: 5000}
	c4 := inst.BinlogCoordinates{LogFile: "mysql-bin.00112", LogPos: 104}

	c.Assert(c1.Equals(&c2), Equals, true)
	c.Assert(c1.Equals(&c3), Equals, false)
	c.Assert(c1.Equals(&c4), Equals, false)
	c.Assert(c1.SmallerThan(&c2), Equals, false)
	c.Assert(c1.SmallerThan(&c3), Equals, true)
	c.Assert(c1.SmallerThan(&c4), Equals, true)
	c.Assert(c3.SmallerThan(&c4), Equals, true)
	c.Assert(c3.SmallerThan(&c2), Equals, false)
	c.Assert(c4.SmallerThan(&c2), Equals, false)
	c.Assert(c4.SmallerThan(&c3), Equals, false)
}