Skip to content

Commit

Permalink
fix admin service unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shoothzj committed Feb 27, 2023
1 parent 5a36c73 commit fdcf7b3
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ INSERT INTO AppNamespace (AppId, Name) VALUES ('someAppId', 'application');

INSERT INTO Namespace (Id, AppId, ClusterName, NamespaceName) VALUES (100, 'someAppId', 'default', 'application');

INSERT INTO Item (NamespaceId, `Key`, `Type`, Value, Comment) VALUES (100, 'k1', '0', 'v1', 'comment1');
INSERT INTO Item (NamespaceId, `Key`, `Type`, Value, Comment) VALUES (100, 'k2', '0', 'v2', 'comment1');
INSERT INTO Item (NamespaceId, `Key`, `Type`, Value, Comment) VALUES (100, 'k3', '0', 'v3', 'comment1');
INSERT INTO Item (NamespaceId, "Key", "Type", "Value", Comment) VALUES (100, 'k1', '0', 'v1', 'comment1');
INSERT INTO Item (NamespaceId, "Key", "Type", "Value", Comment) VALUES (100, 'k2', '0', 'v2', 'comment1');
INSERT INTO Item (NamespaceId, "Key", "Type", "Value", Comment) VALUES (100, 'k3', '0', 'v3', 'comment1');
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
INSERT INTO `ServerConfig` (`Key`, `Cluster`, `Value`)
INSERT INTO `ServerConfig` ("Key", "Cluster", "Value")
VALUES
('name', 'default', 'kl');
31 changes: 26 additions & 5 deletions apollo-adminservice/src/test/resources/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,25 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
ALTER TABLE APP ALTER COLUMN DataChange_CreatedBy VARCHAR(255) NULL;
ALTER TABLE APP ALTER COLUMN DataChange_CreatedTime TIMESTAMP NULL;
ALTER TABLE APP ALTER COLUMN ORGNAME VARCHAR(255) NULL;
ALTER TABLE APP ALTER COLUMN ORGID VARCHAR(255) NULL;
ALTER TABLE Cluster ALTER COLUMN DataChange_CreatedBy VARCHAR(255) NULL;
ALTER TABLE Cluster ALTER COLUMN DataChange_CreatedTime TIMESTAMP NULL;
ALTER TABLE Cluster ALTER COLUMN ParentClusterId BIGINT DEFAULT 0;
ALTER TABLE Namespace ALTER COLUMN DataChange_CreatedBy VARCHAR(255) NULL;
ALTER TABLE Namespace ALTER COLUMN DataChange_CreatedTime TIMESTAMP NULL;
ALTER TABLE Item ALTER COLUMN DataChange_CreatedBy VARCHAR(255) NULL;
ALTER TABLE Item ALTER COLUMN DataChange_CreatedTime TIMESTAMP NULL;
ALTER TABLE RELEASE ALTER COLUMN DataChange_CreatedBy VARCHAR(255) NULL;
ALTER TABLE RELEASE ALTER COLUMN DataChange_CreatedTime TIMESTAMP NULL;
ALTER TABLE ServerConfig ALTER COLUMN DataChange_CreatedBy VARCHAR(255) NULL;
ALTER TABLE ServerConfig ALTER COLUMN DataChange_CreatedTime TIMESTAMP NULL;
ALTER TABLE ServerConfig ALTER COLUMN COMMENT VARCHAR(255) NULL;
ALTER TABLE Audit ALTER COLUMN DataChange_CreatedBy VARCHAR(255) NULL;
ALTER TABLE Audit ALTER COLUMN DataChange_CreatedTime TIMESTAMP NULL;

INSERT INTO App (AppId, Name, OwnerName, OwnerEmail) VALUES ('100003171','apollo-config-service','刘一鸣','liuym@ctrip.com');
INSERT INTO App (AppId, Name, OwnerName, OwnerEmail) VALUES ('100003172','apollo-admin-service','宋顺','song_s@ctrip.com');
INSERT INTO App (AppId, Name, OwnerName, OwnerEmail) VALUES ('100003173','apollo-portal','张乐','zhanglea@ctrip.com');
Expand All @@ -26,6 +45,9 @@ INSERT INTO Cluster (AppId, Name) VALUES ('100003173', 'default');
INSERT INTO Cluster (AppId, Name) VALUES ('100003173', 'cluster3');
INSERT INTO Cluster (AppId, Name) VALUES ('fxhermesproducer', 'default');

ALTER TABLE AppNamespace ALTER COLUMN DataChange_CreatedBy VARCHAR(255) NULL;
ALTER TABLE AppNamespace ALTER COLUMN DataChange_CreatedTime TIMESTAMP NULL;
ALTER TABLE AppNamespace ALTER COLUMN Format VARCHAR(255) NULL;
INSERT INTO AppNamespace (AppId, Name) VALUES ('100003171', 'application');
INSERT INTO AppNamespace (AppId, Name) VALUES ('100003171', 'fx.apollo.config');
INSERT INTO AppNamespace (AppId, Name) VALUES ('100003172', 'application');
Expand All @@ -40,10 +62,9 @@ INSERT INTO Namespace (Id, AppId, ClusterName, NamespaceName) VALUES (2, 'fxherm
INSERT INTO Namespace (Id, AppId, ClusterName, NamespaceName) VALUES (3, '100003172', 'default', 'application');
INSERT INTO Namespace (Id, AppId, ClusterName, NamespaceName) VALUES (4, '100003173', 'default', 'application');

INSERT INTO Item (NamespaceId, `Key`, Value, Comment) VALUES (1, 'k1', 'v1', 'comment1');
INSERT INTO Item (NamespaceId, `Key`, Value, Comment) VALUES (1, 'k2', 'v2', 'comment2');
INSERT INTO Item (NamespaceId, `Key`, Value, Comment) VALUES (2, 'k3', 'v3', 'comment3');
INSERT INTO Item (NamespaceId, `Key`, Value, Comment, LineNum) VALUES (5, 'k1', 'v4', 'comment4',1);
INSERT INTO Item (NamespaceId, "Key", "Value", Comment) VALUES (1, 'k1', 'v1', 'comment1');
INSERT INTO Item (NamespaceId, "Key", "Value", Comment) VALUES (1, 'k2', 'v2', 'comment2');
INSERT INTO Item (NamespaceId, "Key", "Value", Comment) VALUES (2, 'k3', 'v3', 'comment3');
INSERT INTO Item (NamespaceId, "Key", "Value", Comment, LineNum) VALUES (5, 'k1', 'v4', 'comment4',1);

INSERT INTO RELEASE (ReleaseKey, Name, Comment, AppId, ClusterName, NamespaceName, Configurations) VALUES ('TEST-RELEASE-KEY', 'REV1','First Release','100003171', 'default', 'application', '{"k1":"v1"}');

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
INSERT INTO `ServerConfig` (`Key`, `Cluster`, `Value`)
ALTER TABLE ServerConfig ALTER COLUMN DataChange_CreatedBy VARCHAR(255) NULL;
ALTER TABLE ServerConfig ALTER COLUMN DataChange_CreatedTime TIMESTAMP NULL;
ALTER TABLE ServerConfig ALTER COLUMN COMMENT VARCHAR(255) NULL;
INSERT INTO `ServerConfig` ("Key", "Cluster", "Value")
VALUES
('admin-service.access.tokens', 'default', 'someToken,anotherToken'),
('admin-service.access.control.enabled', 'default', 'false');
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
INSERT INTO `ServerConfig` (`Key`, `Cluster`, `Value`)
ALTER TABLE ServerConfig ALTER COLUMN DataChange_CreatedBy VARCHAR(255) NULL;
ALTER TABLE ServerConfig ALTER COLUMN DataChange_CreatedTime TIMESTAMP NULL;
ALTER TABLE ServerConfig ALTER COLUMN COMMENT VARCHAR(255) NULL;
INSERT INTO `ServerConfig` ("Key", "Cluster", "Value")
VALUES
('admin-service.access.control.enabled', 'default', 'true');
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
INSERT INTO `ServerConfig` (`Key`, `Cluster`, `Value`)
ALTER TABLE ServerConfig ALTER COLUMN DataChange_CreatedBy VARCHAR(255) NULL;
ALTER TABLE ServerConfig ALTER COLUMN DataChange_CreatedTime TIMESTAMP NULL;
ALTER TABLE ServerConfig ALTER COLUMN COMMENT VARCHAR(255) NULL;
INSERT INTO `ServerConfig` ("Key", "Cluster", "Value")
VALUES
('admin-service.access.tokens', 'default', 'someToken,anotherToken'),
('admin-service.access.control.enabled', 'default', 'true');
16 changes: 0 additions & 16 deletions apollo-adminservice/src/test/resources/import.sql

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class Item extends BaseEntity {
@Column(name = "`Key`", nullable = false)
private String key;

@Column(name = "type")
@Column(name = "`Type`")
private int type;

@Column(name = "`Value`")
Expand Down
27 changes: 21 additions & 6 deletions apollo-configservice/src/test/resources/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,18 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
ALTER TABLE APP ALTER COLUMN DataChange_CreatedBy VARCHAR(255) NULL;
ALTER TABLE APP ALTER COLUMN DataChange_CreatedTime TIMESTAMP NULL;
ALTER TABLE APP ALTER COLUMN ORGNAME VARCHAR(255) NULL;
ALTER TABLE APP ALTER COLUMN ORGID VARCHAR(255) NULL;
INSERT INTO App (AppId, Name, OwnerName, OwnerEmail) VALUES ('100003171','apollo-config-service','刘一鸣','liuym@ctrip.com');
INSERT INTO App (AppId, Name, OwnerName, OwnerEmail) VALUES ('100003172','apollo-admin-service','宋顺','song_s@ctrip.com');
INSERT INTO App (AppId, Name, OwnerName, OwnerEmail) VALUES ('100003173','apollo-portal','张乐','zhanglea@ctrip.com');
INSERT INTO App (AppId, Name, OwnerName, OwnerEmail) VALUES ('fxhermesproducer','fx-hermes-producer','梁锦华','jhliang@ctrip.com');

ALTER TABLE Cluster ALTER COLUMN DataChange_CreatedBy VARCHAR(255) NULL;
ALTER TABLE Cluster ALTER COLUMN DataChange_CreatedTime TIMESTAMP NULL;
ALTER TABLE Cluster ALTER COLUMN ParentClusterId BIGINT NULL;
INSERT INTO Cluster (AppId, Name) VALUES ('100003171', 'default');
INSERT INTO Cluster (AppId, Name) VALUES ('100003171', 'cluster1');
INSERT INTO Cluster (AppId, Name) VALUES ('100003172', 'default');
Expand All @@ -26,6 +33,9 @@ INSERT INTO Cluster (AppId, Name) VALUES ('100003173', 'default');
INSERT INTO Cluster (AppId, Name) VALUES ('100003173', 'cluster3');
INSERT INTO Cluster (AppId, Name) VALUES ('fxhermesproducer', 'default');

ALTER TABLE AppNamespace ALTER COLUMN DataChange_CreatedBy VARCHAR(255) NULL;
ALTER TABLE AppNamespace ALTER COLUMN DataChange_CreatedTime TIMESTAMP NULL;
ALTER TABLE AppNamespace ALTER COLUMN Format VARCHAR(255) NULL;
INSERT INTO AppNamespace (AppId, Name) VALUES ('100003171', 'application');
INSERT INTO AppNamespace (AppId, Name) VALUES ('100003171', 'fx.apollo.config');
INSERT INTO AppNamespace (AppId, Name) VALUES ('100003172', 'application');
Expand All @@ -34,16 +44,21 @@ INSERT INTO AppNamespace (AppId, Name) VALUES ('100003173', 'application');
INSERT INTO AppNamespace (AppId, Name) VALUES ('100003173', 'fx.apollo.portal');
INSERT INTO AppNamespace (AppID, Name) VALUES ('fxhermesproducer', 'fx.hermes.producer');

ALTER TABLE Namespace ALTER COLUMN DataChange_CreatedBy VARCHAR(255) NULL;
ALTER TABLE Namespace ALTER COLUMN DataChange_CreatedTime TIMESTAMP NULL;
INSERT INTO Namespace (Id, AppId, ClusterName, NamespaceName) VALUES (1, '100003171', 'default', 'application');
INSERT INTO Namespace (Id, AppId, ClusterName, NamespaceName) VALUES (5, '100003171', 'cluster1', 'application');
INSERT INTO Namespace (Id, AppId, ClusterName, NamespaceName) VALUES (2, 'fxhermesproducer', 'default', 'fx.hermes.producer');
INSERT INTO Namespace (Id, AppId, ClusterName, NamespaceName) VALUES (3, '100003172', 'default', 'application');
INSERT INTO Namespace (Id, AppId, ClusterName, NamespaceName) VALUES (4, '100003173', 'default', 'application');
INSERT INTO Namespace (Id, AppId, ClusterName, NamespaceName) VALUES (5, '100003171', 'default', 'application');

INSERT INTO Item (NamespaceId, `Key`, Value, Comment) VALUES (1, 'k1', 'v1', 'comment1');
INSERT INTO Item (NamespaceId, `Key`, Value, Comment) VALUES (1, 'k2', 'v2', 'comment2');
INSERT INTO Item (NamespaceId, `Key`, Value, Comment) VALUES (2, 'k3', 'v3', 'comment3');
INSERT INTO Item (NamespaceId, `Key`, Value, Comment) VALUES (5, 'k3', 'v4', 'comment4');
ALTER TABLE Item ALTER COLUMN DataChange_CreatedBy VARCHAR(255) NULL;
ALTER TABLE Item ALTER COLUMN DataChange_CreatedTime TIMESTAMP NULL;
INSERT INTO Item (NamespaceId, "Key", "Value", Comment) VALUES (1, 'k1', 'v1', 'comment1');
INSERT INTO Item (NamespaceId, "Key", "Value", Comment) VALUES (1, 'k2', 'v2', 'comment2');
INSERT INTO Item (NamespaceId, "Key", "Value", Comment) VALUES (2, 'k3', 'v3', 'comment3');
INSERT INTO Item (NamespaceId, "Key", "Value", Comment, LineNum) VALUES (5, 'k1', 'v4', 'comment4',1);

ALTER TABLE RELEASE ALTER COLUMN DataChange_CreatedBy VARCHAR(255) NULL;
ALTER TABLE RELEASE ALTER COLUMN DataChange_CreatedTime TIMESTAMP NULL;
INSERT INTO RELEASE (ReleaseKey, Name, Comment, AppId, ClusterName, NamespaceName, Configurations) VALUES ('TEST-RELEASE-KEY', 'REV1','First Release','100003171', 'default', 'application', '{"k1":"v1"}');

0 comments on commit fdcf7b3

Please sign in to comment.