Skip to content

Commit

Permalink
Fixes after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
jkopriva committed Jan 28, 2025
1 parent d2fef44 commit 64a470c
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 40 deletions.
26 changes: 12 additions & 14 deletions src/utils/test.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,27 +326,25 @@ export async function waitForGitLabCIPipelineToFinish(gitLabProvider: GitLabProv
* @throws {Error} If the pipeline run cannot be found or if there is an error interacting with the Kubernetes API.
*
*/
export async function verifySyftImagePath(repositoryName: string, developmentNamespace: string):Promise<boolean> {
const kubeClient: Kubernetes = new Kubernetes();
export async function verifySyftImagePath(kubeClient: Kubernetes, repositoryName: string, developmentNamespace: string): Promise<boolean> {
const pipelineRun = await kubeClient.getPipelineRunByRepository(repositoryName, 'push');
var result: boolean = true
if (pipelineRun && pipelineRun.metadata && pipelineRun.metadata.name) {
let result = true;
if (pipelineRun?.metadata?.name) {
const doc: any = await kubeClient.pipelinerunfromName(pipelineRun.metadata.name, developmentNamespace);
const index = doc.spec.pipelineSpec.tasks.findIndex((item: { name: string; }) => item.name === "build-container");
const regex = new RegExp("registry.redhat.io/rh-syft-tech-preview/syft-rhel9", 'i');
const imageIndex: number = (doc.spec.pipelineSpec.tasks[index].taskSpec.steps.findIndex((item: { image: string; }) => regex.test(item.image)));
if (imageIndex !== -1) {
console.log("The image path found is " + doc.spec.pipelineSpec.tasks[index].taskSpec.steps[imageIndex].image);
}
else
{
}
else {
const podName: string = pipelineRun.metadata.name + '-build-container-pod';
// Read the yaml of the given pod
const podYaml = await kubeClient.getPodYaml(podName,developmentNamespace)
console.log(`The image path not found.The build-container pod yaml is : \n${podYaml}`)
result = false
}
const podYaml = await kubeClient.getPodYaml(podName, developmentNamespace);
console.log(`The image path not found.The build-container pod yaml is : \n${podYaml}`);
result = false;
}
}
return result
}
return result;

}
2 changes: 1 addition & 1 deletion tests/gpts/github/dotnet.actions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const stringOnRoute = 'Welcome';
const runDotNetBasicTests = () => {
const configuration = loadSoftwareTemplatesTestsGlobals();

if (configuration.templates.includes(dotNetTemplateName) && configuration.github && configuration.github.actions) {
if (configuration.templates.includes(dotNetTemplateName) && configuration.pipeline.github && configuration.github.actions) {
gitHubActionsBasicGoldenPathTemplateTests(dotNetTemplateName, stringOnRoute);
} else {
skipSuite(dotNetTemplateName);
Expand Down
2 changes: 1 addition & 1 deletion tests/gpts/github/go.actions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const stringOnRoute = 'Hello World!';
const runGolangBasicTests = () => {
const configuration = loadSoftwareTemplatesTestsGlobals();

if (configuration.templates.includes(golangTemplateName) && configuration.github && configuration.github.actions) {
if (configuration.templates.includes(golangTemplateName) && configuration.pipeline.github && configuration.github.actions) {
gitHubActionsBasicGoldenPathTemplateTests(golangTemplateName, stringOnRoute);
} else {
skipSuite(golangTemplateName);
Expand Down
2 changes: 1 addition & 1 deletion tests/gpts/github/nodejs.actions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const stringOnRoute = 'Hello from Node.js Starter Application!';
const runNodeJSBasicTests = () => {
const configuration = loadSoftwareTemplatesTestsGlobals();

if (configuration.templates.includes(nodejsTemplateName) && configuration.github && configuration.github.actions) {
if (configuration.templates.includes(nodejsTemplateName) && configuration.pipeline.github && configuration.github.actions) {
gitHubActionsBasicGoldenPathTemplateTests(nodejsTemplateName, stringOnRoute);
} else {
skipSuite(nodejsTemplateName);
Expand Down
2 changes: 1 addition & 1 deletion tests/gpts/github/python.actions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const stringOnRoute = 'Hello World!';
const runPythonBasicTests = () => {
const configuration = loadSoftwareTemplatesTestsGlobals();

if (configuration.templates.includes(pythonTemplateName) && configuration.github && configuration.github.actions) {
if (configuration.templates.includes(pythonTemplateName) && configuration.pipeline.github && configuration.github.actions) {

gitHubActionsBasicGoldenPathTemplateTests(pythonTemplateName, stringOnRoute);
} else {
Expand Down
2 changes: 1 addition & 1 deletion tests/gpts/github/quarkus.actions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const stringOnRoute = 'Congratulations, you have created a new Quarkus cloud ap
const runQuarkusBasicTests = () => {
const configuration = loadSoftwareTemplatesTestsGlobals();

if (configuration.templates.includes(quarkusTemplateName) && configuration.github && configuration.github.actions) {
if (configuration.templates.includes(quarkusTemplateName) && configuration.pipeline.github && configuration.github.actions) {
gitHubActionsBasicGoldenPathTemplateTests(quarkusTemplateName, stringOnRoute);
} else {
skipSuite(quarkusTemplateName);
Expand Down
2 changes: 1 addition & 1 deletion tests/gpts/github/springboot.actions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const stringOnRoute = 'Hello World!';
const runSpringBootBasicTests = () => {
const configuration = loadSoftwareTemplatesTestsGlobals();

if (configuration.templates.includes(springBootTemplateName) && configuration.github && configuration.github.actions) {
if (configuration.templates.includes(springBootTemplateName) && configuration.pipeline.github && configuration.github.actions) {
gitHubActionsBasicGoldenPathTemplateTests(springBootTemplateName, stringOnRoute);
} else {
skipSuite(springBootTemplateName);
Expand Down
2 changes: 1 addition & 1 deletion tests/gpts/github/test-config/github_advanced_scenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export const githubSoftwareTemplatesAdvancedScenarios = (gptTemplate: string) =>
* if failed to figure out the image path ,return pod yaml for reference
*/
it(`Check ${gptTemplate} pipelinerun yaml has the rh-syft image path`, async () => {
const result = await verifySyftImagePath(repositoryName, developmentNamespace);
const result = await verifySyftImagePath(kubeClient, repositoryName, developmentNamespace);
expect(result).toBe(true);
}, 900000);

Expand Down
16 changes: 1 addition & 15 deletions tests/gpts/github/test-config/github_positive_suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,22 +172,8 @@ export const gitHubBasicGoldenPathTemplateTests = (gptTemplate: string) => {
* if failed to figure out the image path ,return pod yaml for reference
*/
it(`Check ${gptTemplate} pipelinerun yaml has the rh-syft image path`, async () => {
<<<<<<< HEAD
const result = await verifySyftImagePath(repositoryName, developmentNamespace);
const result = await verifySyftImagePath(kubeClient, repositoryName, developmentNamespace);
expect(result).toBe(true);
=======
const pipelineRun = await kubeClient.getPipelineRunByRepository(repositoryName, 'push');
if (pipelineRun && pipelineRun.metadata && pipelineRun.metadata.name) {
const doc = await kubeClient.pipelinerunfromName(pipelineRun.metadata.name, developmentNamespace);
const index = await doc.spec.pipelineSpec.tasks.findIndex(item => item.name === "build-container");
const regex = new RegExp("registry.redhat.io/rh-syft-tech-preview/syft-rhel9", 'i');
const imageIndex = (await doc.spec.pipelineSpec.tasks[index].taskSpec.steps.findIndex(item => regex.test(item.image)));
if (imageIndex) {
console.log("The image path found is " + await doc.spec.pipelineSpec.tasks[index].taskSpec.steps[imageIndex].image);
}
expect(imageIndex).not.toBe(undefined);
}
>>>>>>> 0d39281 (Fixes after review + other fixes)
}, 900000);

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/gpts/gitlab/suites-config/gitlab_advanced_suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,15 @@ export const gitLabSoftwareTemplatesAdvancedScenarios = (softwareTemplateName: s
* if failed to figure out the image path ,return pod yaml for reference
*/
it(`Check ${softwareTemplateName} pipelinerun yaml has the rh-syft image path`, async () => {
const result = await verifySyftImagePath(repositoryName, developmentNamespace);
const result = await verifySyftImagePath(kubeClient, repositoryName, developmentNamespace);
expect(result).toBe(true);
}, 900000);

/**
* verify if the ACS Scan is successfully done from the logs of task steps
*/
it(`Check if ACS Scan is successful for ${softwareTemplateName}`, async ()=> {
const result = await checkIfAcsScanIsPass(repositoryName, developmentNamespace);
const result = await checkIfAcsScanIsPass(kubeClient, repositoryName, developmentNamespace);
expect(result).toBe(true);
console.log("Verified as ACS Scan is Successful");
}, 900000);
Expand Down
4 changes: 2 additions & 2 deletions tests/gpts/gitlab/suites-config/gitlab_positive_suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,15 @@ export const gitLabProviderBasicTests = (softwareTemplateName: string) => {
* if failed to figure out the image path ,return pod yaml for reference
*/
it(`Check ${softwareTemplateName} pipelinerun yaml has the rh-syft image path`, async () => {
const result = await verifySyftImagePath(repositoryName, developmentNamespace);
const result = await verifySyftImagePath(kubeClient, repositoryName, developmentNamespace);
expect(result).toBe(true);
}, 900000);

/**
* verify if the ACS Scan is successfully done from the logs of task steps
*/
it(`Check if ACS Scan is successful for ${softwareTemplateName}`, async () => {
const result = await checkIfAcsScanIsPass(repositoryName, developmentNamespace);
const result = await checkIfAcsScanIsPass(kubeClient, repositoryName, developmentNamespace);
expect(result).toBe(true);
console.log("Verified as ACS Scan is Successful");
}, 900000);
Expand Down

0 comments on commit 64a470c

Please sign in to comment.