Commit graph

47 commits

Author SHA1 Message Date
Gabriel Adrian Samfira
f5992b7344 Allow using LXD image mirror
This change allows GARM tests to use a mirror for LXD images, allowing
for faster image downloads.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-08-14 19:44:23 +00:00
Gabriel Adrian Samfira
d5cbc5bfb2 Switch to self hosted runner
GitHub hosted runners seem to have issues with LXD containers.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-08-12 21:15:47 +00:00
Fabian Fulga
9d4c0a953c Adding garm test suite 2024-06-17 12:36:00 +03:00
Gabriel Adrian Samfira
402c8b70e2 Use different creds than the default ones
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-04-27 18:55:30 +00:00
Gabriel Adrian Samfira
87943db62c Fix lint and add integration tests logging
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-04-27 18:10:03 +00:00
Gabriel Adrian Samfira
0128f59344 Add some credentials e2e tests
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-04-25 17:38:24 +00:00
Gabriel Adrian Samfira
39a5e14eb1 Add more e2e GH endpoint tests
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-04-25 07:45:09 +00:00
Gabriel Adrian Samfira
ccf51053b5 Add github endpoint operations e2e test
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-04-24 14:54:29 +00:00
Gabriel Adrian Samfira
c2b974dfa0 Create clone creds for repo update
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-04-24 11:39:20 +00:00
Gabriel Adrian Samfira
8b5584f083 Add some e2e boilerplate
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-04-24 11:21:27 +00:00
Gabriel Adrian Samfira
9a6770c3a3 Allow bypassing Unauthorized error when deleting runner
This change allows users to bypass GitHub Unauthorized errors when removing
github runners. This means that removing runners will now be possible even
if the pool manager is stopped.

There is a new flag added to the runner rm command and to the API that
tells GARM to bypass pool being stopped and any 401 error returned by
GitHub.

This means you will be able to remove the runners from garm and your
provider, but will mean that the runner will still exist in github as
"offline" if the credentials are not updated or the runner manually removed.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-03-10 15:21:39 +00:00
Gabriel Adrian Samfira
b5e3552776 Fix variable name
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-02-26 19:04:48 +00:00
Gabriel Adrian Samfira
111b93f062 simplify integration test job
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-02-26 17:58:04 +00:00
Gabriel Adrian Samfira
43b3db5c0c Use user service
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-02-26 17:41:04 +00:00
Gabriel Adrian Samfira
a17cd577e0 Add script and service template
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-02-26 16:48:22 +00:00
Gabriel Adrian Samfira
00fd7c1204 Switch to apg for password gen
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-02-26 16:44:47 +00:00
Gabriel Adrian Samfira
b4dde6a839 Allow integration tests to run locally
This change adds the ability to run integration tests locally. You will
still need a number of environment variables set, including a github PAT.

Details on how to use this will come in a subsequent commit.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-02-26 16:28:07 +00:00
Mario Constanti
c137f9b662 fix: gocritic linter findings
Signed-off-by: Mario Constanti <mario.constanti@mercedes-benz.com>
2024-02-22 15:06:53 +01:00
Mario Constanti
09e25ca8b1 fix: gosec linter finding - memory aliasing
G601: Implicit memory aliasing in for loop

Signed-off-by: Mario Constanti <mario.constanti@mercedes-benz.com>
2024-02-22 15:06:53 +01:00
Mario Constanti
e664639e98 fix: var-declaration linter findings
Signed-off-by: Mario Constanti <mario.constanti@mercedes-benz.com>
2024-02-22 15:06:53 +01:00
Mario Constanti
3b9f8b555b fix: var-naming linter findings
Signed-off-by: Mario Constanti <mario.constanti@mercedes-benz.com>
2024-02-22 15:06:53 +01:00
Mario Constanti
bd0b27ab10 fix: gci section warnings
Signed-off-by: Mario Constanti <mario.constanti@mercedes-benz.com>
2024-02-22 15:06:53 +01:00
Gabriel Adrian Samfira
e441b6ce89 Switch to log/slog
This change switches GARM to the new structured logging standard
library. This will allow us to set log levels and reduce some of
the log spam.

Given that we introduced new knobs to tweak logging, the number of
config options for logging now warrants it's own section.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2024-01-05 23:46:40 +00:00
Gabriel Adrian Samfira
912371cf57 Create needed folders before use
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-12-18 16:50:02 +00:00
Gabriel Adrian Samfira
6c7c5a913f Define variable before use
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-12-18 16:43:30 +00:00
Gabriel Adrian Samfira
5d596aa94c Copy provider config in garm folder
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-12-18 16:39:30 +00:00
Gabriel Adrian Samfira
e6eed93546 Export required variables
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-12-18 16:31:52 +00:00
Gabriel Adrian Samfira
0dd4f38691 Update go-github
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-12-18 16:20:44 +00:00
Gabriel Adrian Samfira
affb56f9a0 Remove the LXD internal provider
Canonical have relicensed the LXD project to AGPLv3. This means that we can
no longer update the go LXD client without re-licensing GARM as AGPLv3. This
is not desirable or possible.

The existing code seems to be Apache 2.0 and all code that has already been
contributed seems to stay as Apache 2.0, but new contributions from Canonical
employees will be AGPLv3.

We cannot risc including AGPLv3 code now or in the future, so we will separate
the LXD provider into its own project which can be AGPLv3. GARM will simply
execute the external provider.

If the client code of LXD will ever be split from the main project and re-licensed
as Apache 2.0 or a compatible license, we will reconsider adding it back as a
native provider. Although in the long run, I believe external providers will
be the only option as they are easier to write, easier to maintain and safer to
ship (a bug in the provider does not crash GARM itself).

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-12-18 12:16:48 +00:00
Gabriel Adrian Samfira
b9c7c93f7f
Fix linting issues
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-11-21 20:52:40 +02:00
Mihaela Balutoiu
c563ace750 Add integration tests for test external provider
Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2023-11-06 13:03:25 +02:00
Gabriel Adrian Samfira
fc77a4b735 Update go-github and garm-provider-common
We need to abstract away the tools struct and not have garm-provider-common
depend on go-github just for that one struct. It makes it hard to update
go-github without updating garm-provider-common first and then all the rest
of the providers.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-09-24 07:56:56 +00:00
Mihaela Balutoiu
f9c3f30ae4 Cleaning up leftover Github webhooks for org/repo
Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2023-08-29 11:10:11 +03:00
Gabriel Adrian Samfira
d700b790ac Update garm-provider-common and go-github
* Updates the garm-provider-common and go-github packages.
* Update sqlToParamsInstance to return an error when unmarshaling

This change is needed to pull in the new Seal/Unseal functions in common.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-08-28 08:13:44 +00:00
Ionut Balutoiu
93d290df47 Optimize waitPoolRunningIdleInstances func
Instead of asking for all the GARM instances from the API, and then
filtering them by `poolID`, we can ask the API to return only the
instances that are in the `poolID` pool.

Therefore, we only need to count the instances that are running and idle.

Signed-off-by: Ionut Balutoiu <ibalutoiu@cloudbasesolutions.com>
2023-08-25 17:14:11 +03:00
Ionut Balutoiu
4e3ad41c0b Fix waitPoolRunningIdleInstances function
The variable `runningIdleCount` would get incremented for instances
on every pool, instead of only for the pool we are interested in.
This change fixes this.

Also, adjust the logging message when error occurs in this timeout
exceeded scenario.

Signed-off-by: Ionut Balutoiu <ibalutoiu@cloudbasesolutions.com>
2023-08-24 16:12:00 +03:00
Ionut Balutoiu
318bc52b57 Refactor integration E2E tests
* General cleanup of the integration tests Golang code. Move the
  `e2e.go` codebase into its own package and separate files.
* Reduce the overall log spam from the integration tests output.
* Add final GitHub workflow step that stops GARM server, and does the
  GitHub cleanup of any orphaned resources.
* Add `TODO` to implement cleanup of the orphaned GitHub webhooks.
  This is useful, if the uninstall of the webhooks failed.
* Add `TODO` for extra missing checks on the GitHub webhooks
  install / uninstall logic.

Signed-off-by: Ionut Balutoiu <ibalutoiu@cloudbasesolutions.com>
2023-08-24 15:22:46 +03:00
Mihaela Balutoiu
300ad110f0 Add webhooks integration tests
Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2023-08-22 21:23:56 +03:00
Mihaela Balutoiu
6b77979ab5 Fix timeout logic
Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2023-08-14 14:35:07 +03:00
Mihaela Balutoiu
475cc6425b Add log orgPool/repoPool details on timeout exceeded
Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2023-08-14 11:45:10 +03:00
Mihaela Balutoiu
aa956ae939 Cleaning up leftover runners for org/repo
Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2023-08-09 16:31:50 +03:00
Mihaela Balutoiu
191d44fb3f Log org/repo details on timeout exceeded
Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2023-08-07 12:37:09 +03:00
Mihaela Balutoiu
97d1202225 Log instance details on timeout exceeded
Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2023-08-04 23:28:26 +03:00
Mihaela Balutoiu
cf0c1f188b Fix org_name/repo_name
Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2023-08-02 20:24:44 +03:00
Gabriel Adrian Samfira
d02292bd1a
Fix config dir location
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-08-02 17:29:08 +03:00
Gabriel Adrian Samfira
d2ffa22204
Set up ngrok and use sudo
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-08-02 17:14:27 +03:00
Mihaela Balutoiu
6f69f942cf Add GitHub workflow for integration tests
Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
2023-08-02 16:11:55 +03:00