-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pod and container overrides via attribute API tests (#22195)
* Pod and container overrides via attribute API tests --------- Signed-off-by: mdolhalo <mdolhalo@redhat.com> Co-authored-by: Maryna Dolhalova <mdolhalo@redhat.com>
- Loading branch information
Showing
9 changed files
with
177 additions
and
1,972 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
kind: DevWorkspace | ||
apiVersion: workspace.devfile.io/v1alpha2 | ||
metadata: | ||
name: web-terminal-container-overrides | ||
spec: | ||
started: true | ||
template: | ||
attributes: | ||
controller.devfile.io/storage-type: ephemeral | ||
projects: | ||
- name: web-nodejs-sample | ||
git: | ||
remotes: | ||
origin: "https://github.com/che-samples/web-nodejs-sample.git" | ||
components: | ||
- name: web-terminal | ||
attributes: | ||
container-overrides: {"resources":{"limits":{"nvidia.com/gpu":"1"}}} | ||
container: | ||
image: quay.io/wto/web-terminal-tooling:next | ||
args: | ||
- tail | ||
- '-f' | ||
- /dev/null | ||
cpuLimit: 400m | ||
cpuRequest: 100m | ||
memoryLimit: 256Mi | ||
memoryRequest: 128Mi |
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,37 @@ | ||
kind: DevWorkspace | ||
apiVersion: workspace.devfile.io/v1alpha2 | ||
metadata: | ||
name: code-latest-pod-overrides | ||
spec: | ||
started: true | ||
template: | ||
attributes: | ||
pod-overrides: | ||
metadata: | ||
annotations: | ||
io.openshift.userns: "true" | ||
io.kubernetes.cri-o.userns-mode: "auto:size=65536;map-to-root=true" # <-- user namespace | ||
openshift.io/scc: container-build | ||
spec: | ||
runtimeClassName: kata | ||
schedulerName: stork | ||
projects: | ||
- name: web-nodejs-sample | ||
git: | ||
remotes: | ||
origin: "https://github.com/che-samples/web-nodejs-sample.git" | ||
commands: | ||
- id: say-hello | ||
exec: | ||
component: che-code-runtime-description | ||
commandLine: echo "Hello from $(pwd)" | ||
workingDir: ${PROJECT_SOURCE}/app | ||
contributions: | ||
- name: che-code | ||
uri: https://eclipse-che.github.io/che-plugin-registry/main/v3/plugins/che-incubator/che-code/latest/devfile.yaml | ||
components: | ||
- name: che-code-runtime-description | ||
container: | ||
env: | ||
- name: CODE_HOST | ||
value: 0.0.0.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,37 @@ | ||
import { KubernetesCommandLineToolsExecutor } from '../../utils/KubernetesCommandLineToolsExecutor'; | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import YAML from 'yaml'; | ||
import { expect } from 'chai'; | ||
|
||
suite(`Test defining container overrides via attribute.`, async function (): Promise<void> { | ||
const pathToSampleFile: string = path.resolve('resources/container-overrides.yaml'); | ||
const workspaceName: string = YAML.parse(fs.readFileSync(pathToSampleFile, 'utf8')).metadata.name; | ||
const kubernetesCommandLineToolsExecutor: KubernetesCommandLineToolsExecutor = new KubernetesCommandLineToolsExecutor(workspaceName); | ||
|
||
suiteSetup('Login into OC client', function (): void { | ||
kubernetesCommandLineToolsExecutor.loginToOcp(); | ||
}); | ||
|
||
suiteTeardown('Delete DewWorkspace', function (): void { | ||
kubernetesCommandLineToolsExecutor.deleteDevWorkspace(); | ||
}); | ||
|
||
test('Apply container-overrides sample as DewWorkspace with OC client', function (): void { | ||
kubernetesCommandLineToolsExecutor.applyYamlConfigurationAsFile(pathToSampleFile); | ||
kubernetesCommandLineToolsExecutor.wait(5); | ||
}); | ||
|
||
test('Check that fields are overridden in the Deployment for DewWorkspace', function (): void { | ||
const devWorkspaceFullYamlOutput: Object = YAML.parse(kubernetesCommandLineToolsExecutor.getDevWorkspaceYamlConfiguration()); | ||
expect(devWorkspaceFullYamlOutput.spec.template.components[0].attributes['container-overrides']).eqls({ | ||
resources: { | ||
limits: { | ||
'nvidia.com/gpu': '1' | ||
} | ||
} | ||
}); | ||
}); | ||
}); | ||
|
||
|
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,43 @@ | ||
import { KubernetesCommandLineToolsExecutor } from '../../utils/KubernetesCommandLineToolsExecutor'; | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import YAML from 'yaml'; | ||
import { expect } from 'chai'; | ||
|
||
suite(`Test defining pod overrides via attribute.`, async function (): Promise<void> { | ||
const pathToSampleFile: string = path.resolve('resources/pod-overrides.yaml'); | ||
const workspaceName: string = YAML.parse(fs.readFileSync(pathToSampleFile, 'utf8')).metadata.name; | ||
const kubernetesCommandLineToolsExecutor: KubernetesCommandLineToolsExecutor = new KubernetesCommandLineToolsExecutor(workspaceName); | ||
|
||
suiteSetup('Login into OC client', function (): void { | ||
kubernetesCommandLineToolsExecutor.loginToOcp(); | ||
}); | ||
|
||
suiteTeardown('Delete DewWorkspace', function (): void { | ||
kubernetesCommandLineToolsExecutor.deleteDevWorkspace(); | ||
}); | ||
|
||
test('Apply pod-overrides sample as DewWorkspace with OC client', function (): void { | ||
kubernetesCommandLineToolsExecutor.applyYamlConfigurationAsFile(pathToSampleFile); | ||
kubernetesCommandLineToolsExecutor.wait(5); | ||
}); | ||
|
||
test('Check that fields are overridden in the Deployment for DewWorkspace', function (): void { | ||
const devWorkspaceFullYamlOutput: Object = YAML.parse(kubernetesCommandLineToolsExecutor.getDevWorkspaceYamlConfiguration()); | ||
expect(devWorkspaceFullYamlOutput.spec.template.attributes['pod-overrides']).eqls({ | ||
metadata: { | ||
annotations: { | ||
'io.kubernetes.cri-o.userns-mode': 'auto:size=65536;map-to-root=true', | ||
'io.openshift.userns': 'true', | ||
'openshift.io/scc': 'container-build' | ||
} | ||
}, | ||
spec: { | ||
runtimeClassName: 'kata', | ||
schedulerName: 'stork' | ||
} | ||
}); | ||
}); | ||
}); | ||
|
||
|
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
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