Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:Add baremetal cluster e2e test #206

Closed
wants to merge 110 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
c84c1af
Merge pull request #1 from GreptimeTeam/develop
confoc May 23, 2024
85002b5
Merge branch 'GreptimeTeam:develop' into develop
confoc May 28, 2024
71081cc
ifx
Jun 12, 2024
0e0f9b9
fix2
Jun 13, 2024
693a722
fix2
Jun 14, 2024
7f9be86
fix3
Jun 14, 2024
eacc7bc
fix3
Jun 14, 2024
d6ade88
fix4
Jun 14, 2024
3b2ed05
fix4
Jun 14, 2024
c43ef9c
fix5
Jun 17, 2024
ab3a329
fix6
Jun 17, 2024
bb5e7a0
fix7
Jun 17, 2024
41a46d4
fix8
Jun 17, 2024
79e2c10
fix9
Jun 18, 2024
f45e9d6
fix9
Jun 18, 2024
6c240c4
fix10
Jun 21, 2024
6ad8083
fix10
Jun 21, 2024
0c2990c
fix11
Jun 21, 2024
a0beacb
fix11
Jun 21, 2024
dcf2ec6
fix11
Jun 21, 2024
a5d4d42
fix11
Jun 21, 2024
b0232ae
fix11
Jun 21, 2024
30f595e
fix11
Jun 21, 2024
c94f907
fix11
Jun 21, 2024
1b02bbe
fix11
Jun 21, 2024
219fb5b
fix11
Jun 21, 2024
6206249
fix11
Jun 24, 2024
e4fb8a6
fix11
Jun 24, 2024
7208120
fix11
Jun 24, 2024
8f857a5
fix11
Jun 24, 2024
fdf91cf
fix11
Jun 24, 2024
7e9282d
fix11
Jun 24, 2024
367747c
fix11
Jun 24, 2024
d1319ab
fix11
Jun 24, 2024
dc9dca7
fix11
Jun 24, 2024
83f8b0c
fix11
Jun 24, 2024
be56c09
fix11
Jun 24, 2024
5d4163d
fix11
Jun 24, 2024
1983aa6
fix11
Jun 24, 2024
4e897b6
fix11
Jun 24, 2024
87ea15b
fix11
Jun 24, 2024
0615d55
fix11
Jun 24, 2024
5395aed
fix11
Jun 24, 2024
5dba756
fix11
Jun 24, 2024
15e7a2d
fix11
Jun 24, 2024
36e834b
fix11
Jun 24, 2024
3868fde
fix11
Jun 24, 2024
ca70fd6
fix11
Jun 24, 2024
71befb3
fix11
Jun 24, 2024
1d54fef
fix12
Jun 24, 2024
98638d7
fix13
Jun 25, 2024
1d3d4c2
fix13
Jun 25, 2024
7429d48
fix
Jun 25, 2024
f6dc85d
fix
Jun 25, 2024
d856ccf
fix
Jun 25, 2024
21d1c8e
fix
Jun 25, 2024
2ee7b5a
fix
Jun 25, 2024
fb4a186
fix
Jun 25, 2024
3780228
fix
Jun 25, 2024
f4fb200
fix
Jun 25, 2024
d5dd305
fix
Jun 25, 2024
2476fab
fix
Jun 25, 2024
c1fcddc
fix
Jun 25, 2024
d078660
fix
Jun 25, 2024
f7ba7e9
fix
Jun 25, 2024
8706ef8
fix
Jun 25, 2024
d73bdab
fix
Jun 25, 2024
deb5dc7
fix
Jun 25, 2024
656891b
fix
Jun 25, 2024
fd4ffb8
fix
Jun 25, 2024
5a54f7d
fix
Jun 25, 2024
d6a5ee3
fix
Jun 26, 2024
468ab6a
fix
Jun 26, 2024
2f16d46
fix
Jun 26, 2024
5f37a4b
fix
Jun 26, 2024
ede1032
fix
Jun 26, 2024
8c3495a
fix
Jun 28, 2024
7301c86
fix
Jun 28, 2024
b279748
fix
Jun 28, 2024
21751b4
fix
Jun 28, 2024
308a24c
fix
Jun 28, 2024
e5b6383
fix
Jun 28, 2024
5bc5328
fix
Jun 28, 2024
61b60ea
fix
Jun 28, 2024
6bc0b94
fix
Jun 28, 2024
6d9497c
fix
Jul 1, 2024
a482888
fix
Jul 1, 2024
28379a4
fix
Jul 1, 2024
f5d417e
fix
Jul 1, 2024
2879eb8
closeport
Jul 1, 2024
a9357c0
changeport
Jul 1, 2024
9dab097
changeport
Jul 1, 2024
0245666
test
Jul 1, 2024
d2ef0e1
test
Jul 1, 2024
95be0d7
test
Jul 1, 2024
c4a1b1b
test
Jul 1, 2024
0f6b624
test
Jul 1, 2024
63f9f69
foeward
Jul 2, 2024
ab43e0b
baremetalport
Jul 2, 2024
d9e58a7
baremetalport
Jul 2, 2024
2813881
mysqladress
Jul 2, 2024
a994084
sql
Jul 5, 2024
a7eca4b
sql
Jul 5, 2024
a60de7e
fix
Jul 5, 2024
dc4c406
fix
Jul 5, 2024
5a56011
fix
Jul 5, 2024
d4f0dd5
fix
Jul 5, 2024
a4f2fc0
close
Jul 5, 2024
33f15b5
sql
Jul 9, 2024
3ab89fb
sql
Jul 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/cluster/baremetal/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (c *Cluster) Create(ctx context.Context, options *opt.CreateOptions) error
return nil
}

if c.useMemoryMeta {
if !c.useMemoryMeta {
if err := withSpinner("Etcd Cluster", c.createEtcdCluster); err != nil {
return err
}
Expand Down
105 changes: 105 additions & 0 deletions tests/e2e/greptimedbcluster_baremetal_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* Copyright 2023 Greptime Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package e2e

import (
"fmt"
"io"
"net"
"os"
"os/exec"
"time"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

var _ = Describe("Basic test of greptimedb cluster in baremetal", Ordered, func() {
It("Bootstrap cluster in baremteal", func() {
var err error
createcmd := newCreateClusterinBaremetalCommand()

err = createcmd.Start()
Expect(err).NotTo(HaveOccurred(), "failed to create cluster in baremetal")

for {
if conn, err := net.DialTimeout("tcp", "localhost:4000", 2*time.Second); err == nil {
defer conn.Close()
break
}
}

err = getClusterinBaremetal()
Expect(err).NotTo(HaveOccurred(), "failed to get cluster in baremetal")

logFile, err := os.Open("/home/runner/.gtctl/mycluster/logs/frontend.0/log")
if err != nil {
fmt.Printf("Failed to open log file: %v\n", err)
return
}
defer logFile.Close()

// 将文件内容拷贝到标准输出
if _, err := io.Copy(os.Stdout, logFile); err != nil {
fmt.Printf("Failed to copy log file content to stdout: %v\n", err)
}

err = createcmd.Process.Kill()
Expect(err).NotTo(HaveOccurred(), "failed to kill create cluster process")

err = createcmd.Wait()
if err != nil {
if _, ok := err.(*exec.ExitError); ok {
fmt.Printf("the process is terminated\n")
} else {
fmt.Printf("process terminated with error: %v,failed to terminated the process\n", err)
}
} else {
fmt.Printf("failed to terminated the process\n")
}

err = deleteClusterinBaremetal()
Expect(err).NotTo(HaveOccurred(), "failed to delete cluster in baremetal")
})
})

func newCreateClusterinBaremetalCommand() exec.Cmd {
cmd := exec.Command("../../bin/gtctl", "cluster", "create", "mycluster", "--bare-metal")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return *cmd
}

func getClusterinBaremetal() error {
cmd := exec.Command("../../bin/gtctl", "cluster", "get", "mycluster", "--bare-metal")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
return err
}
return nil
}

func deleteClusterinBaremetal() error {
cmd := exec.Command("../../bin/gtctl", "cluster", "delete", "mycluster", "--tear-down-etcd", "--bare-metal")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
return err
}
return nil
}
32 changes: 17 additions & 15 deletions tests/e2e/greptimedbcluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,25 @@ import (
"os/exec"
"time"

"github.com/go-sql-driver/mysql"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/go-sql-driver/mysql"
"k8s.io/klog/v2"
)

const (
createTableSQL = `CREATE TABLE dist_table (
ts TIMESTAMP DEFAULT current_timestamp(),
n INT,
row_id INT,
TIME INDEX (ts),
PRIMARY KEY(n)
)
PARTITION ON COLUMNS (n) (
n < 5,
n >= 5 AND n < 9,
n >= 9
)`
ts TIMESTAMP DEFAULT current_timestamp(),
n INT,
row_id INT,
TIME INDEX (ts),
PRIMARY KEY(n)
)
PARTITION ON COLUMNS (n) (
n < 5,
n >= 5 AND n < 9,
n >= 9
)`

insertDataSQLStr = "INSERT INTO dist_table(n, row_id) VALUES (%d, %d)"

Expand All @@ -57,13 +56,14 @@ var (
)

// TestData is the schema of test data in SQL table.

type TestData struct {
timestamp string
n int32
rowID int32
}

var _ = Describe("Basic test of greptimedb cluster", func() {
var _ = Describe("Basic test of greptimedb cluster", Ordered, func() {
It("Bootstrap cluster", func() {
var err error
err = createCluster()
Expand Down Expand Up @@ -102,7 +102,6 @@ var _ = Describe("Basic test of greptimedb cluster", func() {
if err != nil {
return err
}

return nil
}, 30*time.Second, time.Second).ShouldNot(HaveOccurred())

Expand Down Expand Up @@ -136,6 +135,9 @@ var _ = Describe("Basic test of greptimedb cluster", func() {
}
Expect(len(data) == testRowIDNum).Should(BeTrue(), "get the wrong data from db")

err = conn.Close()
Expect(err).NotTo(HaveOccurred(), "failed to close SQL connection")

err = deleteCluster()
Expect(err).NotTo(HaveOccurred(), "failed to delete cluster")
})
Expand Down
Loading