Skip to content
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

Test/kgw #446

Merged
merged 4 commits into from
Jan 9, 2024
Merged

Test/kgw #446

merged 4 commits into from
Jan 9, 2024

Conversation

Yaiba
Copy link
Contributor

@Yaiba Yaiba commented Jan 3, 2024

Add tests with KGW.

What I did:

  • pull kgw repo and build kgw docker image
  • add kgw integration tests on APIs and authn, they'll be skipped in short test mode
  • by default run all tests on self-hosted github runner
  • by default enable both acceptance test and integration test
  • a separated integration test 'TestLocalDevSetup' for local development, used by task dev:testnet:up:nb
  • combine all tests into one, reduce running time
  • minor fix on test issues

Tests are in integration tests, we probably should start using our own runners to run the tests, since integration tests will run longer and require more computing resources.. Right now our main CI workflow runs on our self-hosted github runner.

The tests are ready to review.

I'm testing CI workflow, do not merge before the tests pass.

@Yaiba Yaiba self-assigned this Jan 3, 2024
@Yaiba Yaiba force-pushed the test/kgw branch 5 times, most recently from f098624 to fe4d8a7 Compare January 8, 2024 17:34
@Yaiba Yaiba changed the title [WIP] Test/kgw Test/kgw Jan 8, 2024
@@ -263,7 +264,7 @@ func (a *AbciApp) executeTx(ctx context.Context, rawTx []byte, logger *log.Logge
Code: code.Uint32(),
GasUsed: gasUsed,
Events: events,
Log: "success",
Log: "",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This I believe is useless and no logic is depended on it, not a breaking change.

@@ -121,7 +114,11 @@ action divide($numerator1, $numerator2, $denominator) public view {
select $up AS upper_value, $down AS lower_value;
}

@kgw(authn='true')
Copy link
Member

Choose a reason for hiding this comment

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

kgw shouldn't auth owner actions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, an owner actoin is not necessary need to be authed.
But an onwer view action should(as user's identity is required) be, to be correctly used with KGW. I'll add this back to owner view action.

Just to clearfy, kgw annotation is not required for any action, kuneiform doesn't force it on any action.

Copy link
Member

Choose a reason for hiding this comment

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

But an onwer view action should(as user's identity is required) be, to be correctly used with KGW. I'll add this back to owner view action.

Ah, right right. I think that's what I was thinking -- non-transaction exec of owner view action.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here I'm more about mark an action that require authn just for testing, not think this kf as a whole application. I should haha

@Yaiba
Copy link
Contributor Author

Yaiba commented Jan 8, 2024

As for the refactor on testing with better specification #392 (comment), I did a small iteration the result is not so good, I'll need more time on it.

@Yaiba
Copy link
Contributor Author

Yaiba commented Jan 8, 2024

I'll combine unit-test and integration-test as they share some same env setups.
It will reduce the running time, also stop running separated jobs(like before) if any error.

defer helper.Teardown()

helper.RunDockerComposeWithServices(ctx, []string{"kgw"})
// this is boot up time issue when running in CI, we just wait for a while
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is actually due to the kgw upstream health check dealy, kwilteam/kgw#11 should fix thix

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
go-version: '1.21.x'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Github runner is using the pre-installed go already, but it still takes 40s to run this step

@Yaiba
Copy link
Contributor Author

Yaiba commented Jan 8, 2024

This pr is good to go. No more email bombs on test failed 🙃
On average, tests will take less than 8 min, not ideal but it's a new start on our more throughly test workflow.

To get this merged, since I changed the job's name to 'test', github branch rule on status checks need to be disabled temporarily as it requires both unit-test and acceptance-test pass.

@@ -26,7 +26,7 @@ services:
--root-dir=/app/kwil
--log.level=${LOG_LEVEL:-info}
--app.extension-endpoints=ext:50051
--app.admin-listen-addr=unix:///var/run/kwil/admin.sock
--app.admin-listen-addr=unix:///tmp/admin.sock
Copy link
Member

Choose a reason for hiding this comment

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

I thought we had the - /tmp:/var/run/kwil:rw mapping in volumes:target above for this. What was going wrong on the machine without this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

'/var/run/kwil/admin.sock' just don't work locally on my pc, and I have to modify this manually everytime.
And I don't think we have to use this path for testing, as long as this path is inside the container?

Copy link
Member

@jchappelow jchappelow left a comment

Choose a reason for hiding this comment

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

Still working locally for me with a minor tweak (see comments).

@@ -216,7 +216,7 @@ tasks:
- go test ./... -tags=ext_test -count=1 -race

test:it:
desc: Run integration tests
desc: Run integration tests ('short' mode)
Copy link
Member

Choose a reason for hiding this comment

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

Not an issue with this PR, but I was testing with go 1.22rc1 and I found that go mod vendor fails with:

go: 'go mod vendor' cannot be run in workspace mode. Run 'go work vendor' to vendor the workspace or set 'GOWORK=off' to exit workspace mode.

This is documented:
golang/go#60056

With the addition of go work vendor, the go mod vendor command errors if there is a go.work file. Two ways we can consider dealing with this so it works on dev machines where there is likely a go.mod as well as CI and cloud build systems:

  • GOWORK=off go mod vendor
  • go mod vendor || go work vendor

For when 1.22 is release.

Copy link
Member

Choose a reason for hiding this comment

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

Well it looks like if the vendor directory is intended for use inside the docker image (while building) then it would need to be created with GOWORK=off go mod vendor, not go work vendor.
I think we should make this change to Taskfile.yml's vendor task definition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah seems so. It's also a bit surprise bc we should not have go.work file anywhere for this workflow 🤔

@@ -85,7 +85,8 @@ jobs:
- name: Generate go vendor
#for faster builds and private repos, need to run this after pb:compile:v1
run: |
task vendor
rm -rf vendor
GOWORK=off go mod vendor
Copy link
Member

Choose a reason for hiding this comment

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

The problem was on my local dev machine where I use task vendor. Can we change the Taskfile instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it, I used go mod vendor || go work vendor so current workflow locally won't break.

Copy link
Member

@jchappelow jchappelow left a comment

Choose a reason for hiding this comment

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

LGTM. Merge away assuming CI passes still.

@Yaiba
Copy link
Contributor Author

Yaiba commented Jan 9, 2024

Alright, I'll temporary disable github branch check rules and merge it.

@Yaiba Yaiba merged commit 53c8500 into main Jan 9, 2024
1 check passed
@Yaiba Yaiba deleted the test/kgw branch January 9, 2024 22:57
brennanjl pushed a commit that referenced this pull request Feb 26, 2024
* test kgw
* go 1.22 compatiable `go mod vendor`
brennanjl pushed a commit that referenced this pull request Feb 26, 2024
* test kgw
* go 1.22 compatiable `go mod vendor`
jchappelow pushed a commit that referenced this pull request Feb 26, 2024
* test kgw
* go 1.22 compatiable `go mod vendor`
brennanjl pushed a commit that referenced this pull request Feb 26, 2024
* test kgw
* go 1.22 compatiable `go mod vendor`
brennanjl pushed a commit that referenced this pull request Feb 26, 2024
* test kgw
* go 1.22 compatiable `go mod vendor`
brennanjl pushed a commit that referenced this pull request Feb 26, 2024
* test kgw
* go 1.22 compatiable `go mod vendor`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants