How to verify upgrade is sucessfull

1 all webstore version 



 1 By Restore point records are available

2 By webstore lifecycle remarks 

3 By log to the Sana side and verifying the image is changed 



4 By log lens side and verify  



all versions should same 

VS Code Addons and Changes

Addon

1 CodeSpell checker : street side software

2 Cypress Snippets 



Show Reference count  

https://stackoverflow.com/questions/45490475/how-do-i-show-reference-count-in-visual-studio-code

Menu File → Preferences → Settings

Search  CodeLens.


Add Emoji 

click extension > type Emojisense

install 


Webstore Health Checks testing Update Active to Websotre table

 file:///C:/Users/s.kodagoda/Downloads/Recordings/WebstoreHealthChecks.webm

https://ismegroup-my.sharepoint.com/personal/k_samaraweera_sana-commerce_com/_layouts/15/stream.aspx?id=%2Fpersonal%2Fk%5Fsamaraweera%5Fsana%2Dcommerce%5Fcom%2FDocuments%2FRecordings%2FCall%20with%20Chamath%20and%201%20other%2D20230302%5F131457%2DMeeting%20Recording%2Emp4&ga=1

The Issues are mainly 2 types,
  1. In progress scenarios
  2. Fails scenarios

Configurations are following, 

currently set as 2hrs 
Sana.Platform.Portal > DbScripts > Local



Implementation > SharedServices > HealthCheckServices



When the issue occurred 1st time,

1 In progress 
eg: When do a webstore installation, if it keeps an 'in progress' state for 2 hrs (WebjobTaskWaitingDuration)


Email Send to the Platform Team Support Inbox Group.
1. Title: Webstore health check
2 Type of fail : Upgrade in progress
3 Webstore name 
4 Webstore id 


The job will run 15/30 min rounds. 

if no one attends to it within 30 min

 then 2nd 30min Will create a ticket in Azure support dashboard

 https://sanacommerce.visualstudio.com/Sana%20Platform/_dashboards/dashboard/2e484f6f-c1e0-4af3-87fa-ee646881715e 

 it will create a record in the WebstoreHealthChecks table


1.00pm  | Email Send 1 | TicketCreated 0

1.30pm  | Email Send 1 | TicketCreated 1


Sana.Platform.Core > ConstantModels > Enums > HealthCheckType.cs

HealthCheckTypes Enum (InProgress/ Failed)

0 InProgress WebJobCheck 

1 Failed WebjobCheck

2 InProgress BackupCronJobCheck

3 Failed BackupCronJobCheck

4 InProgress HttpMonitoringConfiguration

5 Failed HttpMonitoringConfiguration


WebJobCheck: eg Installation, Activation,Restart, SSL,OpenVPN

BackupCronJobCheck: eg Backup

HttpMonitoringConfiguration: eg Http Monitoring : 


Use for Testing 

select * from WebstoreHealthChecks
select * from WebStoreStates
update WebStores set WebStoreStateId =10 where WebStoreId = 1000
update WebStores set WebStoreStateId =9, ModifiedDateTime = '2023-03-02 05:34:27.867' where WebStoreId = 1000

 update [dbo].[WebstoreHealthChecks]   set [IsTicketCreated] =0 where WebStoreId ='57055'


Table column Explain

 [Id]: unique id
,[WebStoreId]
,[HealthCheckType] : HealthCheckType enum 
,[IsEmailSent]: is the email sent or not 
,[IsTicketCreated] is the ticket
,[Description]: Email and ticked desc
,[WebstoreLifeCycleId]: Get the Last Stause of webstore
,[CheckExecutionDateTime]: after failed time which fail to check identify if (ticket Created date) 
,[FailureOccuredTime]: Issue Failed time  
,[CreatedUser]
,[CreatedDateTime]
,[ModifiedUser]
,[ModifiedDateTime]


to check the Fail scenarios update the webstore as follows  

* update WebStores set WebStoreStateId =10 (uninstall inprogress)

  where WebStoreId = 1000

  

to check inprogress/stuck senarios update webstore as folowing     

* update WebStores set WebStoreStateId =9, 

  ModifiedDateTime = '2023-03-02 05:34:27.867' (set -2hr or old) ex: now:10pm set to 8pm 

  where WebStoreId = 1000 

  

  Now job will take 2hr old data

  can change the config table [CloudConfigs] Table

  or Sana,Platform.Portal > Local > CloudConfigs.sql

SELECT * FROM [dbo].[CloudConfigs] where [key] = 'WebjobTaskWaitingDuration'


?? Better to have Ticket ID in table 



DECLARE @WebStoreStateId INT;

DECLARE @WebStoreId INT;

DECLARE @LogType INT;


DECLARE @Date DATETIME

SET @Date = GETDATE()


SET @WebStoreStateId = 26;

SET @WebStoreId = 58719

SET @LogType =5


 

--1 Update webstore as fail 

Update WebStores set WebStoreStateId =@WebStoreStateId where WebStoreId = @WebStoreId


--2 Insert life cycle  

INSERT INTO [dbo].[WebstoreLifeCycles]

           ([WebStoreId]

           ,[WebStoreStateId]

           ,[User]

           ,[Comment],[LifeCycleDate]

           )

     VALUES

           (@WebStoreId

           ,@WebStoreStateId,

           '400',

           'Failed Applied by Manualy',

            @Date)


--3. Add WebStoreLogs to attach error log


INSERT INTO [dbo].[WebStoreLogs]

           ([WebStoreId]

           ,[LogMessage]

           ,[LogType]

           ,[IsExceptionOccured]

           ,[LogDateTime])

     VALUES

           (

           @WebStoreId

           ,'<ArrayOfSanaCloudLog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

  <SanaCloudLog>

<LogMessage>Job Failed Applied by Manually</LogMessage>

  </SanaCloudLog>

</ArrayOfSanaCloudLog>

'

           ,@LogType

           ,1

           ,@Date) 



--------------------------------------------------------------------

SELECT * from WebStores where WebStoreId = 58719

SELECT * from  [dbo].[WebstoreLifeCycles] where WebStoreId = 58719

SELECT * FROM [dbo].[WebstoreHealthChecks] where WebStoreId = 58719

select * from [dbo].[WebStoreLogs] where WebStoreId = 58719



To Run web job manually

 https://portal.azure.com/#home

go tot > App services

Search webjob


Click the Webjobs

Search by browser (ctr + F)   

WebstoreHealthCheck

Click run 



---------------------------------------------------------------------------


-- UPDATE HELTHCHECK/WEBSTORE TABLES
DECLARE @WebStoreStateId INT;
DECLARE @WebStoreId INT;
DECLARE @LogType INT;
DECLARE @Date DATETIME
SET @Date = DATEADD(hour, 2, GETDATE())
DECLARE @previousDate DATETIME
SET @previousDate = DATEADD(hour, -3, GETDATE())

-- VARIABLES
SET @WebStoreStateId = 70;
SET @WebStoreId = 59038
SET @LogType =5

 
--1 UPDATE WEBSTORE AS FAIL
--Update WebStores set WebStoreStateId =@WebStoreStateId where WebStoreId = @WebStoreId

--1 UPDATE WEBSTORE AS INPROGRESS
 update WebStores set WebStoreStateId =@WebStoreStateId,
      ModifiedDateTime = @previousDate
      where WebStoreId = @WebStoreId


--2 INSERT LIFE CYCLE
INSERT INTO [dbo].[WebstoreLifeCycles]
           ([WebStoreId]
           ,[WebStoreStateId]
           ,[User]
           ,[Comment],[LifeCycleDate]
           )
     VALUES
           (@WebStoreId
           ,@WebStoreStateId,
           '400',
           'Change Manualy Applied',
            @Date)

--3.ADD WEBSTORELOGS TO ATTACH ERROR LOG
INSERT INTO [dbo].[WebStoreLogs]
           ([WebStoreId]
           ,[LogMessage]
           ,[LogType]
           ,[IsExceptionOccured]
           ,[LogDateTime])
     VALUES
           (
           @WebStoreId
           ,'<ArrayOfSanaCloudLog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <SanaCloudLog>
        <LogMessage>Job Failed Applied by Manually</LogMessage>
        </SanaCloudLog>
      </ArrayOfSanaCloudLog>
      '
           ,@LogType
           ,1
           ,@Date


--------------------------------------------------------------------

--select GETDATE()
--select DATEADD(hour, 2, GETDATE())
--select DATEADD(hour, -3, GETDATE())


-- RESET WEBSTORE TO ACTIVE
DECLARE @WebStoreStateId INT;
DECLARE @WebStoreId INT;
DECLARE @LogType INT;
DECLARE @Date DATETIME
SET @Date = DATEADD(hour, 2, GETDATE())
DECLARE @previousDate DATETIME
SET @previousDate = DATEADD(hour, -3, GETDATE())

-- VARIABLES
SET @WebStoreStateId = 2;
SET @WebStoreId = 59040
SET @LogType =5

 
--1 UPDATE WEBSTORE AS FAIL
Update WebStores set WebStoreStateId =@WebStoreStateId where WebStoreId = @WebStoreId


--2 INSERT lIFE CYCLE
INSERT INTO [dbo].[WebstoreLifeCycles]
           ([WebStoreId]
           ,[WebStoreStateId]
           ,[User]
           ,[Comment],[LifeCycleDate]
           )
     VALUES
           (@WebStoreId
           ,@WebStoreStateId,
           '400',
           'Activate Manualy Applied',
            @Date)

--update [dbo].[WebstoreLifeCycles] set [LifeCycleDate] = DATEADD(hour, 2, GETDATE())
--where [WebstoreLifeCycleId]= 160890














 

























Application insight

 


Click enable  


the schedule will run after midnight 

else update time from DB

  update [dbo].[WebstoreApplicationInsights] set [ScheduledDate] = '2023-01-03 00:00:00.000'

  where [WebstoreId] = 58671


After install 



To verify 

1 https://portal.azure.com/#home > 

https://portal.azure.com/#view/HubsExtension/BrowseResource/resourceType/microsoft.insights%2Fcomponents

2 copy app name from overview page 


3 search the name 

4. application insight

5. uninstall , should remove 

move to region 

























Cypress with Type script

https://testautomationu.applitools.com/cypress-with-typescript/chapter1.html

//user can define own types on type script
type EvenNumbers = 2|4|6

export  const add = (a: number , b :EvenNumbers) =>{
    return a+b
}

add(21,2,4)


install type script Globerly

> npm i typescript -g

To view all different commands and flages 

> tsc 

it will convert TS file to JS 


Cypress Auto-completion use following

/// <reference types="cypress"/>

but when using type script by adding default type script config file 

references will help auto load 

tsconfig.ts 

{
    "compilerOptions": {
      "target": "es5",
      "lib": ["es5", "dom"],
      "types": ["cypress", "node"],
      "resolveJsonModule": true
    },
    "include": ["**/*.ts"]
}



custom commands on Type script and add header description


export { } // use to remove higlight errors
declare global {
    namespace Cypress{
        interface Chainable{
            findLocator2(input:string):
            Chainable<any>
        }

    }
}

Cypress.Commands.add('findLocator2',(locator:string)=>{    
           
Cypress.log({
    displayName:'getByPlaceholder',
    message:locator,
    consoleProps(){
        return {
            selector: locator
        }
    }
})

    return cy.get('${locator}',{
        log:false
    })
})

Add example 

/**
             * Get a dom value path
             * @param input locator value
             * @example <---------------
             * //this command
             * cy.findlocator('your locator path')
             */

function is not use anymore/ obsalete

@deprecated


When having error on XPath with type script


1 add this in your tsconfig.json file.

"cypress-xpath"

{
    "compilerOptions": {
      "target": "es5",
      "lib": ["es5", "dom"],
      "types": ["cypress", "node","cypress-xpath"], //<------------
      "resolveJsonModule": true
    },
    "include": ["**/*.ts", "support/commands.js"]
}

import "cypress-xpath" to command.ts file

import "cypress-xpath"



Set specific value without using constent values

Create file helper\Typing\Placeholders.ts

export type Attribute = 'attr'|'src'|'title'

export type Placeholder = 'placeholder'|'test'


create method using above mention types

InvokeAttrShould(locator:string,attr:Placeholders,placeholder:string,contain:string,message:string){
       
        cy.get(locator).invoke(attr,placeholder)
        .should(contain,message)              
    }

when use it,only able to type given values

I.InvokeAttrShould(partner.IPAddresses,
'attr', //<----------------------------
'placeholder',// <---------------------------
        'contain',
        partnerData.IPAddressesPlaceholder)      



Change class to models

https://stackoverflow.com/questions/32805559/typescript-es6-import-module-file-is-not-a-module-error

// test.js - exporting es6

export module App {
  export class SomeClass {
    getName(): string {
      return 'name';
    }
  }
  export class OtherClass {
    getName(): string {
      return 'name';
    }
  }
}

And now we can import it with these thre ways:

import * as app1 from "./test";
import app2 = require("./test");
import {App} from "./test";

And we can consume imported stuff like this:

var a1: app1.App.SomeClass  = new app1.App.SomeClass();
var a2: app1.App.OtherClass = new app1.App.OtherClass();

var b1: app2.App.SomeClass  = new app2.App.SomeClass();
var b2: app2.App.OtherClass = new app2.App.OtherClass();

var c1: App.SomeClass  = new App.SomeClass();
var c2: App.OtherClass = new App.OtherClass();

and call the method to see it in action:

console.log(a1.getName())
console.log(a2.getName())
console.log(b1.getName())
console.log(b2.getName())
console.log(c1.getName())
console.log(c2.getName())


change json imports to 


old (it will not read data inside)

const HomePage = require('../../../pageObjects/Home/homePages.json')

New 

import HomePage = require('../../../pageObjects/Home/homePages.json');


















 

Delete table before install

 DECLARE @TestId AS VARCHAR(100)='58311'

  delete FROM [SanaPlatform].[dbo].[WebStoreAzureSettings]  where [WebStoreId] =@TestId

  delete FROM [SanaPlatform].[dbo].[WebstoreDatabaseUsers]  where [WebStoreId] =@TestId

  delete FROM [SanaPlatform].[dbo].[WebStoreDomains]  where [WebStoreId] =@TestId

  delete  FROM [SanaPlatform].[dbo].[WebstoreEmailSettings]  where [WebStoreId] =@TestId

  delete FROM [SanaPlatform].[dbo].[WebstoreInfoEmailSentLogs]  where [WebStoreId] =@TestId

  delete  FROM [SanaPlatform].[dbo].[WebstoreLifeCycles]   where [WebStoreId] =@TestId

  delete FROM [SanaPlatform].[dbo].[WebstoreMaintenanceEmails]  where [WebStoreId] =@TestId

  delete FROM [SanaPlatform].[dbo].[WebStores] where [WebStoreId] = @TestId

Webstore with azure side settings | Create project Underermined

Webstore with azure side settings

 [dbo].[WebStoreAzureSettings]


can get webstore installation profile id created by cluster wise

make Hard coded Partner called: "Sana team undetermined"

Create projects called: Undetermined 

If the partner is not sure then create as undetermined.

Partner ==> WebstoreInstallationProfiles ==> WebStoreAzureSettings