Skip to content

Commit

Permalink
PMM-11670 Set the cluster label if empty (#2459)
Browse files Browse the repository at this point in the history
* PMM-11670 make sure cluster label is not empty

* PMM-11670 fix tests in managed/models

* PMM-11670 fix inventory tests

* PMM-11670 fix tests in managed/qan

* PMM-11670 fix tests in managed/services/victoriametrics

* PMM-11670 fix API tests

* PMM-11670 update API tests

* PMM-11670 remove the deprecated parameter

* PMM-11670 beautify the debug print

---------

Co-authored-by: Matej Kubinec <matej.kubinec@3pillarglobal.com>
  • Loading branch information
Alex Tymchuk and matejkubinec committed Sep 16, 2023
1 parent f2b8b95 commit fe495cc
Show file tree
Hide file tree
Showing 15 changed files with 104 additions and 24 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/managed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,6 @@ jobs:
- name: Run debug commands on failure
if: ${{ failure() }}
run: |
env
go version
go env
pwd
env | sort
go env | sort
git status
kubectl version --output json
1 change: 1 addition & 0 deletions api-tests/inventory/nodes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ func TestRemoveNode(t *testing.T) {
Address: "localhost",
Port: 3306,
ServiceName: serviceName,
Cluster: serviceName,
},
},
}, listAgentsOK.Payload)
Expand Down
12 changes: 12 additions & 0 deletions api-tests/inventory/services_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ func TestMySQLService(t *testing.T) {
Address: "localhost",
Port: 3306,
ServiceName: serviceName,
Cluster: serviceName,
},
},
}, res)
Expand All @@ -372,6 +373,7 @@ func TestMySQLService(t *testing.T) {
Address: "localhost",
Port: 3306,
ServiceName: serviceName,
Cluster: serviceName,
},
},
}, serviceRes)
Expand Down Expand Up @@ -553,6 +555,7 @@ func TestMongoDBService(t *testing.T) {
ServiceID: serviceID,
NodeID: genericNodeID,
ServiceName: serviceName,
Cluster: serviceName,
Address: "localhost",
Port: 27017,
},
Expand All @@ -573,6 +576,7 @@ func TestMongoDBService(t *testing.T) {
ServiceID: serviceID,
NodeID: genericNodeID,
ServiceName: serviceName,
Cluster: serviceName,
Address: "localhost",
Port: 27017,
},
Expand Down Expand Up @@ -729,6 +733,7 @@ func TestMongoDBService(t *testing.T) {
ServiceID: serviceID,
NodeID: genericNodeID,
ServiceName: serviceName,
Cluster: serviceName,
Socket: "/tmp/mongodb-27017.sock",
},
},
Expand Down Expand Up @@ -770,6 +775,7 @@ func TestPostgreSQLService(t *testing.T) {
DatabaseName: defaultPostgresDBName,
Port: 5432,
ServiceName: serviceName,
Cluster: serviceName,
},
},
}, res)
Expand All @@ -791,6 +797,7 @@ func TestPostgreSQLService(t *testing.T) {
DatabaseName: defaultPostgresDBName,
Port: 5432,
ServiceName: serviceName,
Cluster: serviceName,
},
},
}, serviceRes)
Expand Down Expand Up @@ -973,6 +980,7 @@ func TestProxySQLService(t *testing.T) {
Address: "localhost",
Port: 5432,
ServiceName: serviceName,
Cluster: serviceName,
},
},
}, res)
Expand All @@ -993,6 +1001,7 @@ func TestProxySQLService(t *testing.T) {
Address: "localhost",
Port: 5432,
ServiceName: serviceName,
Cluster: serviceName,
},
},
}, serviceRes)
Expand Down Expand Up @@ -1184,6 +1193,7 @@ func TestExternalService(t *testing.T) {
ServiceID: serviceID,
NodeID: genericNodeID,
ServiceName: serviceName,
Cluster: serviceName,
Group: "redis",
},
},
Expand All @@ -1203,6 +1213,7 @@ func TestExternalService(t *testing.T) {
ServiceID: serviceID,
NodeID: genericNodeID,
ServiceName: serviceName,
Cluster: serviceName,
Group: "redis",
},
},
Expand Down Expand Up @@ -1334,6 +1345,7 @@ func TestExternalService(t *testing.T) {
ServiceID: serviceID,
NodeID: genericNodeID,
ServiceName: serviceName,
Cluster: serviceName,
Group: "external",
},
},
Expand Down
2 changes: 2 additions & 0 deletions api-tests/management/external_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func TestAddExternal(t *testing.T) {
ServiceID: serviceID,
NodeID: nodeID,
ServiceName: serviceName,
Cluster: serviceName,
Group: "external",
},
}, *serviceOK.Payload)
Expand Down Expand Up @@ -225,6 +226,7 @@ func TestAddExternal(t *testing.T) {
ServiceID: serviceID,
NodeID: nodeID,
ServiceName: serviceName,
Cluster: serviceName,
Group: "external",
},
}, *serviceOK.Payload)
Expand Down
2 changes: 2 additions & 0 deletions api-tests/management/haproxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func TestAddHAProxy(t *testing.T) {
ServiceID: serviceID,
NodeID: nodeID,
ServiceName: serviceName,
Cluster: serviceName,
},
}, *serviceOK.Payload)

Expand Down Expand Up @@ -225,6 +226,7 @@ func TestAddHAProxy(t *testing.T) {
ServiceID: serviceID,
NodeID: nodeID,
ServiceName: serviceName,
Cluster: serviceName,
},
}, *serviceOK.Payload)

Expand Down
7 changes: 7 additions & 0 deletions api-tests/management/mongodb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func TestAddMongoDB(t *testing.T) {
ServiceID: serviceID,
NodeID: nodeID,
ServiceName: serviceName,
Cluster: serviceName,
Address: "10.10.10.10",
Port: 27017,
},
Expand Down Expand Up @@ -154,6 +155,7 @@ func TestAddMongoDB(t *testing.T) {
ServiceID: serviceID,
NodeID: nodeID,
ServiceName: serviceName,
Cluster: serviceName,
Address: "10.10.10.10",
Port: 27017,
},
Expand Down Expand Up @@ -389,6 +391,7 @@ func TestAddMongoDB(t *testing.T) {
ServiceID: serviceID,
NodeID: newNodeID,
ServiceName: serviceName,
Cluster: serviceName,
Address: "10.10.10.10",
Port: 27017,
},
Expand Down Expand Up @@ -607,6 +610,7 @@ func TestAddMongoDB(t *testing.T) {
ServiceID: serviceID,
NodeID: nodeID,
ServiceName: serviceName,
Cluster: serviceName,
Socket: "/tmp/mongodb-27017.sock",
},
}, *serviceOK.Payload)
Expand Down Expand Up @@ -678,6 +682,7 @@ func TestAddMongoDB(t *testing.T) {
ServiceID: serviceID,
NodeID: nodeID,
ServiceName: serviceName,
Cluster: serviceName,
Address: "10.10.10.10",
Port: 27017,
},
Expand Down Expand Up @@ -750,6 +755,7 @@ func TestAddMongoDB(t *testing.T) {
ServiceID: serviceID,
NodeID: nodeID,
ServiceName: serviceName,
Cluster: serviceName,
Address: "10.10.10.10",
Port: 27017,
},
Expand Down Expand Up @@ -821,6 +827,7 @@ func TestAddMongoDB(t *testing.T) {
ServiceID: serviceID,
NodeID: nodeID,
ServiceName: serviceName,
Cluster: serviceName,
Address: "10.10.10.10",
Port: 27017,
},
Expand Down
6 changes: 6 additions & 0 deletions api-tests/management/mysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func TestAddMySQL(t *testing.T) {
ServiceID: serviceID,
NodeID: nodeID,
ServiceName: serviceName,
Cluster: serviceName,
Address: "10.10.10.10",
Port: 3306,
},
Expand Down Expand Up @@ -159,6 +160,7 @@ func TestAddMySQL(t *testing.T) {
ServiceID: serviceID,
NodeID: nodeID,
ServiceName: serviceName,
Cluster: serviceName,
Address: "10.10.10.10",
Port: 3306,
},
Expand Down Expand Up @@ -413,6 +415,7 @@ func TestAddMySQL(t *testing.T) {
ServiceID: serviceID,
NodeID: newNodeID,
ServiceName: serviceName,
Cluster: serviceName,
Address: "10.10.10.10",
Port: 27017,
},
Expand Down Expand Up @@ -666,6 +669,7 @@ func TestAddMySQL(t *testing.T) {
ServiceID: serviceID,
NodeID: nodeID,
ServiceName: serviceName,
Cluster: serviceName,
Address: "10.10.10.10",
Port: 3306,
},
Expand Down Expand Up @@ -741,6 +745,7 @@ func TestAddMySQL(t *testing.T) {
ServiceID: serviceID,
NodeID: nodeID,
ServiceName: serviceName,
Cluster: serviceName,
Address: "10.10.10.10",
Port: 3306,
},
Expand Down Expand Up @@ -815,6 +820,7 @@ func TestAddMySQL(t *testing.T) {
ServiceID: serviceID,
NodeID: nodeID,
ServiceName: serviceName,
Cluster: serviceName,
Address: "10.10.10.10",
Port: 3306,
},
Expand Down
7 changes: 7 additions & 0 deletions api-tests/management/postgresql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func TestAddPostgreSQL(t *testing.T) {
ServiceID: serviceID,
NodeID: nodeID,
ServiceName: serviceName,
Cluster: serviceName,
DatabaseName: defaultPostgresDBName,
Address: "10.10.10.10",
Port: 5432,
Expand Down Expand Up @@ -161,6 +162,7 @@ func TestAddPostgreSQL(t *testing.T) {
ServiceID: serviceID,
NodeID: nodeID,
ServiceName: serviceName,
Cluster: serviceName,
DatabaseName: defaultPostgresDBName,
Address: "10.10.10.10",
Port: 5432,
Expand Down Expand Up @@ -261,6 +263,7 @@ func TestAddPostgreSQL(t *testing.T) {
ServiceID: serviceID,
NodeID: nodeID,
ServiceName: serviceName,
Cluster: serviceName,
DatabaseName: defaultPostgresDBName,
Address: "10.10.10.10",
Port: 5432,
Expand Down Expand Up @@ -410,6 +413,7 @@ func TestAddPostgreSQL(t *testing.T) {
ServiceID: serviceID,
NodeID: newNodeID,
ServiceName: serviceName,
Cluster: serviceName,
DatabaseName: defaultPostgresDBName,
Address: "10.10.10.10",
Port: 27017,
Expand Down Expand Up @@ -636,6 +640,7 @@ func TestAddPostgreSQL(t *testing.T) {
ServiceID: serviceID,
NodeID: nodeID,
ServiceName: serviceName,
Cluster: serviceName,
DatabaseName: defaultPostgresDBName,
Address: "10.10.10.10",
Port: 5432,
Expand Down Expand Up @@ -711,6 +716,7 @@ func TestAddPostgreSQL(t *testing.T) {
ServiceID: serviceID,
NodeID: nodeID,
ServiceName: serviceName,
Cluster: serviceName,
DatabaseName: defaultPostgresDBName,
Address: "10.10.10.10",
Port: 5432,
Expand Down Expand Up @@ -785,6 +791,7 @@ func TestAddPostgreSQL(t *testing.T) {
ServiceID: serviceID,
NodeID: nodeID,
ServiceName: serviceName,
Cluster: serviceName,
DatabaseName: defaultPostgresDBName,
Address: "10.10.10.10",
Port: 5432,
Expand Down
16 changes: 9 additions & 7 deletions api-tests/management/proxysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func TestAddProxySQL(t *testing.T) {
ServiceID: serviceID,
NodeID: nodeID,
ServiceName: serviceName,
Cluster: serviceName,
Address: "10.10.10.10",
Port: 3306,
},
Expand Down Expand Up @@ -155,6 +156,7 @@ func TestAddProxySQL(t *testing.T) {
ServiceID: serviceID,
NodeID: nodeID,
ServiceName: serviceName,
Cluster: serviceName,
Address: "10.10.10.10",
Port: 3306,
},
Expand Down Expand Up @@ -260,13 +262,12 @@ func TestAddProxySQL(t *testing.T) {
params := &proxysql.AddProxySQLParams{
Context: pmmapitests.Context,
Body: proxysql.AddProxySQLBody{
NodeID: nodeID,
PMMAgentID: pmmAgentID,
ServiceName: serviceName,
Address: "10.10.10.10",
Port: 3306,
Username: "username",

NodeID: nodeID,
PMMAgentID: pmmAgentID,
ServiceName: serviceName,
Address: "10.10.10.10",
Port: 3306,
Username: "username",
SkipConnectionCheck: true,
},
}
Expand Down Expand Up @@ -386,6 +387,7 @@ func TestAddProxySQL(t *testing.T) {
ServiceID: serviceID,
NodeID: newNodeID,
ServiceName: serviceName,
Cluster: serviceName,
Address: "10.10.10.10",
Port: 27017,
},
Expand Down
3 changes: 3 additions & 0 deletions managed/models/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,9 @@ var databaseSchema = [][]string{
ALTER COLUMN comments_parsing_disabled DROP DEFAULT`,
},
85: {
`UPDATE services SET cluster = service_name WHERE cluster = ''`,
},
86: {
`ALTER TABLE services
ADD COLUMN version VARCHAR NOT NULL DEFAULT ''`,
},
Expand Down
Loading

0 comments on commit fe495cc

Please sign in to comment.