Skip to content

Commit

Permalink
Merge pull request #109 from smurawski/azd_support
Browse files Browse the repository at this point in the history
Azd support and prepare playwright for testing store front too.
  • Loading branch information
pauldotyu authored Feb 9, 2024
2 parents 5cd8071 + 092ff87 commit b560ce3
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 15 deletions.
22 changes: 22 additions & 0 deletions azd-hooks/postprovision.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env pwsh

$services=@("ai-service", "makeline-service", "order-service", "product-service", "store-admin", "store-front", "virtual-customer", "virtual-worker")

if (($env:DEPLOY_AZURE_CONTAINER_REGISTRY -like "true") -and ($env:BUILD_CONTAINERS -like "true")) {
echo "Build container images"
foreach ($service in $services) {
echo "Building aks-store-demo/${service}:latest"
az acr build --registry $env:AZURE_REGISTRY_NAME --image aks-store-demo/${service}:latest ./src/${service}/
}
}
elseif (($env:DEPLOY_AZURE_CONTAINER_REGISTRY -like "true") -and ($env:BUILD_CONTAINERS -like "false")) {
echo "Import container images"
foreach ($service in $services) {
echo "Importing aks-store-demo/${service}:latest"
az acr import --name $env:AZURE_REGISTRY_NAME --source ghcr.io/azure-samples/aks-store-demo/${service}:latest --image aks-store-demo/${service}:latest
}
}
else {
echo "No BUILD_CONTAINERS variable set, skipping container build/import"
}

39 changes: 39 additions & 0 deletions azd-hooks/predeploy.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env pwsh

echo "Retrieving cluster credentials"
az aks get-credentials --resource-group $env:AZURE_RESOURCEGROUP_NAME --name $env:AZURE_AKS_CLUSTER_NAME --overwrite-existing

$makelineUseSqlApi = "false"
if ($env:AZURE_DATABASE_API -eq "cosmosdbsql") {
$makelineUseSqlApi = "true"
}

echo "Deploy Helm chart"
helm upgrade aks-store-demo ./charts/aks-store-demo `
--install `
--set aiService.create=true `
--set aiService.modelDeploymentName=$env:AZURE_OPENAI_MODEL_NAME `
--set aiService.openAiEndpoint=$env:AZURE_OPENAI_ENDPOINT `
--set aiService.managedIdentityClientId=$env:AZURE_IDENTITY_CLIENT_ID `
--set aiService.image.repository=$env:AZURE_REGISTRY_URI/aks-store-demo/ai-service `
--set orderService.useAzureServiceBus=true `
--set orderService.queueHost=$env:AZURE_SERVICE_BUS_HOST `
--set orderService.queuePort=5671 `
--set orderService.queueUsername=$env:AZURE_SERVICE_BUS_SENDER_NAME `
--set orderService.queuePassword=$(az keyvault secret show --name $env:AZURE_SERVICE_BUS_SENDER_KEY --vault-name $env:AZURE_KEY_VAULT_NAME --query value -o tsv) `
--set orderService.queueTransport=tls `
--set orderService.image.repository=$env:AZURE_REGISTRY_URI/aks-store-demo/order-service `
--set makelineService.useAzureCosmosDB=true `
--set makelineService.orderQueueUri=$env:AZURE_SERVICE_BUS_URI `
--set makelineService.orderQueueUsername=$env:AZURE_SERVICE_BUS_LISTENER_NAME `
--set makelineService.orderQueuePassword=$(az keyvault secret show --name $env:AZURE_SERVICE_BUS_LISTENER_KEY --vault-name $env:AZURE_KEY_VAULT_NAME --query value -o tsv) `
--set makelineService.orderDBUri=$env:AZURE_COSMOS_DATABASE_URI `
--set makelineService.orderDBUsername=$env:AZURE_COSMOS_DATABASE_NAME `
--set makelineService.orderDBPassword=$(az keyvault secret show --name $env:AZURE_COSMOS_DATABASE_KEY --vault-name $env:AZURE_KEY_VAULT_NAME --query value -o tsv) `
--set makelineService.image.repository=$env:AZURE_REGISTRY_URI/aks-store-demo/makeline-service `
--set productService.image.repository=$env:AZURE_REGISTRY_URI/aks-store-demo/product-service `
--set storeAdmin.image.repository=$env:AZURE_REGISTRY_URI/aks-store-demo/store-admin `
--set storeFront.image.repository=$env:AZURE_REGISTRY_URI/aks-store-demo/store-front `
--set virtualCustomer.image.repository=$env:AZURE_REGISTRY_URI/aks-store-demo/virtual-customer `
--set virtualWorker.image.repository=$env:AZURE_REGISTRY_URI/aks-store-demo/virtual-worker `
--set makelineService.useSqlApi=$makelineUseSqlApi
10 changes: 10 additions & 0 deletions azd-hooks/preprovision.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env pwsh

echo "Ensuring Azure CLI extensions and dependencies are installed"
az provider register --namespace Microsoft.ContainerService
az feature register --namespace Microsoft.ContainerService --name AKS-KedaPreview
az feature register --namespace Microsoft.ContainerService --name AKS-PrometheusAddonPreview
az feature register --namespace Microsoft.ContainerService --name EnableWorkloadIdentityPreview
az feature register --namespace Microsoft.ContainerService --name NetworkObservabilityPreview
az extension add --upgrade --name aks-preview
az extension add --upgrade --name amg
42 changes: 30 additions & 12 deletions azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,38 @@ metadata:
template: [email protected]
hooks:
preprovision:
shell: sh
continueOnError: false
interactive: false
run: azd-hooks/preprovision.sh
posix:
shell: sh
continueOnError: false
interactive: false
run: azd-hooks/preprovision.sh
windows:
shell: pwsh
continueOnError: false
interactive: false
run: azd-hooks/preprovision.ps1
postprovision:
shell: sh
continueOnError: false
interactive: false
run: azd-hooks/postprovision.sh
posix:
shell: sh
continueOnError: false
interactive: false
run: azd-hooks/postprovision.sh
windows:
shell: pwsh
continueOnError: false
interactive: false
run: azd-hooks/postprovision.ps1
predeploy: # This is a hack until Helm is supported in azd (https://github.com/Azure/azure-dev/issues/1618)
shell: sh
continueOnError: false
interactive: false
run: azd-hooks/predeploy.sh
posix:
shell: sh
continueOnError: false
interactive: false
run: azd-hooks/predeploy.sh
windows:
shell: pwsh
continueOnError: false
interactive: false
run: azd-hooks/predeploy.ps1
infra:
provider: terraform
path: infra/terraform
1 change: 1 addition & 0 deletions tests/e2e/add_product.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { test, expect } from '@playwright/test';

test.use({ baseURL: process.env.STORE_ADMIN_URL });

test('can add product ', async ({ page }) => {
await page.goto('/');
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/example.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { test, expect } from '@playwright/test';

test.use({ baseURL: process.env.STORE_ADMIN_URL });

test('has title', async ({ page }) => {
await page.goto('/');

Expand Down
1 change: 1 addition & 0 deletions tests/e2e/products.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { test, expect } from '@playwright/test';

test.use({ baseURL: process.env.STORE_ADMIN_URL });

test('renders functionally', async ({ page }) => {
await page.goto('/');
Expand Down
3 changes: 0 additions & 3 deletions tests/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ export default defineConfig({
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: process.env.STORE_ADMIN_URL,

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},
Expand Down

0 comments on commit b560ce3

Please sign in to comment.