finos / git-proxy

Deploy custom push protections and policies on top of Git
https://git-proxy.finos.org
Apache License 2.0
87 stars 60 forks source link

e2e testing of git-proxy #394

Open coopernetes opened 6 months ago

coopernetes commented 6 months ago

We have a collection tests that validate git-proxy internals but nothing which runs in CI that validates changes acting as a client integrating with the git-proxy server(s). Tests should be run (at least on main or pre-release) to validate the server's behaviour end-to-end using a tool like serverspec or goss.

Another option would be a simple Docker-based test (package the app, run a container, run an HTTP-based test through it and shut down the container). container-structure-test is an option there. The below is an illustrative example - it's not a working test but should give an implementer a starting point.

schemaVersion: '2.0.0'
commandTests:
- name: 'verify git-proxy returns 200'
  setup:
    - ["npm", "install", "axios"]
    - ["npx", "--", "@finos/git-proxy"]
  command: 'node'
  args:
    - -e
    - |
      const axios = require("axios");
      axios.get("http://localhost:8080/api/v1/health")
        .then(function (response) {
          console.log(response.status);
        });
  expectedOutput: ["200"]
  exitCode: 0

Yup but I don't mean in a spec runner like jest or mocha where you have to manipulate the require cache.

It may be possible to setup jobs that simulate how the end user would test it in CI and just provide the env vars there to confirm by pinging the running services.

Originally posted by @lwhiteley in https://github.com/finos/git-proxy/issues/379#issuecomment-1879082571

marksmith388 commented 3 months ago

Hi, does this issue need to be looked at?

JamieSlome commented 3 months ago

@marksmith388 - for sure! Wanna tackle it? 😇

marksmith388 commented 3 months ago

Absolutely!

marksmith388 commented 3 months ago

I have a working solution using goss, what are my next steps?

JamieSlome commented 3 months ago

@marksmith388 - thanks for joining the community call today and apologies for missing your message from last week 🤗

@coopernetes - can we define a number of test requirements for this ticket to make sure @marksmith388 has something clear to work towards?

Of course appreciate you said you would both follow up on Slack but posting here to serve more as a small reminder in any case 💡