]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: add snmp-gateway service e2e tests 44977/head
authorAvan Thakkar <athakkar@redhat.com>
Tue, 1 Feb 2022 13:02:42 +0000 (18:32 +0530)
committerAvan Thakkar <athakkar@redhat.com>
Thu, 10 Feb 2022 12:55:40 +0000 (18:25 +0530)
Fixes: https://tracker.ceph.com/issues/54034
Signed-off-by: Avan Thakkar <athakkar@redhat.com>
(cherry picked from commit 76dcf6a881f343bb3d93259701e57ccb572f94e8)

src/pybind/mgr/dashboard/frontend/cypress/integration/cluster/services.po.ts
src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/workflow/09-services.e2e-spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/service-form/service-form.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/service-form/service-form.component.ts

index 07bd3b58b8b7ef01116effcc4992fe9311117641..6987b6f20f52e91654033a69e7f1b37f6cd577f0 100644 (file)
@@ -37,7 +37,7 @@ export class ServicesPageHelper extends PageHelper {
     });
   }
 
-  addService(serviceType: string, exist?: boolean, count = '1') {
+  addService(serviceType: string, exist?: boolean, count = '1', snmpVersion?: string) {
     cy.get(`${this.pages.create.id}`).within(() => {
       this.selectServiceType(serviceType);
       switch (serviceType) {
@@ -59,13 +59,33 @@ export class ServicesPageHelper extends PageHelper {
           cy.get('#count').type(count);
           break;
 
+        case 'snmp-gateway':
+          this.selectOption('snmp_version', snmpVersion);
+          cy.get('#snmp_destination').type('192.168.0.1:8443');
+          if (snmpVersion === 'V2c') {
+            cy.get('#snmp_community').type('public');
+          } else {
+            cy.get('#engine_id').type('800C53F00000');
+            this.selectOption('auth_protocol', 'SHA');
+            this.selectOption('privacy_protocol', 'DES');
+
+            // Credentials
+            cy.get('#snmp_v3_auth_username').type('test');
+            cy.get('#snmp_v3_auth_password').type('testpass');
+            cy.get('#snmp_v3_priv_password').type('testencrypt');
+          }
+          break;
+
         default:
           cy.get('#service_id').type('test');
           cy.get('#count').type(count);
           break;
       }
-
-      cy.get('cd-submit-button').click();
+      if (serviceType === 'snmp-gateway') {
+        cy.get('cd-submit-button').dblclick();
+      } else {
+        cy.get('cd-submit-button').click();
+      }
     });
     if (exist) {
       cy.get('#service_id').should('have.class', 'ng-invalid');
index 9b49c75aca6a35498b641b7a67aff758d29b279a..0c1eecb2b8a52c81d3923fdba6ffbfb10cd0cb87 100644 (file)
@@ -24,4 +24,30 @@ describe('Services page', () => {
 
     services.deleteService('mds.test');
   });
+
+  it('should create and delete snmp-gateway service with version V2c', () => {
+    services.navigateTo('create');
+    services.addService('snmp-gateway', false, '1', 'V2c');
+    services.checkExist('snmp-gateway', true);
+
+    services.clickServiceTab('snmp-gateway', 'Details');
+    cy.get('cd-service-details').within(() => {
+      services.checkServiceStatus('snmp-gateway');
+    });
+
+    services.deleteService('snmp-gateway');
+  });
+
+  it('should create and delete snmp-gateway service with version V3', () => {
+    services.navigateTo('create');
+    services.addService('snmp-gateway', false, '1', 'V3');
+    services.checkExist('snmp-gateway', true);
+
+    services.clickServiceTab('snmp-gateway', 'Details');
+    cy.get('cd-service-details').within(() => {
+      services.checkServiceStatus('snmp-gateway');
+    });
+
+    services.deleteService('snmp-gateway');
+  });
 });
index 8e4623be367f1a488742700b08f12a68b1699e33..e1e8317e9bf6543262e34a7740f5f030d07c9641 100644 (file)
           <!-- Destination -->
           <div class="form-group row">
             <label class="cd-col-form-label required"
-                   [ngClass]="{'required': ['snmp-gateway'].includes(serviceForm.controls.service_type.value)}"
                    for="snmp_destination">
               <span i18n>Destination</span>
               <cd-helper>
           <div class="form-group row"
                *ngIf="serviceForm.controls.snmp_version.value === 'V3'">
             <label class="cd-col-form-label required"
-                   [ngClass]="{'required': ['snmp-gateway'].includes(serviceForm.controls.service_type.value)}"
                    for="engine_id">
               <span i18n>Engine Id</span>
               <cd-helper>
             <div class="form-group row"
                  *ngIf="serviceForm.controls.snmp_version.value === 'V2c'">
               <label class="cd-col-form-label required"
-                     [ngClass]="{'required': ['snmp-gateway'].includes(serviceForm.controls.service_type.value)}"
                      for="snmp_community">
                 <span i18n>SNMP Community</span>
               </label>
             <div class="form-group row"
                  *ngIf="serviceForm.controls.snmp_version.value === 'V3'">
               <label class="cd-col-form-label required"
-                     [ngClass]="{'required': ['snmp-gateway'].includes(serviceForm.controls.service_type.value)}"
                      for="snmp_v3_auth_username">
                 <span i18n>Username</span>
               </label>
             <div class="form-group row"
                  *ngIf="serviceForm.controls.snmp_version.value === 'V3'">
               <label class="cd-col-form-label required"
-                     [ngClass]="{'required': ['snmp-gateway'].includes(serviceForm.controls.service_type.value)}"
                      for="snmp_v3_auth_password">
                 <span i18n>Password</span>
               </label>
             <div class="form-group row"
                  *ngIf="serviceForm.controls.snmp_version.value === 'V3' && serviceForm.controls.privacy_protocol.value !== null && serviceForm.controls.privacy_protocol.value !== undefined">
               <label class="cd-col-form-label required"
-                     [ngClass]="{'required': ['snmp-gateway'].includes(serviceForm.controls.service_type.value)}"
                      for="snmp_v3_priv_password">
                 <span i18n>Encryption</span>
               </label>
index 517f05597ad092a037c9fd5dfe68cc1ccb0d3b3c..06fe53bae056d194a4e08ae458c4cc73b36e093b 100644 (file)
@@ -215,7 +215,15 @@ export class ServiceFormComponent extends CdForm implements OnInit {
         ]
       ],
       // snmp-gateway
-      snmp_version: [null, [Validators.required]],
+      snmp_version: [
+        null,
+        [
+          CdValidators.requiredIf({
+            service_type: 'snmp-gateway',
+            unmanaged: false
+          })
+        ]
+      ],
       snmp_destination: [
         null,
         {
@@ -251,7 +259,15 @@ export class ServiceFormComponent extends CdForm implements OnInit {
           })
         ]
       ],
-      privacy_protocol: [null],
+      privacy_protocol: [
+        null,
+        [
+          CdValidators.requiredIf({
+            service_type: 'snmp-gateway',
+            unmanaged: false
+          })
+        ]
+      ],
       snmp_community: [
         null,
         [