Skip to content

Commit 8803ddf

Browse files
authored
Merge pull request #707 from snyk/chore/fix-os3-tests
chore: fix OpenShift 3 tests by using previously removed Pod generator
2 parents aa2ab5c + fee2e07 commit 8803ddf

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

test/helpers/kubectl.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,17 @@ export async function applyK8sYaml(pathToYamlDeployment: string, namespace?: str
8989

9090
export async function createPodFromImage(name: string, image: string, namespace: string) {
9191
console.log(`Letting Kubernetes decide how to manage image ${image} with name ${name}`);
92-
await exec(`./kubectl run ${name} --image=${image} -n ${namespace} -- sleep 999999999`);
92+
/**
93+
* HACK! The newest version of kubectl does not support generators. However, "OpenShift 3" tests run on K8s 1.11 which supports generators.
94+
* The default behaviour there is to create a Deployment, whereas new versions of kubectl create Pods.
95+
* We can't use the default behaviour for both OpenShift 3 and other tests, because we would get different results.
96+
* Hence we need to specifically select the Pod generator on OS3 but it would default to Pod on anything else.
97+
*/
98+
const generator =
99+
process.env['TEST_PLATFORM'] === 'openshift3'
100+
? '--generator=run-pod/v1'
101+
: '';
102+
await exec(`./kubectl run ${name} ${generator} --image=${image} -n ${namespace} -- sleep 999999999`);
93103
console.log(`Done Letting Kubernetes decide how to manage image ${image} with name ${name}`);
94104
}
95105

0 commit comments

Comments
 (0)