Skip to content

Commit

Permalink
Merge branch 'refs/heads/main' into ale/eng-6219-make-router-tests-le…
Browse files Browse the repository at this point in the history
…ss-flaky

# Conflicts:
#	router-tests/go.mod
#	router-tests/go.sum
#	router/go.mod
#	router/go.sum
  • Loading branch information
alepane21 committed Feb 7, 2025
2 parents b5ed84d + a05ecd5 commit 5102a1c
Show file tree
Hide file tree
Showing 34 changed files with 965 additions and 264 deletions.
4 changes: 4 additions & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Binaries are attached to the github release otherwise all images can be found [h
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.72.4](https://github.com/wundergraph/cosmo/compare/wgc@0.72.3...wgc@0.72.4) (2025-02-06)

**Note:** Version bump only for package wgc

## [0.72.3](https://github.com/wundergraph/cosmo/compare/wgc@0.72.2...wgc@0.72.3) (2025-02-05)

**Note:** Version bump only for package wgc
Expand Down
2 changes: 1 addition & 1 deletion cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wgc",
"version": "0.72.3",
"version": "0.72.4",
"description": "The official CLI tool to manage the GraphQL Federation Platform Cosmo",
"type": "module",
"main": "dist/index.js",
Expand Down
6 changes: 3 additions & 3 deletions composition-go/index.global.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions composition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Binaries are attached to the github release otherwise all images can be found [h
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.36.1](https://github.com/wundergraph/cosmo/compare/@wundergraph/composition@0.36.0...@wundergraph/composition@0.36.1) (2025-02-06)

### Bug Fixes

* allow integer to Float input coercion ([#1572](https://github.com/wundergraph/cosmo/issues/1572)) ([51c3d8e](https://github.com/wundergraph/cosmo/commit/51c3d8e11b6360f583f1809e2360c652a91659c6)) (@Aenimus)

# [0.36.0](https://github.com/wundergraph/cosmo/compare/@wundergraph/composition@0.35.0...@wundergraph/composition@0.36.0) (2025-02-05)

### Features
Expand Down
2 changes: 1 addition & 1 deletion composition/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wundergraph/composition",
"version": "0.36.0",
"version": "0.36.1",
"author": {
"name": "WunderGraph Maintainers",
"email": "info@wundergraph.com"
Expand Down
2 changes: 1 addition & 1 deletion composition/src/normalization/normalization-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ export class NormalizationFactory {
return argumentValue.kind === Kind.BOOLEAN;
}
case FLOAT_SCALAR: {
return argumentValue.kind === Kind.FLOAT;
return argumentValue.kind === Kind.FLOAT || argumentValue.kind === Kind.INT;
}
case ID_SCALAR: {
return argumentValue.kind === Kind.STRING || argumentValue.kind === Kind.INT;
Expand Down
34 changes: 34 additions & 0 deletions composition/tests/directives.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,28 @@ describe('Directive tests', () => {
expect(warnings).toHaveLength(0);
});

test('that a integer can be coerced into a Float', () => {
const { errors, normalizationResult, warnings } = normalizeSubgraph(nk.definitions, nk.name);
expect(errors).toBeUndefined();
expect(schemaToSortedNormalizedString(normalizationResult!.schema)).toBe(
normalizeString(
schemaQueryDefinition +
baseDirectiveDefinitions +
`
directive @z(float: Float!) on FIELD_DEFINITION
type Query {
dummy: String! @z(float: 1)
}
scalar openfed__FieldSet
`,
),
);
expect(warnings).toHaveLength(0);
});

test('that @specifiedBy is supported', () => {
const { errors } = normalizeSubgraph(subgraphA.definitions, subgraphA.name);
expect(errors).toBeUndefined();
Expand Down Expand Up @@ -479,6 +501,18 @@ const nj: Subgraph = {
`),
};

const nk: Subgraph = {
name: 'nk',
url: '',
definitions: parse(`
directive @z(float: Float!) on FIELD_DEFINITION
type Query {
dummy: String! @z(float: 1)
}
`),
};

const subgraphA: Subgraph = {
name: 'subgraph-a',
url: '',
Expand Down
4 changes: 4 additions & 0 deletions controlplane/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Binaries are attached to the github release otherwise all images can be found [h
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.121.7](https://github.com/wundergraph/cosmo/compare/controlplane@0.121.6...controlplane@0.121.7) (2025-02-06)

**Note:** Version bump only for package controlplane

## [0.121.6](https://github.com/wundergraph/cosmo/compare/controlplane@0.121.5...controlplane@0.121.6) (2025-02-05)

**Note:** Version bump only for package controlplane
Expand Down
2 changes: 1 addition & 1 deletion controlplane/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "controlplane",
"version": "0.121.6",
"version": "0.121.7",
"private": true,
"description": "WunderGraph Cosmo Controlplane",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion demo/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/rs/cors v1.11.0
github.com/vektah/gqlparser/v2 v2.5.21
github.com/wundergraph/cosmo/composition-go v0.0.0-20240124120900-5effe48a4a1d
github.com/wundergraph/cosmo/router v0.0.0-20250204092643-f97e30f48a8c
github.com/wundergraph/cosmo/router v0.0.0-20250206172233-1a9ec1459419
github.com/wundergraph/cosmo/router-tests v0.0.0-20241213115435-a249dba8c52a
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.147
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1
Expand Down
4 changes: 2 additions & 2 deletions demo/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,8 @@ github.com/wundergraph/astjson v0.0.0-20250106123708-be463c97e083 h1:8/D7f8gKxTB
github.com/wundergraph/astjson v0.0.0-20250106123708-be463c97e083/go.mod h1:eOTL6acwctsN4F3b7YE+eE2t8zcJ/doLm9sZzsxxxrE=
github.com/wundergraph/cosmo/composition-go v0.0.0-20240124120900-5effe48a4a1d h1:NEUrhuqOaTO1dpW8pz2tu6dKbQAqFvgiF/m4NXdzZm0=
github.com/wundergraph/cosmo/composition-go v0.0.0-20240124120900-5effe48a4a1d/go.mod h1:9I3gPMAlAY+m1/cFL20iN7XHTyuZd3VT5ijccdU/FsI=
github.com/wundergraph/cosmo/router v0.0.0-20250204092643-f97e30f48a8c h1:JG8F9j1GV9OWSSSv3GIYoKgD8ugw+1i+4IUYR16yrIo=
github.com/wundergraph/cosmo/router v0.0.0-20250204092643-f97e30f48a8c/go.mod h1:iSJuRRUMFHt7ZPbjqi0z4818iK5/TK/wG+brqaPvO34=
github.com/wundergraph/cosmo/router v0.0.0-20250206172233-1a9ec1459419 h1:s3XbCUQyzRietjaoNSWULZVic16Oup84bc+L4JmW+ss=
github.com/wundergraph/cosmo/router v0.0.0-20250206172233-1a9ec1459419/go.mod h1:iSJuRRUMFHt7ZPbjqi0z4818iK5/TK/wG+brqaPvO34=
github.com/wundergraph/cosmo/router-tests v0.0.0-20241213115435-a249dba8c52a h1:GVLe85f5g+G0IOorDBBNTfm5Ua9DO0vuVY7ReSTOEbQ=
github.com/wundergraph/cosmo/router-tests v0.0.0-20241213115435-a249dba8c52a/go.mod h1:I+SFviFnd3BHlPmYn+ckmzQyDB9+/c8RZJo4t6VQAds=
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.147 h1:czDm+FM5EIIYU/blkHycZUtvhsA+VIJ8eNjRZtt5VN0=
Expand Down
101 changes: 95 additions & 6 deletions router-tests/cache_warmup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ package integration

import (
"context"
nodev1 "github.com/wundergraph/cosmo/router/gen/proto/wg/cosmo/node/v1"
"github.com/wundergraph/cosmo/router/pkg/otel"
"net/http"
"testing"
"time"

"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/sdk/metric"
"go.opentelemetry.io/otel/sdk/metric/metricdata"
"go.opentelemetry.io/otel/sdk/metric/metricdata/metricdatatest"
"net/http"
"testing"
"time"

nodev1 "github.com/wundergraph/cosmo/router/gen/proto/wg/cosmo/node/v1"
"github.com/wundergraph/cosmo/router/pkg/otel"

"github.com/stretchr/testify/require"
"go.uber.org/zap"
Expand Down Expand Up @@ -40,7 +42,7 @@ func TestCacheWarmup(t *testing.T) {
t.Run("cache warmup enabled", func(t *testing.T) {
t.Parallel()

const employeeQueryCount = 2
const employeeQueryCount = 3

testenv.Run(t, &testenv.Config{
RouterOptions: []core.Option{
Expand Down Expand Up @@ -81,20 +83,107 @@ func TestCacheWarmup(t *testing.T) {
})
require.Equal(t, `{"data":{"employees":[{"id":1,"details":{"forename":"Jens","surname":"Neuse"}},{"id":2,"details":{"forename":"Dustin","surname":"Deus"}},{"id":3,"details":{"forename":"Stefan","surname":"Avram"}},{"id":4,"details":{"forename":"Björn","surname":"Schwenzer"}},{"id":5,"details":{"forename":"Sergiy","surname":"Petrunin"}},{"id":7,"details":{"forename":"Suvij","surname":"Surya"}},{"id":8,"details":{"forename":"Nithin","surname":"Kumar"}},{"id":10,"details":{"forename":"Eelco","surname":"Wiersma"}},{"id":11,"details":{"forename":"Alexandra","surname":"Neuse"}},{"id":12,"details":{"forename":"David","surname":"Stutt"}}]}}`, res.Body)

// employee operation is warmed up from the query with the inline value 2 for the id

// variable called id
res = xEnv.MakeGraphQLRequestOK(testenv.GraphQLRequest{
Query: `query m($id: Int!){ employee(id: $id) { id details { forename surname } } }`,
Variables: []byte(`{"id": 1}`),
})
require.Equal(t, "HIT", res.Response.Header.Get("x-wg-execution-plan-cache"))
require.Equal(t, `{"data":{"employee":{"id":1,"details":{"forename":"Jens","surname":"Neuse"}}}}`, res.Body)

// variable called jensID
res = xEnv.MakeGraphQLRequestOK(testenv.GraphQLRequest{
Query: `query m($jensID: Int!){ employee(id: $jensID) { id details { forename surname } } }`,
Variables: []byte(`{"jensID": 1}`),
})
require.Equal(t, "HIT", res.Response.Header.Get("x-wg-execution-plan-cache"))
require.Equal(t, `{"data":{"employee":{"id":1,"details":{"forename":"Jens","surname":"Neuse"}}}}`, res.Body)

// inline value 2 - match with warmed up operation
res = xEnv.MakeGraphQLRequestOK(testenv.GraphQLRequest{
Query: `query { employee(id: 2) { id details { forename surname } } }`,
})
require.Equal(t, "HIT", res.Response.Header.Get("x-wg-execution-plan-cache"))
require.Equal(t, `{"data":{"employee":{"id":2,"details":{"forename":"Dustin","surname":"Deus"}}}}`, res.Body)
})
})

t.Run("cache warmup enabled - variables remapping disabled", func(t *testing.T) {
t.Parallel()

const employeeQueryCount = 3

testenv.Run(t, &testenv.Config{
ModifyEngineExecutionConfiguration: func(cfg *config.EngineExecutionConfiguration) {
cfg.DisableVariablesRemapping = true
},
RouterOptions: []core.Option{
core.WithCacheWarmupConfig(&config.CacheWarmupConfiguration{
Enabled: true,
Source: config.CacheWarmupSource{
Filesystem: &config.CacheWarmupFileSystemSource{
Path: "testenv/testdata/cache_warmup/simple",
},
},
}),
},
AssertCacheMetrics: &testenv.CacheMetricsAssertions{
BaseGraphAssertions: testenv.CacheMetricsAssertion{
QueryNormalizationMisses: 3 + employeeWarmedQueryCount + employeeQueryCount,
QueryNormalizationHits: 4,
ValidationMisses: 5 + employeeWarmedQueryCount,
ValidationHits: 2 + employeeQueryCount,
PlanMisses: 5 + employeeWarmedQueryCount,
PlanHits: 2 + employeeQueryCount,
},
},
}, func(t *testing.T, xEnv *testenv.Environment) {
res := xEnv.MakeGraphQLRequestOK(testenv.GraphQLRequest{
Query: `query { employees { id } }`,
})
require.Equal(t, employeesIDData, res.Body)
res = xEnv.MakeGraphQLRequestOK(testenv.GraphQLRequest{
Query: `query { employees { id } }`,
})
require.Equal(t, employeesIDData, res.Body)
res = xEnv.MakeGraphQLRequestOK(testenv.GraphQLRequest{
Query: `query { employees { id details { forename } } }`,
})
require.Equal(t, `{"data":{"employees":[{"id":1,"details":{"forename":"Jens"}},{"id":2,"details":{"forename":"Dustin"}},{"id":3,"details":{"forename":"Stefan"}},{"id":4,"details":{"forename":"Björn"}},{"id":5,"details":{"forename":"Sergiy"}},{"id":7,"details":{"forename":"Suvij"}},{"id":8,"details":{"forename":"Nithin"}},{"id":10,"details":{"forename":"Eelco"}},{"id":11,"details":{"forename":"Alexandra"}},{"id":12,"details":{"forename":"David"}}]}}`, res.Body)
res = xEnv.MakeGraphQLRequestOK(testenv.GraphQLRequest{
Query: `query { employees { id details { forename surname } } }`,
})
require.Equal(t, `{"data":{"employees":[{"id":1,"details":{"forename":"Jens","surname":"Neuse"}},{"id":2,"details":{"forename":"Dustin","surname":"Deus"}},{"id":3,"details":{"forename":"Stefan","surname":"Avram"}},{"id":4,"details":{"forename":"Björn","surname":"Schwenzer"}},{"id":5,"details":{"forename":"Sergiy","surname":"Petrunin"}},{"id":7,"details":{"forename":"Suvij","surname":"Surya"}},{"id":8,"details":{"forename":"Nithin","surname":"Kumar"}},{"id":10,"details":{"forename":"Eelco","surname":"Wiersma"}},{"id":11,"details":{"forename":"Alexandra","surname":"Neuse"}},{"id":12,"details":{"forename":"David","surname":"Stutt"}}]}}`, res.Body)

// employee operation is warmed up from the query with the inline value 2 for the id

// variable called id
res = xEnv.MakeGraphQLRequestOK(testenv.GraphQLRequest{
Query: `query m($id: Int!){ employee(id: $id) { id details { forename surname } } }`,
Variables: []byte(`{"id": 1}`),
})
require.Equal(t, "MISS", res.Response.Header.Get("x-wg-execution-plan-cache"))
require.Equal(t, `{"data":{"employee":{"id":1,"details":{"forename":"Jens","surname":"Neuse"}}}}`, res.Body)

// variable called jensID
res = xEnv.MakeGraphQLRequestOK(testenv.GraphQLRequest{
Query: `query m($jensID: Int!){ employee(id: $jensID) { id details { forename surname } } }`,
Variables: []byte(`{"jensID": 1}`),
})
require.Equal(t, "MISS", res.Response.Header.Get("x-wg-execution-plan-cache"))
require.Equal(t, `{"data":{"employee":{"id":1,"details":{"forename":"Jens","surname":"Neuse"}}}}`, res.Body)

// inline value 2 - match with warmed up operation
res = xEnv.MakeGraphQLRequestOK(testenv.GraphQLRequest{
Query: `query { employee(id: 2) { id details { forename surname } } }`,
})
require.Equal(t, "HIT", res.Response.Header.Get("x-wg-execution-plan-cache"))
require.Equal(t, `{"data":{"employee":{"id":2,"details":{"forename":"Dustin","surname":"Deus"}}}}`, res.Body)
})
})

t.Run("cache warmup invalid files", func(t *testing.T) {
t.Parallel()
testenv.Run(t, &testenv.Config{
Expand Down
6 changes: 3 additions & 3 deletions router-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ require (
github.com/tidwall/gjson v1.18.0
github.com/twmb/franz-go v1.16.1
github.com/twmb/franz-go/pkg/kadm v1.11.0
github.com/wundergraph/cosmo/demo v0.0.0-20250204092643-f97e30f48a8c
github.com/wundergraph/cosmo/router v0.0.0-20250204092643-f97e30f48a8c
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.147
github.com/wundergraph/cosmo/demo v0.0.0-20250206172233-1a9ec1459419
github.com/wundergraph/cosmo/router v0.0.0-20250206172233-1a9ec1459419
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.148
go.opentelemetry.io/otel v1.28.0
go.opentelemetry.io/otel/sdk v1.28.0
go.opentelemetry.io/otel/sdk/metric v1.28.0
Expand Down
4 changes: 2 additions & 2 deletions router-tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,8 @@ github.com/wundergraph/astjson v0.0.0-20250106123708-be463c97e083 h1:8/D7f8gKxTB
github.com/wundergraph/astjson v0.0.0-20250106123708-be463c97e083/go.mod h1:eOTL6acwctsN4F3b7YE+eE2t8zcJ/doLm9sZzsxxxrE=
github.com/wundergraph/consul/sdk v0.0.0-20250204115147-ed842a8fd301 h1:EzfKHQoTjFDDcgaECCCR2aTePqMu9QBmPbyhqIYOhV0=
github.com/wundergraph/consul/sdk v0.0.0-20250204115147-ed842a8fd301/go.mod h1:wxI0Nak5dI5RvJuzGyiEK4nZj0O9X+Aw6U0tC1wPKq0=
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.147 h1:czDm+FM5EIIYU/blkHycZUtvhsA+VIJ8eNjRZtt5VN0=
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.147/go.mod h1:B7eV0Qh8Lop9QzIOQcsvKp3S0ejfC6mgyWoJnI917yQ=
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.148 h1:DZEHM32i8noRvNRmDMHTLUQCExBf2fF+Dd/I3DcTvss=
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.148/go.mod h1:B7eV0Qh8Lop9QzIOQcsvKp3S0ejfC6mgyWoJnI917yQ=
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4=
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
Loading

0 comments on commit 5102a1c

Please sign in to comment.