Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APIM: Enable CRD Sample tests for APIM Product #3651

Open
ross-p-smith opened this issue Dec 14, 2023 · 1 comment
Open

APIM: Enable CRD Sample tests for APIM Product #3651

ross-p-smith opened this issue Dec 14, 2023 · 1 comment
Labels
test Test refactoring related tasks
Milestone

Comments

@ross-p-smith
Copy link
Contributor

PR #3552 enables ProductPolicy and ProductApi. However, the samples tests are commented out because they take a long time to provision APIM.

Describe the improvement
In v2/internal/testcommon/samples_tester.go there are some exclusions defined on L62 - we should capture recordings for these.

Additional context
You will need to delete the recording and re-record after removing these exclusions.

@ross-p-smith
Copy link
Contributor Author

ross-p-smith commented Dec 19, 2023

Extra information. We cannot enable the ProductPolicy and ProductApi samples test until the Product sample is enabled. If we enable the Product sample test then this is the output of the integration test

[controller:test-integration-envtest]     logr.go:284: I2023-12-19T14:42:58Z] ProductController "msg"="Encountered error, re-queuing..." name="asotestaachpc" namespace="aso-test-samples-creationanddeletion-test-apimanagement-v-88dd7" result=reconcile.Result{Requeue:false, RequeueAfter:60000000000}
[controller:test-integration-envtest]     kube_per_test_context.go:548: 
[controller:test-integration-envtest]         Timed out after 1800.000s.
[controller:test-integration-envtest]         Expected
[controller:test-integration-envtest]             <*v1api20220801.Product | 0xc002055180>: {
[controller:test-integration-envtest]                 TypeMeta: {Kind: "", APIVersion: ""},
[controller:test-integration-envtest]                 ObjectMeta: {
[controller:test-integration-envtest]                     Name: "asotestaachpc",
[controller:test-integration-envtest]                     GenerateName: "",
[controller:test-integration-envtest]                     Namespace: "aso-test-samples-creationanddeletion-test-apimanagement-v-88dd7",
[controller:test-integration-envtest]                     SelfLink: "",
[controller:test-integration-envtest]                     UID: "7e47404a-6b38-4b0d-9c7b-4a057af651b8",
[controller:test-integration-envtest]                     ResourceVersion: "1421",
[controller:test-integration-envtest]                     Generation: 2,
[controller:test-integration-envtest]                     CreationTimestamp: {
[controller:test-integration-envtest]                         Time: 2023-12-19T13:46:49Z,
[controller:test-integration-envtest]                     },
[controller:test-integration-envtest]                     DeletionTimestamp: {
[controller:test-integration-envtest]                         Time: 2023-12-19T14:13:25Z,
[controller:test-integration-envtest]                     },
[controller:test-integration-envtest]                     DeletionGracePeriodSeconds: 0,
[controller:test-integration-envtest]                     Labels: {
[controller:test-integration-envtest]                         "serviceoperator.azure.com/owner-group-kind": "Service.apimanagement.azure.com",
[controller:test-integration-envtest]                         "serviceoperator.azure.com/owner-name": "asotestxrhkfo",
[controller:test-integration-envtest]                     },
[controller:test-integration-envtest]                     Annotations: {
[controller:test-integration-envtest]                         "serviceoperator.azure.com/latest-reconciled-generation": "1",
[controller:test-integration-envtest]                         "serviceoperator.azure.com/resource-id": "/subscriptions/xxxx/resourceGroups/asotest-rg-nnxzgr/providers/Microsoft.ApiManagement/service/asotestxrhkfo/products/asotestaachpc",
[controller:test-integration-envtest]                     },
[controller:test-integration-envtest]                     OwnerReferences: [
[controller:test-integration-envtest]                         {
[controller:test-integration-envtest]                             APIVersion: "apimanagement.azure.com/v1api20220801storage",
[controller:test-integration-envtest]                             Kind: "Service",
[controller:test-integration-envtest]                             Name: "asotestxrhkfo",
[controller:test-integration-envtest]                             UID: "3b626492-8cf8-4b59-bed8-5d8740d28a9a",
[controller:test-integration-envtest]                             Controller: nil,
[controller:test-integration-envtest]                             BlockOwnerDeletion: nil,
[controller:test-integration-envtest]                         },
[controller:test-integration-envtest]                     ],
[controller:test-integration-envtest]                     Finalizers: [
[controller:test-integration-envtest]                         "serviceoperator.azure.com/finalizer",
[controller:test-integration-envtest]                     ],
[controller:test-integration-envtest]                     ManagedFields: [
[controller:test-integration-envtest]                         {
[controller:test-integration-envtest]                             Manager: "controllers.test",
[controller:test-integration-envtest]                             Operation: "Update",
[controller:test-integration-envtest]                             APIVersion: "apimanagement.azure.com/v1api20220801",
[controller:test-integration-envtest]                             Time: {
[controller:test-integration-envtest]                                 Time: 2023-12-19T13:46:49Z,
[controller:test-integration-envtest]                             },
[controller:test-integration-envtest]                             FieldsType: "FieldsV1",
[controller:test-integration-envtest]                             FieldsV1: {
[controller:test-integration-envtest]                                 Raw: "{\"f:spec\":{\".\":{},\"f:description\":{},\"f:displayName\":{},\"f:owner\":{\".\":{},\"f:name\":{}},\"f:subscriptionRequired\":{}}}",
[controller:test-integration-envtest]                             },
[controller:test-integration-envtest]                             Subresource: "",
[controller:test-integration-envtest]                         },
[controller:test-integration-envtest]                         {
[controller:test-integration-envtest]                             Manager: "controllers.test",
[controller:test-integration-envtest]                             Operation: "Update",
[controller:test-integration-envtest]                             APIVersion: "apimanagement.azure.com/v1api20220801storage",
[controller:test-integration-envtest]                             Time: {
[controller:test-integration-envtest]                                 Time: 2023-12-19T14:09:57Z,
[controller:test-integration-envtest]                             },
[controller:test-integration-envtest]                             FieldsType: "FieldsV1",
[controller:test-integration-envtest]                             FieldsV1: {
[controller:test-integration-envtest]                                 Raw: "{\"f:metadata\":{\"f:annotations\":{\".\":{},\"f:serviceoperator.azure.com/latest-reconciled-generation\":{},\"f:serviceoperator.azure.com/resource-id\":{}},\"f:finalizers\":{\".\":{},\"v:\\\"serviceoperator.azure.com/finalizer\\\"\":{}},\"f:labels\":{\".\":{},\"f:serviceoperator.azure.com/owner-group-kind\":{},\"f:serviceoperator.azure.com/owner-name\":{}},\"f:ownerReferences\":{\".\":{},\"k:{\\\"uid\\\":\\\"3b626492-8cf8-4b59-bed8-5d8740d28a9a\\\"}\":{}}}}",
[controller:test-integration-envtest]                             },
[controller:test-integration-envtest]                             Subresource: "",
[controller:test-integration-envtest]                         },
[controller:test-integration-envtest]                         {
[controller:test-integration-envtest]                             Manager: "controllers.test",
[controller:test-integration-envtest]                             Operation: "Update",
[controller:test-integration-envtest]                             APIVersion: "apimanagement.azure.com/v1api20220801storage",
[controller:test-integration-envtest]                             Time: {
[controller:test-integration-envtest]                                 Time: 2023-12-19T14:17:33Z,
[controller:test-integration-envtest]                             },
[controller:test-integration-envtest]                             FieldsType: "FieldsV1",
[controller:test-integration-envtest]                             FieldsV1: {
[controller:test-integration-envtest]                                 Raw: "{\"f:status\":{\"f:approvalRequired\":{},\"f:conditions\":{},\"f:description\":{},\"f:displayName\":{},\"f:id\":{},\"f:name\":{},\"f:state\":{},\"f:subscriptionRequired\":{},\"f:type\":{}}}",
[controller:test-integration-envtest]                             },
[controller:test-integration-envtest]                             Subresource: "status",
[controller:test-integration-envtest]                         },
[controller:test-integration-envtest]                     ],
[controller:test-integration-envtest]                 },
[controller:test-integration-envtest]                 Spec: {
[controller:test-integration-envtest]                     ApprovalRequired: nil,
[controller:test-integration-envtest]                     AzureName: "asotestaachpc",
[controller:test-integration-envtest]                     Description: "A product for customer 1",
[controller:test-integration-envtest]                     DisplayName: "Customer 1",
[controller:test-integration-envtest]                     Owner: {
[controller:test-integration-envtest]                         Name: "asotestxrhkfo",
[controller:test-integration-envtest]                         ARMID: "",
[controller:test-integration-envtest]                     },
[controller:test-integration-envtest]                     State: nil,
[controller:test-integration-envtest]                     SubscriptionRequired: true,
[controller:test-integration-envtest]                     SubscriptionsLimit: nil,
[controller:test-integration-envtest]                     Terms: nil,
[controller:test-integration-envtest]                 },
[controller:test-integration-envtest]                 Status: {
[controller:test-integration-envtest]                     ApprovalRequired: false,
[controller:test-integration-envtest]                     Conditions: [
[controller:test-integration-envtest]                         {
[controller:test-integration-envtest]                             Type: "Ready",
[controller:test-integration-envtest]                             Status: "False",
[controller:test-integration-envtest]                             Severity: "Warning",
[controller:test-integration-envtest]                             LastTransitionTime: {
[controller:test-integration-envtest]                                 Time: 2023-12-19T14:17:33Z,
[controller:test-integration-envtest]                             },
[controller:test-integration-envtest]                             ObservedGeneration: 2,
[controller:test-integration-envtest]                             Reason: "Failed",
[controller:test-integration-envtest]                             Message: "failed to delete product \"asotestaachpc\": DELETE https://management.azure.com/subscriptions/xxxx/resourceGroups/asotest-rg-nnxzgr/providers/Microsoft.ApiManagement/service/asotestxrhkfo/products/asotestaachpc\n--------------------------------------------------------------------------------\nRESPONSE 404: 404 Not Found\nERROR CODE: ResourceGroupNotFound\n--------------------------------------------------------------------------------\n{\n  \"error\": {\n    \"code\": \"ResourceGroupNotFound\",\n    \"message\": \"Resource group 'asotest-rg-nnxzgr' could not be found.\"\n  }\n}\n--------------------------------------------------------------------------------\n",
[controller:test-integration-envtest]                         },
[controller:test-integration-envtest]                     ],
[controller:test-integration-envtest]                     Description: "A product for customer 1",
[controller:test-integration-envtest]                     DisplayName: "Customer 1",
[controller:test-integration-envtest]                     Id: "/subscriptions/xxxx/resourceGroups/asotest-rg-nnxzgr/providers/Microsoft.ApiManagement/service/asotestxrhkfo/products/asotestaachpc",
[controller:test-integration-envtest]                     Name: "asotestaachpc",
[controller:test-integration-envtest]                     State: "notPublished",
[controller:test-integration-envtest]                     SubscriptionRequired: true,
[controller:test-integration-envtest]                     SubscriptionsLimit: nil,
[controller:test-integration-envtest]                     Terms: nil,
[controller:test-integration-envtest]                     Type: "Microsoft.ApiManagement/service/products",
[controller:test-integration-envtest]                 },
[controller:test-integration-envtest]             }
[controller:test-integration-envtest]         to be deleted
[controller:test-integration-envtest] --- FAIL: Test_Samples_CreationAndDeletion (0.00s)
[controller:test-integration-envtest]     --- FAIL: Test_Samples_CreationAndDeletion/Test_Apimanagement_v1api20220801_CreationAndDeletion (3424.36s)
[controller:test-integration-envtest] FAIL
[controller:test-integration-envtest] FAIL      github.com/Azure/azure-service-operator/v2/internal/controllers 3425.551s
[controller:test-integration-envtest] FAIL

I think that the resource group is being deleted before apim; and because product is a child of the apim, it doesn't know that it's been deleted. Is there a way to force the delete order?

I notice that in

if sample.Owner().Kind == resolver.ResourceGroupKind {
we only set the owner if it's a resource group. Could/Should this be amended to allow for child resourcesof apim?

@matthchr matthchr added test Test refactoring related tasks and removed needs-triage 🔍 labels Jan 8, 2024
@matthchr matthchr added this to the v2.6.0 milestone Jan 8, 2024
@matthchr matthchr modified the milestones: v2.6.0, v2.7.0, v2.8.0 Feb 22, 2024
@theunrepentantgeek theunrepentantgeek modified the milestones: v2.8.0, v2.9.0 Apr 30, 2024
@matthchr matthchr modified the milestones: v2.9.0, v2.10.0 Jun 10, 2024
@matthchr matthchr modified the milestones: v2.10.0, v2.11.0 Aug 27, 2024
@matthchr matthchr modified the milestones: v2.11.0, v2.12.0 Oct 28, 2024
@theunrepentantgeek theunrepentantgeek modified the milestones: v2.12.0, v2.13.0 Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test Test refactoring related tasks
Projects
Development

No branches or pull requests

3 participants