Skip to content

integration-testing initial phase#1

Open
Prajwal17Tunerlabs wants to merge 24 commits into
developfrom
develop-2
Open

integration-testing initial phase#1
Prajwal17Tunerlabs wants to merge 24 commits into
developfrom
develop-2

Conversation

@Prajwal17Tunerlabs
Copy link
Copy Markdown
Owner

Description

These recommendations are intended to promote code quality and team communication during software development. They cover a variety of topics, including ensuring that pull requests are submitted to the correct branch, documenting new methods, preserving consistency across many services, and avoiding typical blunders like accessing APIs or DB queries within loops. Sensitive data should not be uploaded, and changes to environment variables or database models should be executed consistently. Teams may work more effectively and develop higher-quality software by adhering to these standards.

Type of change

Please choose appropriate options.

  • Bug fix (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)
  • Enhancement (additive changes to improve performance)
  • This change requires a documentation update

Checklist

  • It's critical to avoid making needless file modifications in contributions, such as adding new lines, console logs, or additional spaces, to guarantee cleaner and more efficient code. Furthermore, eliminating unnecessary imports from a file might enhance code readability and efficiency.
  • Ensure that the pull request is assigned to the right base branch and that the development branch name contains the JIRA Task Id. Furthermore, each commit message should include the JIRA Task Id in the manner "ED-100: message".
  • Only update packages if it is mentioned and authorized in the design document, and make sure that you have the required permissions.
  • Avoid making API and database queries inside a loop as it can lead to performance issues and slow down the system.
  • When calling another function inside a given function, add comments explaining the purpose and meaning of the passed arguments and expected return values.
  • If adding a blank argument in a function, add a comment explaining the reason for the blank argument.
  • Before submitting a pull request, do a self-review of your code to ensure there are no conflicts with the base branch and all comments have been addressed.
  • Before merging a pull request, it's important to have other team members review it to catch any potential errors or issues
  • To maintain code integrity, it's important to remove all related changes when removing code during a code review.
  • If new constants, endpoints, or utility functions are introduced, it is important to check if they already exist in the service to avoid any duplication.
  • Whenever a new environment variable is added to a service, it's important to ensure that the necessary changes are made to related files such as ".env.sample" and "envVariables.js" to maintain consistency and avoid errors. Additionally, the new environment variable should be added to the devops repository to ensure that it is properly documented and accessible to the team.
  • When adding a new function to a service, it is important to document it with relevant information such as the name, parameters, and return value in a consistent format across all services. Additionally, if there are any changes to the API response, ensure that the documentation in the controllers is updated accordingly.
  • Write a clear and concise commit message that describes the changes made.
  • Maintain consistent function signature and code across all services when adding a function to multiple services. Implement changes to database models in all services that use the same model.
  • Use only let and const. Do not use var.
  • Make common functions for repetitive code blocks.
  • Avoid uploading sensitive information such as secret tokens or passwords in pull requests to ensure data security.
  • Maintain consistent indentation and spacing throughout the code.

Prajwal17Tunerlabs and others added 24 commits May 22, 2026 12:53
The CI pipeline was failing because the `test:integration` npm script
invoked `mocha` which resolved to the globally installed mocha from the
nvm environment (Node v24 global) rather than the local package in
node_modules. The global mocha binary cannot resolve locally-installed
packages like `mocha-junit-reporter`, causing the reporter load to fail.

Fix by explicitly referencing `./node_modules/.bin/mocha` so the locally
installed mocha is always used, ensuring it can find all local
devDependencies including `mocha-junit-reporter`.
…r-resolution

fix: use local mocha binary to resolve mocha-junit-reporter correctly
The recent refactor in commonTests.js changed USER_INTERNAL_ACCESS_TOKEN
to read from process.env.INTERNAL_ACCESS_TOKEN (without a fallback default).
However, the CI test step only exported ADMIN_SECRET_CODE from the user
service .env file, leaving INTERNAL_ACCESS_TOKEN undefined during test runs.

This caused admin user creation requests to fail authentication against the
user-service, breaking the integration test suite.

Fix: extract INTERNAL_ACCESS_TOKEN from ~/services/user/src/.env using the
same pattern already used for ADMIN_SECRET_CODE.
…ss-token-ci

fix: export INTERNAL_ACCESS_TOKEN to integration test environment
…tion tests

The CI pipeline was using a fixed `sleep 60` delay before running integration
tests, which was unreliable — services (user, entity, project, interface) could
take longer to fully initialize, especially after DB migrations and Kafka
startup, causing tests to run against unready services.

The mocha-junit-reporter produces no stdout output, so when the before() hook
in integration tests hangs (connection refused to user-service), the CI step
either times out via no_output_timeout (5m) or exits with a non-zero code and
no diagnostic output visible in the log.

Fix: replace `sleep 60` with four `wait_for_http` health checks (one per
application service) using the already-defined reusable command. Each check
polls the /health endpoint up to 60 times with 3s intervals (180s max),
failing fast with a clear error if a service does not become ready in time.
…-health-checks

fix: replace sleep 60 with wait_for_http health checks before integration tests
Commits 4733067 and ee5a447 removed the wait_for_http steps that ensured
all four application services (user, entity, project, interface) were
fully HTTP-ready before the integration test suite ran.

wait_for_port only confirms TCP connectivity — it does not guarantee the
Node.js service has finished initialising (DB connections, Kafka, etc.).
When tests start against a service that is listening on the port but not
yet serving HTTP, the mocha before() hooks fail silently and
mocha-junit-reporter produces no stdout, causing the CI step to appear
empty or exit without useful diagnostics.

Fix: re-add wait_for_http calls (polling /health up to 180 s each) for
all four services, after the existing wait_for_port checks.
…for-http-health-checks

fix: restore wait_for_http health checks before integration tests
The wait_for_http step for project-service polls /health without any
query parameters, which causes the health check handler to run a full
check including microservice dependency checks (user-service,
entity-management, SamikshaService) via the interface-service.

However, the interface-service has not yet been confirmed healthy at
that point in the pipeline (it is checked in the next step), creating
a race condition where project-service's /health returns a 400 error
because it cannot reach the interface-service.

Fix: append ?basicCheck=true to the project-service health check URL.
The elevate-services-health-check library skips microservice dependency
checks when basicCheck is truthy, so only MongoDB, Kafka, and Gotenberg
are verified — all of which are already confirmed up before this step.
…ce-health-check-basic

fix: use basicCheck=true for project-service CI health check
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.

1 participant