@@ -35,6 +35,7 @@ import (
3535 "github.com/deepflowio/deepflow/server/querier/config"
3636 "github.com/deepflowio/deepflow/server/querier/engine/clickhouse/client"
3737 "github.com/deepflowio/deepflow/server/querier/engine/clickhouse/metrics"
38+ tagdescription "github.com/deepflowio/deepflow/server/querier/engine/clickhouse/tag"
3839 "github.com/deepflowio/deepflow/server/querier/parse"
3940)
4041
@@ -692,6 +693,54 @@ func TestGetSql(t *testing.T) {
692693 }
693694}
694695
696+ func TestL7ProtocolDatabaseEnumCandidates (t * testing.T ) {
697+ if err := Load (); err != nil {
698+ t .Fatal (err )
699+ }
700+
701+ enums , ok := tagdescription .TAG_INT_ENUMS ["l7_protocol" ]
702+ if ! ok {
703+ t .Fatal ("missing l7_protocol int enum" )
704+ }
705+ got := make (map [int ]struct {
706+ en string
707+ zh string
708+ }, len (enums ))
709+ for _ , item := range enums {
710+ value , ok := item .Value .(int )
711+ if ! ok {
712+ t .Fatalf ("unexpected l7_protocol enum value type %T" , item .Value )
713+ }
714+ got [value ] = struct {
715+ en string
716+ zh string
717+ }{
718+ en : fmt .Sprint (item .DisplayNameEN ),
719+ zh : fmt .Sprint (item .DisplayNameZH ),
720+ }
721+ }
722+
723+ expected := map [int ]struct {
724+ en string
725+ zh string
726+ }{
727+ 60 : {en : "MySQL" , zh : "MySQL" },
728+ 61 : {en : "PostgreSQL" , zh : "PostgreSQL" },
729+ 62 : {en : "Oracle" , zh : "Oracle" },
730+ 63 : {en : "Dameng" , zh : "达梦" },
731+ 64 : {en : "DB2" , zh : "DB2" },
732+ 65 : {en : "TDSQL" , zh : "TDSQL" },
733+ 66 : {en : "OceanBase" , zh : "OceanBase" },
734+ 67 : {en : "GoldenDB" , zh : "GoldenDB" },
735+ 68 : {en : "Kingbase" , zh : "人大金仓" },
736+ }
737+ for value , want := range expected {
738+ if got [value ] != want {
739+ t .Errorf ("l7_protocol enum %d = %+v, want %+v" , value , got [value ], want )
740+ }
741+ }
742+ }
743+
695744/* func TestGetSqltest(t *testing.T) {
696745 for _, pcase := range parsetest {
697746 e := CHEngine{DB: "flow_log"}
0 commit comments