From 27ae2f64995282937e9dc8fadd69e34824b91d6f Mon Sep 17 00:00:00 2001 From: Yingjian Wu Date: Wed, 6 Mar 2024 13:52:28 -0500 Subject: [PATCH] add more test --- .../netflix/metacat/MetacatSmokeSpec.groovy | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/metacat-functional-tests/src/functionalTest/groovy/com/netflix/metacat/MetacatSmokeSpec.groovy b/metacat-functional-tests/src/functionalTest/groovy/com/netflix/metacat/MetacatSmokeSpec.groovy index 7f961e58e..8dfa578c6 100644 --- a/metacat-functional-tests/src/functionalTest/groovy/com/netflix/metacat/MetacatSmokeSpec.groovy +++ b/metacat-functional-tests/src/functionalTest/groovy/com/netflix/metacat/MetacatSmokeSpec.groovy @@ -1573,6 +1573,13 @@ class MetacatSmokeSpec extends Specification { def dto = api.getTable(catalogName, databaseName, tableName, false, true, true) then: metacatJson.convertValue(dto.getDefinitionMetadata().get('tags'), Set.class) == tags + tagApi.getTags() == tags + tagApi.search('tag', null, null, null).size() == 3 + tagApi.search('tag', null, null, tableName).size() == 1 + tagApi.search('tag', null, null, tableName).size() == 1 + tagApi.list(tags, null, null, null, null, null).size() == 3 + tagApi.list(tags, null, null, null, null, QualifiedName.Type.TABLE).size() == 1 + tagApi.list(tags, null, null, null, "random_table", QualifiedName.Type.TABLE).size() == 0 cleanup: tagApi.removeTableTags(catalogName, databaseName, tableName, true, [] as Set) api.deleteTable(catalogName, databaseName, tableName) @@ -1661,6 +1668,63 @@ class MetacatSmokeSpec extends Specification { 's3-mysql-db' | 'smoke_db6' | 'part' | ['test_tag', 'unused'] as List | false } + def "Test tags for multiple tables #catalogName/#databaseName/#tableName"() { + setup: + def catalogName = "prodhive" + def databaseName = "default" + when: + createTable(catalogName, databaseName, "table1") + tagApi.setTableTags(catalogName, databaseName, "table1", ['table1', 'test'] as Set) + then: + tagApi.getTags().size() == 2 + tagApi.list(['table1', 'test'] as Set, null, null, null, null, QualifiedName.Type.TABLE).size() == 1 + tagApi.search('test', null, null, null).size() == 3 + tagApi.search('table1', null, null, null).size() == 3 + when: + createTable(catalogName, databaseName, "table2") + tagApi.setTableTags(catalogName, databaseName, "table2", ['table2', 'test'] as Set) + then: + tagApi.getTags().size() == 3 + tagApi.list(['table1', 'test'] as Set, null, null, null, null, QualifiedName.Type.TABLE).size() == 1 + tagApi.list(['table2', 'test'] as Set, null, null, null, null, QualifiedName.Type.TABLE).size() == 1 + tagApi.list(['test'] as Set, null, null, null, null, QualifiedName.Type.TABLE).size() == 2 + tagApi.search('test', null, null, null).size() == 4 + tagApi.search('table1', null, null, null).size() == 3 + tagApi.search('table2', null, null, null).size() == 3 + when: + createTable(catalogName, databaseName, "table3") + tagApi.setTableTags(catalogName, databaseName, "table3", ['table3', 'unused'] as Set) + then: + tagApi.getTags().size() == 5 + tagApi.list(['table1', 'test'] as Set, null, null, null, null, QualifiedName.Type.TABLE).size() == 1 + tagApi.list(['table2', 'test'] as Set, null, null, null, null, QualifiedName.Type.TABLE).size() == 1 + tagApi.list(['test'] as Set, null, null, null, null, QualifiedName.Type.TABLE).size() == 2 + tagApi.list(['table3', 'unused'] as Set, null, null, null, null, QualifiedName.Type.TABLE).size() == 1 + tagApi.list(['unused'] as Set, null, null, null, null, QualifiedName.Type.TABLE).size() == 1 + tagApi.search('test', null, null, null).size() == 4 + tagApi.search('table1', null, null, null).size() == 3 + tagApi.search('table2', null, null, null).size() == 3 + tagApi.search('table3', null, null, null).size() == 3 + tagApi.search('unused', null, null, null).size() == 3 + when: + api.deleteTable(catalogName, databaseName, "table1") + then: + tagApi.getTags().size() == 5 + tagApi.list(['table1', 'test'] as Set, null, null, null, null, QualifiedName.Type.TABLE).size() == 0 + tagApi.list(['table2', 'test'] as Set, null, null, null, null, QualifiedName.Type.TABLE).size() == 1 + tagApi.list(['test'] as Set, null, null, null, null, QualifiedName.Type.TABLE).size() == 1 + tagApi.list(['table3', 'unused'] as Set, null, null, null, null, QualifiedName.Type.TABLE).size() == 1 + tagApi.list(['unused'] as Set, null, null, null, null, QualifiedName.Type.TABLE).size() == 1 + tagApi.search('test', null, null, null).size() == 3 + tagApi.search('table1', null, null, null).size() == 0 + tagApi.search('table2', null, null, null).size() == 3 + tagApi.search('table3', null, null, null).size() == 3 + tagApi.search('unused', null, null, null).size() == 3 + cleanup: + api.deleteTable(catalogName, databaseName, "table2") + api.deleteTable(catalogName, databaseName, "table3") + } + @Unroll def "Test tags for #catalogName/#databaseName/#tableName/#viewName"() { when: