Skip to content

Repository maintenance: CI and testing improvements #310

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jan 1, 2025

Conversation

xBlaz3kx
Copy link
Contributor

Proposed changes

  • Added local docker compose for unit and integration testing
  • Improved the CI pipeline - now has jobs for each test type

Types of changes

What types of changes does your code introduce?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of
them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before
merging your code.

  • I have read the CONTRIBUTING doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules

Further comments

@xBlaz3kx xBlaz3kx changed the title Improving CI and testing Repository maintenance: CI and testing improvements Dec 26, 2024
Copy link
Owner

@lorenzodonini lorenzodonini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Local and dockerized setup work differently (different networks), so we need to parametrize the test instance and toxiproxy with env variables accordingly. I put this code together that would need to be added to the network_test.go file to work for both environments:

type proxyConfig struct {
	ToxiProxyHost     string `env:"TOXIPROXY_HOST" envDefault:"localhost"`
	ToxiProxyPort     int    `env:"TOXIPROXY_PORT" envDefault:"8474"`
	ProxyOcppListener string `env:"PROXY_OCPP_LISTENER" envDefault:"localhost:8886"`
	ProxyOcppUpstream string `env:"PROXY_OCPP_UPSTREAM" envDefault:"localhost:8887"`
}

and:

func (s *NetworkTestSuite) SetupSuite() {
	var cfg proxyConfig
	err := env.Parse(&cfg)
	if err != nil {
		panic(err)
	}
	endpoint := fmt.Sprintf("%v:%v", cfg.ToxiProxyHost, cfg.ToxiProxyPort)
	client := toxiproxy.NewClient(endpoint)
        // .....
        p, err := client.CreateProxy("ocpp", cfg.ProxyOcppListener, cfg.ProxyOcppUpstream)
	require.NoError(s.T(), err)
	s.proxy = p
}

This needs a new support lib:

go get github.com/caarlos0/env/v11

@lorenzodonini
Copy link
Owner

lorenzodonini commented Dec 31, 2024

@xBlaz3kx Thanks for the PR. If it's too many change requests to handle, do you want me to take the branch over?

@xBlaz3kx
Copy link
Contributor Author

@xBlaz3kx Thanks for the PR. If it's too many change requests to handle, do you want me to take the branch over?

No worries, I will take some time and apply suggested changes.

@xBlaz3kx
Copy link
Contributor Author

xBlaz3kx commented Dec 31, 2024

I fixed the tests and also improved the testing workflow a bit:

  • Removed unnecessary waiting and go installation, since the tests are run via Docker
  • Added SHA as postfix to artifacts to uniquely identify coverage files for each workflow run

Not sure why coveralls is failing though.

@lorenzodonini lorenzodonini merged commit 8a016f6 into lorenzodonini:master Jan 1, 2025
4 checks passed
@xBlaz3kx xBlaz3kx deleted the chore/test-env branch January 2, 2025 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants