Commit 2a6d6566 authored by Daniel Scholl's avatar Daniel Scholl
Browse files

Fixing Infrastructure Testing Bugs

parent 08bda391
......@@ -20,18 +20,26 @@ func All() {
mg.Deps(PartitionTests)
}
// Execute Module Tests and fail if a test fails. Only executes tests in 'test' directories.
func ModuleTests() error {
mg.Deps(Clean)
mg.Deps(Check)
fmt.Println("INFO: Running unit tests...")
return FindAndRunTests("testing")
}
// Execute Unit Tests for OSDU MVP Central Resources.
func CentralUnitTest() error {
mg.Deps(Check)
fmt.Println("INFO: Running unit tests...")
return FindAndRunTests("central_resources/tests/unit")
return FindAndRunTests("templates/osdu-r3-mvp/central_resources/tests/unit")
}
// Execute Integration Tests for OSDU MVP Central Resources.
func CentralIntegrationTest() error {
mg.Deps(Check)
fmt.Println("INFO: Running integration tests...")
return FindAndRunTests("central_resources/tests/integration")
return FindAndRunTests("templates/osdu-r3-mvp/central_resources/tests/integration")
}
// Execute Tests for OSDU MVP Central Resources.
......@@ -44,14 +52,14 @@ func CentralTests() {
func ServiceUnitTest() error {
mg.Deps(Check)
fmt.Println("INFO: Running unit tests...")
return FindAndRunTests("service_resources/tests/unit")
return FindAndRunTests("templates/osdu-r3-mvp/service_resources/tests/unit")
}
// Execute Integration Tests for OSDU MVP Service Resources.
func ServiceIntegrationTest() error {
mg.Deps(Check)
fmt.Println("INFO: Running integration tests...")
return FindAndRunTests("service_resources/tests/integration")
return FindAndRunTests("templates/osdu-r3-mvp/service_resources/tests/integration")
}
// Execute Tests for OSDU MVP Service Resources.
......@@ -64,14 +72,14 @@ func ServiceTests() {
func PartitionUnitTest() error {
mg.Deps(Check)
fmt.Println("INFO: Running unit tests...")
return FindAndRunTests("data_partition/tests/unit")
return FindAndRunTests("templates/osdu-r3-mvp/data_partition/tests/unit")
}
// Execute Integration Tests for OSDU MVP Partition Resources.
func PartitionIntegrationTest() error {
mg.Deps(Check)
fmt.Println("INFO: Running integration tests...")
return FindAndRunTests("data_partition/tests/integration")
return FindAndRunTests("templates/osdu-r3-mvp/data_partition/tests/integration")
}
// Execute Tests for OSDU MVP Partition Resources.
......@@ -101,7 +109,7 @@ func LintTF() error {
// Remove temporary build and test files.
func Clean() error {
fmt.Println("INFO: Cleaning...")
return filepath.Walk("./infra/modules", func(path string, info os.FileInfo, err error) error {
return filepath.Walk("./modules", func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
......
......@@ -42,7 +42,7 @@ func asMap(t *testing.T, jsonString string) map[string]interface{} {
func TestTemplate(t *testing.T) {
expectedResult := asMap(t, `{
"kubernetes_version": "1.17.7"
"kubernetes_version": "1.17.9"
}`)
testFixture := infratests.UnitTestFixture{
......
......@@ -30,7 +30,7 @@ module "container-registry" {
container_registry_name = "osdu-module-container-registry-${module.resource_group.random}"
container_registry_admin_enabled = true
container_registry_sku = "Standard"
container_registry_tags = {
resource_tags = {
osdu = "module"
}
subnet_id_whitelist = [
......@@ -39,4 +39,4 @@ module "container-registry" {
resource_ip_whitelist = [
"10.0.0.0/24"
]
}
\ No newline at end of file
}
......@@ -11,7 +11,7 @@ import (
var name = "cosmosdb-"
var location = "eastus"
var count = 10
var count = 7
var tfOptions = &terraform.Options{
TerraformDir: "./",
......@@ -30,7 +30,7 @@ func TestTemplate(t *testing.T) {
expectedAccountResult := asMap(t, `{
"kind": "GlobalDocumentDB",
"enable_automatic_failover": false,
"enable_automatic_failover": true,
"enable_multiple_write_locations": false,
"is_virtual_network_filter_enabled": false,
"offer_type": "Standard",
......@@ -40,12 +40,14 @@ func TestTemplate(t *testing.T) {
}`)
expectedDatabaseResult := asMap(t, `{
"name": "osdu-module-database1",
"throughput": 400
"name": "osdu-module-database",
"autoscale_settings": [{
"max_throughput": 4000
}]
}`)
expectedContainerResult := asMap(t, `{
"database_name": "osdu-module-database1",
"database_name": "osdu-module-database",
"name": "osdu-module-container1",
"partition_key_path": "/id"
}`)
......@@ -57,9 +59,9 @@ func TestTemplate(t *testing.T) {
PlanAssertions: nil,
ExpectedResourceCount: count,
ExpectedResourceAttributeValues: infratests.ResourceDescription{
"module.cosmosdb.azurerm_cosmosdb_account.cosmosdb": expectedAccountResult,
"module.cosmosdb.azurerm_cosmosdb_sql_database.cosmos_dbs[0]": expectedDatabaseResult,
"module.cosmosdb.azurerm_cosmosdb_sql_container.cosmos_collections[0]": expectedContainerResult,
"module.cosmosdb_autoscale.azurerm_cosmosdb_account.cosmosdb": expectedAccountResult,
"module.cosmosdb_autoscale.azurerm_cosmosdb_sql_database.cosmos_dbs[0]": expectedDatabaseResult,
"module.cosmosdb_autoscale.azurerm_cosmosdb_sql_container.cosmos_collections[0]": expectedContainerResult,
},
}
......
......@@ -26,7 +26,7 @@ import (
)
var workspace = "osdu-services-" + strings.ToLower(random.UniqueId())
var count = 14
var count = 6
var tfOptions = &terraform.Options{
TerraformDir: "./",
......@@ -52,41 +52,17 @@ func TestTemplate(t *testing.T) {
},
}
expectedNamespaceAuth := map[string]interface{}{
"name": "policy",
"listen": true,
"send": true,
"manage": false,
}
expectedSubscription := map[string]interface{}{
"name": "sub_test",
"max_delivery_count": 1.0,
"lock_duration": "PT5M",
"forward_to": "",
"dead_lettering_on_message_expiration": true,
"name": "sub_test",
"max_delivery_count": 1.0,
"lock_duration": "PT5M",
"dead_lettering_on_filter_evaluation_error": true,
}
expectedTopic := map[string]interface{}{
"name": "topic_test",
"default_message_ttl": "PT30M",
"enable_partitioning": true,
"support_ordering": true,
"requires_duplicate_detection": true,
}
expectedTopicAuth := map[string]interface{}{
"name": "policy",
"listen": true,
"send": true,
"manage": false,
}
expectedSubRules := map[string]interface{}{
"name": "sub_test",
"filter_type": "SqlFilter",
"sql_filter": "color = 'red'",
"action": "",
"name": "topic_test",
"enable_partitioning": true,
"status": "Active",
}
testFixture := infratests.UnitTestFixture{
......@@ -96,12 +72,9 @@ func TestTemplate(t *testing.T) {
PlanAssertions: nil,
ExpectedResourceCount: count,
ExpectedResourceAttributeValues: infratests.ResourceDescription{
"module.service-bus.azurerm_servicebus_namespace.servicebus": expectedSBNamespace,
"module.service-bus.azurerm_servicebus_namespace_authorization_rule.sbnamespaceauth[0]": expectedNamespaceAuth,
"module.service-bus.azurerm_servicebus_topic.sptopic[0]": expectedTopic,
"module.service-bus.azurerm_servicebus_subscription.subscription[0]": expectedSubscription,
"module.service-bus.azurerm_servicebus_topic_authorization_rule.topicaauth[0]": expectedTopicAuth,
"module.service-bus.azurerm_servicebus_subscription_rule.subrules[0]": expectedSubRules,
"module.service_bus.azurerm_servicebus_namespace.main": expectedSBNamespace,
"module.service_bus.azurerm_servicebus_topic.main[0]": expectedTopic,
"module.service_bus.azurerm_servicebus_subscription.main[0]": expectedSubscription,
},
}
infratests.RunUnitTests(&testFixture)
......
......@@ -29,7 +29,7 @@ func TestTemplate(t *testing.T) {
expectedResult := asMap(t, `{
"account_kind" : "StorageV2",
"account_replication_type": "LRS",
"account_replication_type": "GZRS",
"account_tier": "Standard"
}`)
......
......@@ -19,7 +19,7 @@ import (
"testing"
"github.com/gruntwork-io/terratest/modules/terraform"
appGatewayIntegTests "github.com/microsoft/cobalt/infra/modules/providers/azure/aks-appgw/tests/integration"
appGatewayIntegTests "github.com/microsoft/cobalt/infra/modules/providers/azure/appgw/tests/integration"
redisIntegTests "github.com/microsoft/cobalt/infra/modules/providers/azure/redis-cache/tests/integration"
storageIntegTests "github.com/microsoft/cobalt/infra/modules/providers/azure/storage-account/tests/integration"
"github.com/microsoft/cobalt/test-harness/infratests"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment