mirror of
https://github.com/Azure/k8s-deploy.git
synced 2026-06-23 13:09:27 +08:00
e9693a7cdd
* First commit - made manifests for test deployments, made manifests for i tests for other deployment strategies * broke down blue/green * added latest tags to test manifests for new tags * remade tester * ready to test bgi * using all but first index of argv * careless error with dicts * added test to namespace * realized i was silencing error * indexing containers * keyerror * logging bc python errors are weird * expected still string * parsed args behaving weirdly * test seems to be working now, applying changes to other YAMLs now * blue/green ready to test * oops * oops * Added additional labels to check * hyphen * Added our annotations * lol * added our labels to services too * nonetype issue' * nonetype issue' * narrowing down parameter * fixed annotations issue with promote * adding debhug statement to figure out why services aren't getting annotations * this should fix annotations issue for service * not sure why this wasn't caught by intellisense * should be fixed with removing comma but adding logs in case * added linkerd install * verification * upgraded kubernetes version * removing crds * proxy option * Added smi extension * logging service * smi svcs also getting labeled now * matching ts type * not sure where stable service is going * remaining svc and deployment should match * keeping stable service and ts object * updated tests to reflect keeping ts object * no green svc after promote * duh * lol * canary work * canary test ready * logging for ing, filename for canary * changed ingress svc key and returning svc files from smi canary deployment * ts name * forgot about baseline in first deploy * * * * * smi canary should annotate, fixed cleanup * typescript issue plus percentage * forgot to type extra method * removed cleaned up objects from annotate list * logging because services aren't getting removed * moving to try/catch strategy of annotation since deletion can fail silently/with warnings * moved label to individual * removing canary service check after promote * pod ready for testing * set weights to 1000 * selectors * * * percentage * * * typing * mixed up pod and smi * fixed tests * prettier * forgot to remove canary * cleanup * Added oliver's feedback + more cleanup * ncc as dev dependency * npx * going back to global ncc install bc npm is being weird * prettier * removed unnecessary post step
76 lines
2.2 KiB
TypeScript
76 lines
2.2 KiB
TypeScript
import {getManifestObjects} from './blueGreenHelper'
|
|
import {BlueGreenDeployment} from '../../types/blueGreenTypes'
|
|
import {deployBlueGreen, deployBlueGreenIngress} from './deploy'
|
|
import * as routeTester from './route'
|
|
import {Kubectl} from '../../types/kubectl'
|
|
import {RouteStrategy} from '../../types/routeStrategy'
|
|
import * as TSutils from '../../utilities/trafficSplitUtils'
|
|
|
|
const ingressFilepath = ['test/unit/manifests/test-ingress-new.yml']
|
|
|
|
jest.mock('../../types/kubectl')
|
|
|
|
describe('deploy tests', () => {
|
|
let testObjects
|
|
beforeEach(() => {
|
|
//@ts-ignore
|
|
Kubectl.mockClear()
|
|
testObjects = getManifestObjects(ingressFilepath)
|
|
})
|
|
|
|
test('correctly determines deploy type and acts accordingly', async () => {
|
|
const kubectl = new Kubectl('')
|
|
const mockBgDeployment: BlueGreenDeployment = {
|
|
deployResult: {
|
|
execResult: {exitCode: 0, stderr: '', stdout: ''},
|
|
manifestFiles: []
|
|
},
|
|
objects: []
|
|
}
|
|
|
|
jest
|
|
.spyOn(routeTester, 'routeBlueGreenForDeploy')
|
|
.mockImplementation(() => Promise.resolve(mockBgDeployment))
|
|
jest
|
|
.spyOn(TSutils, 'getTrafficSplitAPIVersion')
|
|
.mockImplementation(() => Promise.resolve('v1alpha3'))
|
|
|
|
const ingressResult = await deployBlueGreen(
|
|
kubectl,
|
|
ingressFilepath,
|
|
RouteStrategy.INGRESS
|
|
)
|
|
|
|
expect(ingressResult.objects.length).toBe(2)
|
|
|
|
const result = await deployBlueGreen(
|
|
kubectl,
|
|
ingressFilepath,
|
|
RouteStrategy.SERVICE
|
|
)
|
|
|
|
expect(result.objects.length).toBe(2)
|
|
|
|
const smiResult = await deployBlueGreen(
|
|
kubectl,
|
|
ingressFilepath,
|
|
RouteStrategy.SMI
|
|
)
|
|
|
|
expect(smiResult.objects.length).toBe(6)
|
|
})
|
|
|
|
test('correctly deploys blue/green ingress', async () => {
|
|
const kc = new Kubectl('')
|
|
const value = await deployBlueGreenIngress(kc, ingressFilepath)
|
|
const nol = value.objects.map((obj) => {
|
|
if (obj.kind === 'Service') {
|
|
expect(obj.metadata.name).toBe('nginx-service-green')
|
|
}
|
|
if (obj.kind === 'Deployment') {
|
|
expect(obj.metadata.name).toBe('nginx-deployment-green')
|
|
}
|
|
})
|
|
})
|
|
})
|