11import { CoreV1Api , KubeConfig , AppsV1Api } from '@kubernetes/client-node' ;
2- import { exec } from 'child-process-promise' ;
32import setup = require( '../setup' ) ;
43import * as tap from 'tap' ;
54import { WorkloadKind } from '../../src/supervisor/types' ;
@@ -22,12 +21,6 @@ tap.tearDown(async() => {
2221 console . log ( 'Begin removing the snyk-monitor...' ) ;
2322 await setup . removeMonitor ( ) ;
2423 console . log ( 'Removed the snyk-monitor!' ) ;
25- console . log ( 'Begin removing local container registry...' ) ;
26- await setup . removeLocalContainerRegistry ( ) ;
27- console . log ( 'Removed local container registry' ) ;
28- console . log ( 'Begin removing "kind" network...' ) ;
29- await setup . removeUnusedKindNetwork ( ) ;
30- console . log ( 'Removed "kind" network' ) ;
3124} ) ;
3225
3326// Make sure this runs first -- deploying the monitor for the next tests
@@ -72,19 +65,6 @@ tap.test('snyk-monitor container started', async (t) => {
7265 console . log ( 'Done -- snyk-monitor exists!' ) ;
7366} ) ;
7467
75- tap . test ( 'create local container registry and push an image' , async ( t ) => {
76- console . log ( 'Creating local container registry...' ) ;
77- await exec ( 'docker run -d --restart=always -p "5000:5000" --name "kind-registry" registry:2' ) ;
78- await exec ( 'docker network connect "kind" "kind-registry"' ) ;
79-
80- console . log ( 'Pushing python:rc-buster image to the local registry' ) ;
81- //Note: this job takes a while and waitForJob() should be called before trying to access local registry image,
82- //to make sure it completed
83- await kubectl . applyK8sYaml ( './test/fixtures/insecure-registries/push-dockerhub-image-to-local-registry.yaml' ) ;
84-
85- t . pass ( 'successfully started a job to push image to a local registry' ) ;
86- } ) ;
87-
8868tap . test ( 'snyk-monitor sends data to kubernetes-upstream' , async ( t ) => {
8969 t . plan ( 7 ) ;
9070
@@ -246,46 +226,6 @@ tap.test('snyk-monitor pulls images from a private ECR and sends data to kuberne
246226 'snyk-monitor sent expected data to upstream in the expected timeframe' ) ;
247227} ) ;
248228
249- tap . test ( 'snyk-monitor pulls images from a local registry and sends data to kubernetes-upstream' , async ( t ) => {
250- t . plan ( 4 ) ;
251-
252- const deploymentName = 'python-local' ;
253- const namespace = 'services' ;
254- const clusterName = 'Default cluster' ;
255- const deploymentType = WorkloadKind . Deployment ;
256- const imageName = 'kind-registry:5000/python:rc-buster' ;
257-
258- await kubectl . waitForJob ( 'push-to-local-registry' , 'default' ) ;
259-
260- console . log ( 'Applying local registry workload...' ) ;
261- await kubectl . applyK8sYaml ( './test/fixtures/insecure-registries/python-local-deployment.yaml' ) ;
262-
263- console . log ( `Begin polling upstream for the expected kind-registry:5000 image with integration ID ${ integrationId } ...` ) ;
264-
265- const validatorFn : WorkloadLocatorValidator = ( workloads ) => {
266- return workloads !== undefined &&
267- workloads . find ( ( workload ) => workload . name === deploymentName &&
268- workload . type === WorkloadKind . Deployment ) !== undefined ;
269- } ;
270-
271- const testResult = await validateUpstreamStoredData (
272- validatorFn , `api/v2/workloads/${ integrationId } /${ clusterName } /${ namespace } ` ) ;
273- t . ok ( testResult , 'snyk-monitor sent expected data to upstream in the expected timeframe' ) ;
274-
275- const depGraphResult = await getUpstreamResponseBody (
276- `api/v1/dependency-graphs/${ integrationId } /${ clusterName } /${ namespace } /${ deploymentType } /${ deploymentName } ` ) ;
277-
278- t . ok ( 'dependencyGraphResults' in depGraphResult ,
279- 'expected dependencyGraphResults field to exist in /dependency-graphs response' ) ;
280-
281- /* Because of a bug in removeTagFromImage() func in src/scanner/images/index.ts,
282- which chops off everything after ':' from the image name, we store a wrong image name
283- and the result does not exist in the object referred below */
284- t . same ( depGraphResult . dependencyGraphResults [ imageName ] , null ,
285- 'expected result for image kind-registry:5000/python:rc-buster does not exist' ) ;
286- t . ok ( 'kind-registry' in depGraphResult . dependencyGraphResults , 'BUG: the full image name is not stored in kubernetes-upstream' ) ;
287- } ) ;
288-
289229tap . test ( 'snyk-monitor sends deleted workload to kubernetes-upstream' , async ( t ) => {
290230 // First ensure the deployment exists from the previous test
291231 const deploymentValidatorFn : WorkloadLocatorValidator = ( workloads ) => {
0 commit comments