Skip to content

Commit

Permalink
[ci-visibility] Fix v3 evp proxy version (#4159)
Browse files Browse the repository at this point in the history
  • Loading branch information
juan-fernandez committed Mar 20, 2024
1 parent 9796589 commit 7dcdc09
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,15 @@ class AgentProxyCiVisibilityExporter extends CiVisibilityExporter {

this.getAgentInfo((err, agentInfo) => {
this._isInitialized = true
const latestEvpProxyVersion = getLatestEvpProxyVersion(err, agentInfo)
let latestEvpProxyVersion = getLatestEvpProxyVersion(err, agentInfo)
const isEvpCompatible = latestEvpProxyVersion >= 2
const isGzipCompatible = latestEvpProxyVersion >= 4

// v3 does not work well citestcycle, so we downgrade to v2
if (latestEvpProxyVersion === 3) {
latestEvpProxyVersion = 2
}

const evpProxyPrefix = `${AGENT_EVP_PROXY_PATH_PREFIX}${latestEvpProxyVersion}`
if (isEvpCompatible) {
this._isUsingEvpProxy = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,4 +285,39 @@ describe('AgentProxyCiVisibilityExporter', () => {
expect(scope.isDone()).to.be.true
})
})

describe('evpProxyPrefix', () => {
it('should set evpProxyPrefix to v2 if the newest version is v3', async () => {
const scope = nock('http://localhost:8126')
.get('/info')
.reply(200, JSON.stringify({
endpoints: ['/evp_proxy/v2', '/evp_proxy/v3']
}))

const agentProxyCiVisibilityExporter = new AgentProxyCiVisibilityExporter({ port, tags })

expect(agentProxyCiVisibilityExporter).not.to.be.null

await agentProxyCiVisibilityExporter._canUseCiVisProtocolPromise

expect(agentProxyCiVisibilityExporter.evpProxyPrefix).to.equal('/evp_proxy/v2')
expect(scope.isDone()).to.be.true
})
it('should set evpProxyPrefix to v4 if the newest version is v4', async () => {
const scope = nock('http://localhost:8126')
.get('/info')
.reply(200, JSON.stringify({
endpoints: ['/evp_proxy/v2', '/evp_proxy/v3', '/evp_proxy/v4/']
}))

const agentProxyCiVisibilityExporter = new AgentProxyCiVisibilityExporter({ port, tags })

expect(agentProxyCiVisibilityExporter).not.to.be.null

await agentProxyCiVisibilityExporter._canUseCiVisProtocolPromise

expect(agentProxyCiVisibilityExporter.evpProxyPrefix).to.equal('/evp_proxy/v4')
expect(scope.isDone()).to.be.true
})
})
})

0 comments on commit 7dcdc09

Please sign in to comment.