-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
188 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package api | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"strings" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/taosdata/taoskeeper/db" | ||
"github.com/taosdata/taoskeeper/util" | ||
) | ||
|
||
func TestCreateClusterInfoSql(t *testing.T) { | ||
conn, _ := db.NewConnector("root", "taosdata", "127.0.0.1", 6041, false) | ||
defer conn.Close() | ||
|
||
dbName := "db_202412031539" | ||
conn.Exec(context.Background(), "create database "+dbName, util.GetQidOwn()) | ||
defer conn.Exec(context.Background(), "drop database "+dbName, util.GetQidOwn()) | ||
|
||
conn, _ = db.NewConnectorWithDb("root", "taosdata", "127.0.0.1", 6041, dbName, false) | ||
defer conn.Close() | ||
|
||
conn.Exec(context.Background(), CreateClusterInfoSql, util.GetQidOwn()) | ||
|
||
testCases := []struct { | ||
ep string | ||
wantErr bool | ||
}{ | ||
{"", false}, | ||
{"hello", false}, | ||
{strings.Repeat("a", 128), false}, | ||
{strings.Repeat("a", 255), false}, | ||
{strings.Repeat("a", 256), true}, | ||
} | ||
|
||
conn.Exec(context.Background(), | ||
"create table d0 using cluster_info tags('cluster_id')", util.GetQidOwn()) | ||
|
||
for _, tc := range testCases { | ||
sql := fmt.Sprintf("insert into d0 (ts, first_ep) values(%d, '%s')", time.Now().UnixMilli(), tc.ep) | ||
_, err := conn.Exec(context.Background(), sql, util.GetQidOwn()) | ||
if tc.wantErr { | ||
assert.Error(t, err) // [0x2653] Value too long for column/tag: endpoint | ||
} else { | ||
assert.NoError(t, err) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package cmd | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"strings" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/taosdata/taoskeeper/db" | ||
"github.com/taosdata/taoskeeper/infrastructure/config" | ||
"github.com/taosdata/taoskeeper/util" | ||
) | ||
|
||
func TestTransferTaosdClusterBasicInfo(t *testing.T) { | ||
config.InitConfig() | ||
|
||
conn, _ := db.NewConnector("root", "taosdata", "127.0.0.1", 6041, false) | ||
defer conn.Close() | ||
|
||
dbName := "db_202412031539" | ||
conn.Exec(context.Background(), "create database "+dbName, util.GetQidOwn()) | ||
defer conn.Exec(context.Background(), "drop database "+dbName, util.GetQidOwn()) | ||
|
||
conn, _ = db.NewConnectorWithDb("root", "taosdata", "127.0.0.1", 6041, dbName, false) | ||
defer conn.Close() | ||
|
||
cmd := Command{conn: conn, fromTime: time.Now().Add(time.Duration(1 * time.Hour))} | ||
cmd.TransferTaosdClusterBasicInfo() | ||
|
||
testCases := []struct { | ||
ep string | ||
wantErr bool | ||
}{ | ||
{"", false}, | ||
{"hello", false}, | ||
{strings.Repeat("a", 128), false}, | ||
{strings.Repeat("a", 255), false}, | ||
{strings.Repeat("a", 256), true}, | ||
} | ||
|
||
conn.Exec(context.Background(), | ||
"create table d0 using taosd_cluster_basic tags('cluster_id')", util.GetQidOwn()) | ||
|
||
for _, tc := range testCases { | ||
sql := fmt.Sprintf("insert into d0 (ts, first_ep) values(%d, '%s')", time.Now().UnixMilli(), tc.ep) | ||
_, err := conn.Exec(context.Background(), sql, util.GetQidOwn()) | ||
if tc.wantErr { | ||
assert.Error(t, err) // [0x2653] Value too long for column/tag: endpoint | ||
} else { | ||
assert.NoError(t, err) | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters