Add refactored e2e tests
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
This commit is contained in:
committed by
Sunny
parent
1730f3c46b
commit
f6b0c6e7ef
19
tests/integration/terraform/azure/aks.tf
Normal file
19
tests/integration/terraform/azure/aks.tf
Normal file
@@ -0,0 +1,19 @@
|
||||
module "aks" {
|
||||
source = "git::https://github.com/fluxcd/test-infra.git//tf-modules/azure/aks"
|
||||
|
||||
name = local.name
|
||||
location = var.azure_location
|
||||
tags = var.tags
|
||||
}
|
||||
|
||||
module "acr" {
|
||||
source = "git::https://github.com/fluxcd/test-infra.git//tf-modules/azure/acr"
|
||||
|
||||
name = local.name
|
||||
location = var.azure_location
|
||||
aks_principal_id = [module.aks.principal_id]
|
||||
resource_group = module.aks.resource_group
|
||||
tags = var.tags
|
||||
|
||||
depends_on = [module.aks]
|
||||
}
|
||||
26
tests/integration/terraform/azure/azuredevops.tf
Normal file
26
tests/integration/terraform/azure/azuredevops.tf
Normal file
@@ -0,0 +1,26 @@
|
||||
resource "azuredevops_project" "e2e" {
|
||||
name = local.name
|
||||
visibility = "private"
|
||||
version_control = "Git"
|
||||
work_item_template = "Agile"
|
||||
description = "Test Project for Flux E2E test - Managed by Terraform"
|
||||
}
|
||||
|
||||
|
||||
resource "azuredevops_git_repository" "fleet_infra" {
|
||||
project_id = azuredevops_project.e2e.id
|
||||
name = "fleet-infra-${local.name}"
|
||||
default_branch = "refs/heads/main"
|
||||
initialization {
|
||||
init_type = "Clean"
|
||||
}
|
||||
}
|
||||
|
||||
resource "azuredevops_git_repository" "application" {
|
||||
project_id = azuredevops_project.e2e.id
|
||||
name = "application-${local.name}"
|
||||
default_branch = "refs/heads/main"
|
||||
initialization {
|
||||
init_type = "Clean"
|
||||
}
|
||||
}
|
||||
27
tests/integration/terraform/azure/event-hub.tf
Normal file
27
tests/integration/terraform/azure/event-hub.tf
Normal file
@@ -0,0 +1,27 @@
|
||||
resource "azurerm_eventhub_namespace" "this" {
|
||||
name = local.name
|
||||
location = var.azure_location
|
||||
resource_group_name = module.aks.resource_group
|
||||
sku = "Basic"
|
||||
capacity = 1
|
||||
tags = var.tags
|
||||
}
|
||||
|
||||
|
||||
resource "azurerm_eventhub" "this" {
|
||||
name = local.name
|
||||
namespace_name = azurerm_eventhub_namespace.this.name
|
||||
resource_group_name = module.aks.resource_group
|
||||
partition_count = 1
|
||||
message_retention = 1
|
||||
}
|
||||
|
||||
resource "azurerm_eventhub_authorization_rule" "this" {
|
||||
name = local.name
|
||||
resource_group_name = module.aks.resource_group
|
||||
namespace_name = azurerm_eventhub_namespace.this.name
|
||||
eventhub_name = azurerm_eventhub.this.name
|
||||
listen = true
|
||||
send = true
|
||||
manage = false
|
||||
}
|
||||
61
tests/integration/terraform/azure/keyvault.tf
Normal file
61
tests/integration/terraform/azure/keyvault.tf
Normal file
@@ -0,0 +1,61 @@
|
||||
resource "azurerm_key_vault" "this" {
|
||||
name = local.name
|
||||
resource_group_name = module.aks.resource_group
|
||||
location = var.azure_location
|
||||
tenant_id = data.azurerm_client_config.current.tenant_id
|
||||
sku_name = "standard"
|
||||
tags = var.tags
|
||||
}
|
||||
|
||||
resource "azurerm_key_vault_access_policy" "admin" {
|
||||
key_vault_id = azurerm_key_vault.this.id
|
||||
tenant_id = data.azurerm_client_config.current.tenant_id
|
||||
object_id = data.azurerm_client_config.current.object_id
|
||||
|
||||
key_permissions = [
|
||||
"Create",
|
||||
"Update",
|
||||
"Encrypt",
|
||||
"Delete",
|
||||
"Get",
|
||||
"List",
|
||||
"Purge",
|
||||
"Recover",
|
||||
"GetRotationPolicy",
|
||||
"SetRotationPolicy"
|
||||
]
|
||||
|
||||
secret_permissions = [
|
||||
"Get",
|
||||
"Delete",
|
||||
"Purge",
|
||||
"Recover"
|
||||
]
|
||||
|
||||
}
|
||||
|
||||
resource "azurerm_key_vault_access_policy" "cluster_binding" {
|
||||
key_vault_id = azurerm_key_vault.this.id
|
||||
tenant_id = data.azurerm_client_config.current.tenant_id
|
||||
object_id = module.aks.principal_id
|
||||
|
||||
key_permissions = [
|
||||
"Decrypt",
|
||||
"Encrypt",
|
||||
]
|
||||
}
|
||||
|
||||
resource "azurerm_key_vault_key" "sops" {
|
||||
depends_on = [azurerm_key_vault_access_policy.admin]
|
||||
|
||||
name = "sops"
|
||||
key_vault_id = azurerm_key_vault.this.id
|
||||
key_type = "RSA"
|
||||
key_size = 2048
|
||||
tags = var.tags
|
||||
|
||||
key_opts = [
|
||||
"decrypt",
|
||||
"encrypt",
|
||||
]
|
||||
}
|
||||
35
tests/integration/terraform/azure/main.tf
Normal file
35
tests/integration/terraform/azure/main.tf
Normal file
@@ -0,0 +1,35 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = ">=3.20.0"
|
||||
}
|
||||
azuread = {
|
||||
source = "hashicorp/azuread"
|
||||
version = ">=2.28.0"
|
||||
}
|
||||
azuredevops = {
|
||||
source = "microsoft/azuredevops"
|
||||
version = ">=0.2.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "azurerm" {
|
||||
features {}
|
||||
}
|
||||
|
||||
provider "azuredevops" {
|
||||
org_service_url = "https://dev.azure.com/${var.azuredevops_org}"
|
||||
personal_access_token = var.azuredevops_pat
|
||||
}
|
||||
|
||||
data "azurerm_client_config" "current" {}
|
||||
|
||||
resource "random_pet" "suffix" {
|
||||
separator = "o"
|
||||
}
|
||||
|
||||
locals {
|
||||
name = "e2e${random_pet.suffix.id}"
|
||||
}
|
||||
41
tests/integration/terraform/azure/outputs.tf
Normal file
41
tests/integration/terraform/azure/outputs.tf
Normal file
@@ -0,0 +1,41 @@
|
||||
output "aks_kubeconfig" {
|
||||
description = "kubeconfig of the created AKS cluster"
|
||||
value = module.aks.kubeconfig
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
output "azure_devops_access_token" {
|
||||
sensitive = true
|
||||
value = var.azuredevops_pat
|
||||
}
|
||||
|
||||
output "fleet_infra_repository" {
|
||||
value = {
|
||||
http = azuredevops_git_repository.fleet_infra.remote_url
|
||||
ssh = "ssh://git@ssh.dev.azure.com/v3/${var.azuredevops_org}/${azuredevops_git_repository.fleet_infra.project_id}/${azuredevops_git_repository.fleet_infra.name}"
|
||||
}
|
||||
}
|
||||
|
||||
output "application_repository" {
|
||||
value = {
|
||||
http = azuredevops_git_repository.application.remote_url
|
||||
ssh = "ssh://git@ssh.dev.azure.com/v3/${var.azuredevops_org}/${azuredevops_git_repository.application.project_id}/${azuredevops_git_repository.application.name}"
|
||||
}
|
||||
}
|
||||
|
||||
output "aks_client_id" {
|
||||
value = module.aks.kubelet_client_id
|
||||
}
|
||||
|
||||
output "event_hub_sas" {
|
||||
value = azurerm_eventhub_authorization_rule.this.primary_connection_string
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
output "sops_id" {
|
||||
value = azurerm_key_vault_key.sops.id
|
||||
}
|
||||
|
||||
output "acr_url" {
|
||||
value = module.acr.registry_url
|
||||
}
|
||||
21
tests/integration/terraform/azure/variables.tf
Normal file
21
tests/integration/terraform/azure/variables.tf
Normal file
@@ -0,0 +1,21 @@
|
||||
variable "azuredevops_org" {
|
||||
type = string
|
||||
description = "Name of Azure DevOps organizations were the repositories will be created"
|
||||
}
|
||||
|
||||
variable "azure_location" {
|
||||
type = string
|
||||
description = "Location of the resource group"
|
||||
default = "eastus"
|
||||
}
|
||||
|
||||
variable "tags" {
|
||||
type = map(string)
|
||||
default = {}
|
||||
description = "Tags for created Azure resources"
|
||||
}
|
||||
|
||||
variable "azuredevops_pat" {
|
||||
type = string
|
||||
description = "Personal access token for Azure DevOps repository"
|
||||
}
|
||||
Reference in New Issue
Block a user