impact-graph icon indicating copy to clipboard operation
impact-graph copied to clipboard

Remove clearing the database in the Tests

Open mhmdksh opened this issue 1 year ago • 6 comments

We have a limitation in our tests that will only run on a clean set of data. We want to remove this limitation, in order to make use of testing on real data dumps from our environments instead of completely new databases.

@mohammadranjbarz Have more information about this.

mhmdksh avatar Aug 04 '23 07:08 mhmdksh

@mhmdksh See this part of code https://github.com/Giveth/impact-graph/blob/b67ed85e3345dee7d7b21ea5bc12796b773aa8c4/src/server/bootstrap.ts#L97-L110

It seems you just need to set DROP_DATABASE to false in configs when running on CI so it would not drop database ( no need to change the code)

mohammadranjbarz avatar Aug 06 '23 07:08 mohammadranjbarz

Thanks @mohammadranjbarz

I see it's hard-coded in the code of bootstrap.ts. Do you think we should give it the flexibility to be in process.env maybe that we can decide on when to use it on clean DB or not

mhmdksh avatar Aug 07 '23 15:08 mhmdksh

So I think the only thing we should do to integrate this with the test step in the CI is this:

      - name: Run tests
        run: npm run test
        env:
          ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }}
          XDAI_NODE_HTTP_URL: ${{ secrets.XDAI_NODE_HTTP_URL }}
          INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }}
          INFURA_ID: ${{ secrets.INFURA_ID }}
          POLYGON_SCAN_API_KEY: ${{ secrets.POLYGON_SCAN_API_KEY }}
          OPTIMISTIC_SCAN_API_KEY: ${{ secrets.OPTIMISTIC_SCAN_API_KEY }}
          CELO_SCAN_API_KEY: ${{ secrets.CELO_SCAN_API_KEY }}
          CELO_ALFAJORES_SCAN_API_KEY: ${{ secrets.CELO_ALFAJORES_SCAN_API_KEY }}
          DROP_DATABASE: ${{ secrets.DROP_DATABASE }}

And add the github secret DROP_DATABASE=false

Right? Can you confirm @mohammadranjbarz ?

mhmdksh avatar Aug 31 '23 08:08 mhmdksh

So I think the only thing we should do to integrate this with the test step in the CI is this:

      - name: Run tests
        run: npm run test
        env:
          ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }}
          XDAI_NODE_HTTP_URL: ${{ secrets.XDAI_NODE_HTTP_URL }}
          INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }}
          INFURA_ID: ${{ secrets.INFURA_ID }}
          POLYGON_SCAN_API_KEY: ${{ secrets.POLYGON_SCAN_API_KEY }}
          OPTIMISTIC_SCAN_API_KEY: ${{ secrets.OPTIMISTIC_SCAN_API_KEY }}
          CELO_SCAN_API_KEY: ${{ secrets.CELO_SCAN_API_KEY }}
          CELO_ALFAJORES_SCAN_API_KEY: ${{ secrets.CELO_ALFAJORES_SCAN_API_KEY }}
          DROP_DATABASE: ${{ secrets.DROP_DATABASE }}

And add the github secret DROP_DATABASE=false

Right? Can you confirm @mohammadranjbarz ?

Yeah exactly

mohammadranjbarz avatar Sep 04 '23 08:09 mohammadranjbarz

Thanks @mohammadranjbarz

I've added the above steps, it seems that when testing on real database data, the tests fail from the start. Please check this:

https://github.com/Giveth/impact-graph/actions/runs/6145025837/job/16671618590

mhmdksh avatar Sep 11 '23 12:09 mhmdksh

Want to bring this back to attention. Would be great to have this after moving the production deployment to impact-graph. @mhmdksh will add more details to explain the issue better.

geleeroyale avatar Dec 06 '23 14:12 geleeroyale