-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SLVSCODE-799 Add integration test for Helm chart
- Loading branch information
1 parent
5b50cd7
commit 0ce5812
Showing
9 changed files
with
132 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
apiVersion: v2 | ||
name: test-limit-ranges | ||
version: 0.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
apiVersion: v1 | ||
kind: LimitRange | ||
metadata: | ||
name: {{ .Values.name }} | ||
namespace: {{ .Values.namespace }} | ||
spec: | ||
limits: | ||
- type: Container | ||
default: | ||
memory: 512Mi | ||
cpu: 1 | ||
defaultRequest: | ||
memory: 512Mi | ||
cpu: 1 | ||
min: | ||
memory: 256Mi | ||
cpu: 0.5 | ||
max: | ||
memory: 1Gi | ||
cpu: 2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: example-pod | ||
namespace: {{ .Values.namespace }} | ||
spec: | ||
containers: | ||
- name: nginx-ns-compliant | ||
image: nginx:1.27.0 | ||
automountServiceAccountToken: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
name: example | ||
namespace: example-limit-range |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"folders": [ | ||
{ | ||
"path": "./sample-helm" | ||
} | ||
], | ||
"settings": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* -------------------------------------------------------------------------------------------- | ||
* SonarLint for VisualStudio Code | ||
* Copyright (C) 2017-2024 SonarSource SA | ||
* sonarlint@sonarsource.com | ||
* Licensed under the LGPLv3 License. See LICENSE.txt in the project root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
import * as assert from 'assert'; | ||
import * as path from 'path'; | ||
|
||
// You can import and use all API from the 'vscode' module | ||
// as well as import your extension to test it | ||
import * as vscode from 'vscode'; | ||
|
||
import { activateAndShowOutput, dumpLogOutput, waitForSonarLintDiagnostics } from '../common/util'; | ||
import { expect } from 'chai'; | ||
|
||
const sampleHelmFolderLocation = '../../../samples/sample-helm/'; | ||
|
||
suite('Helm Test Suite', () => { | ||
|
||
test('should report issues on Helm chart', async function () { | ||
const ext = vscode.extensions.getExtension('sonarsource.sonarlint-vscode')!; | ||
await ext.activate(); | ||
|
||
vscode.commands.executeCommand('SonarLint.ShowSonarLintOutput'); | ||
|
||
const fileUri = vscode.Uri.file(path.join(__dirname, sampleHelmFolderLocation, 'templates', 'pod.yaml')); | ||
const document = await vscode.workspace.openTextDocument(fileUri); | ||
await vscode.window.showTextDocument(document); | ||
|
||
const diags = await waitForSonarLintDiagnostics(fileUri); | ||
|
||
assert.strictEqual(diags.length, 2); | ||
assert.strictEqual(diags[0].message, "Specify a storage limit for this container."); | ||
assert.strictEqual(diags[1].message, "Specify a storage request for this container."); | ||
|
||
vscode.commands.executeCommand('workbench.action.closeActiveEditor'); | ||
|
||
}).timeout(60_000); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* -------------------------------------------------------------------------------------------- | ||
* SonarLint for VisualStudio Code | ||
* Copyright (C) 2017-2024 SonarSource SA | ||
* sonarlint@sonarsource.com | ||
* Licensed under the LGPLv3 License. See LICENSE.txt in the project root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
import * as glob from 'glob'; | ||
import * as Mocha from 'mocha'; | ||
import * as path from 'path'; | ||
|
||
export function run(testsRoot: string, cb: (error: any, failures?: number) => void): void { | ||
// Create the mocha test | ||
const mocha = new Mocha({ | ||
ui: 'tdd', | ||
reporter: 'mocha-multi-reporters', | ||
reporterOptions: { | ||
reporterEnabled: 'spec, xunit', | ||
xunitReporterOptions: { | ||
output: path.resolve(__dirname, '..', '..', 'helm-tests.xml') | ||
} | ||
}, | ||
color: true | ||
}); | ||
|
||
glob('**/**.test.js', { cwd: testsRoot }, (err, files) => { | ||
if (err) { | ||
return cb(err); | ||
} | ||
|
||
// Add files to the test suite | ||
files.forEach(f => mocha.addFile(path.resolve(testsRoot, f))); | ||
|
||
try { | ||
// Run the mocha test | ||
mocha.run(failures => { | ||
return cb(null, failures); | ||
}); | ||
} catch (runErr) { | ||
return cb(runErr); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters