You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/09/05 16:28:18 UTC

[GitHub] [beam] eantyshev opened a new pull request, #23032: [Tour Of Beam][backend] integration tests and GA workflow

eantyshev opened a new pull request, #23032:
URL: https://github.com/apache/beam/pull/23032

   
   addresses #23005
   
   Basic integration tests, GitHub action-wrapped, and a bit of a boilerplate to run it locally
   Essentially an acceptance test.
   
   1. Setup and run Datastore emulator in background process
   2. Compile Cloud Functions and run them in background
   3. Execute CD step for samples/learning-content
   4. Run integration tests that call CFs via HTTP client. Compare responses with those from samples/api.
   5. Datastore emulator generates indexes while the queries are executed. Compare it with VCS version. We will use it in future Cloud Deployment workflow.
   
   Example workflow run:
   https://github.com/akvelon/beam/runs/8192798498
   
   ------------------------
   
   Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
   
    - [ ] [**Choose reviewer(s)**](https://beam.apache.org/contribute/#make-your-change) and mention them in a comment (`R: @username`).
    - [ ] Mention the appropriate issue in your description (for example: `addresses #123`), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment `fixes #<ISSUE NUMBER>` instead.
    - [ ] Update `CHANGES.md` with noteworthy changes.
    - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   See the [Contributor Guide](https://beam.apache.org/contribute) for more tips on [how to make review process smoother](https://beam.apache.org/contribute/get-started-contributing/#make-the-reviewers-job-easier).
   
   To check the build health, please visit [https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md](https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md)
   
   GitHub Actions Tests Status (on master branch)
   ------------------------------------------------------------------------------------------------
   [![Build python source distribution and wheels](https://github.com/apache/beam/workflows/Build%20python%20source%20distribution%20and%20wheels/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Build+python+source+distribution+and+wheels%22+branch%3Amaster+event%3Aschedule)
   [![Python tests](https://github.com/apache/beam/workflows/Python%20tests/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Python+Tests%22+branch%3Amaster+event%3Aschedule)
   [![Java tests](https://github.com/apache/beam/workflows/Java%20Tests/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Java+Tests%22+branch%3Amaster+event%3Aschedule)
   [![Go tests](https://github.com/apache/beam/workflows/Go%20tests/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Go+tests%22+branch%3Amaster+event%3Aschedule)
   
   See [CI.md](https://github.com/apache/beam/blob/master/CI.md) for more information about GitHub Actions CI.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] damccorm commented on a diff in pull request #23032: [Tour Of Beam][backend] integration tests and GA workflow

Posted by GitBox <gi...@apache.org>.
damccorm commented on code in PR #23032:
URL: https://github.com/apache/beam/pull/23032#discussion_r966121921


##########
.github/workflows/tour_of_beam_backend.yml:
##########
@@ -28,6 +28,11 @@ on:
     tags: 'v*'
     paths: ['learning/tour-of-beam/backend/**']
 
+# This allows a subsequently queued workflow run to interrupt previous runs
+concurrency:
+  group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
+  cancel-in-progress: true

Review Comment:
   FYI, I added https://github.com/apache/beam/issues/23089 because I think we should be doing this more broadly - thanks for introducing it to the repo 😄 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] eantyshev commented on a diff in pull request #23032: [Tour Of Beam][backend] integration tests and GA workflow

Posted by GitBox <gi...@apache.org>.
eantyshev commented on code in PR #23032:
URL: https://github.com/apache/beam/pull/23032#discussion_r966023514


##########
learning/tour-of-beam/backend/internal/storage/image/Dockerfile:
##########
@@ -24,7 +24,7 @@ FROM google/cloud-sdk:$GCLOUD_SDK_VERSION
 VOLUME /opt/data
 
 # RUN mkdir -p /opt/data/WEB-INF
-COPY index.yaml /opt/data/WEB-INF/index.yaml
+# COPY index.yaml /opt/data/WEB-INF/index.yaml

Review Comment:
   This was my initial idea of how to validate Datastore indexes: by copying it to the Datastore emulator container
   But that actually doesn't work: emulator updates WEB-INF/index.yaml when it executes the query which requires a composite index. 
   So, in this PR we switch to comparing the generated index.yaml with our VCS version.
   Assuming integration tests covered every possible Datastore query, it produces an index that must work when deployed to Cloud
   
   The line has to be removed, I overlooked that I only commented it



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] damccorm merged pull request #23032: [Tour Of Beam][backend] integration tests and GA workflow

Posted by GitBox <gi...@apache.org>.
damccorm merged PR #23032:
URL: https://github.com/apache/beam/pull/23032


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] olehborysevych commented on pull request #23032: [Tour Of Beam][backend] integration tests and GA workflow

Posted by GitBox <gi...@apache.org>.
olehborysevych commented on PR #23032:
URL: https://github.com/apache/beam/pull/23032#issuecomment-1240495682

   lgtm


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] github-actions[bot] commented on pull request #23032: [Tour Of Beam][backend] integration tests and GA workflow

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #23032:
URL: https://github.com/apache/beam/pull/23032#issuecomment-1240499993

   Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] olehborysevych commented on pull request #23032: [Tour Of Beam][backend] integration tests and GA workflow

Posted by GitBox <gi...@apache.org>.
olehborysevych commented on PR #23032:
URL: https://github.com/apache/beam/pull/23032#issuecomment-1240498603

   R: @damccorm 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] damccorm commented on a diff in pull request #23032: [Tour Of Beam][backend] integration tests and GA workflow

Posted by GitBox <gi...@apache.org>.
damccorm commented on code in PR #23032:
URL: https://github.com/apache/beam/pull/23032#discussion_r965939872


##########
learning/tour-of-beam/backend/integration_tests/client.go:
##########
@@ -0,0 +1,68 @@
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package main
+
+import (
+	"encoding/json"
+	"io"
+	"net/http"
+	"os"
+)
+
+func SdkList(url string) (sdkListResponse, error) {
+	var result sdkListResponse
+	err := Get(&result, url, nil)
+	return result, err
+}
+
+func GetContentTree(url, sdk string) (ContentTree, error) {
+	var result ContentTree
+	err := Get(&result, url, map[string]string{"sdk": sdk})
+	return result, err
+}
+
+func GetUnitContent(url, sdk, unitId string) (Unit, error) {
+	var result Unit
+	err := Get(&result, url, map[string]string{"sdk": sdk, "unitId": unitId})
+	return result, err
+}
+
+// Generic HTTP call wrapper
+// params:
+// * dst: response struct pointer
+// * url: request  url
+// * query_params: url query params, as a map (we don't use multiple-valued params)
+func Get(dst interface{}, url string, queryParams map[string]string) error {
+
+	req, err := http.NewRequest(http.MethodGet, url, nil)

Review Comment:
   ```suggestion
   func Get(dst interface{}, url string, queryParams map[string]string) error {
   	req, err := http.NewRequest(http.MethodGet, url, nil)
   ```
   
   Nit - spacing



##########
learning/tour-of-beam/backend/integration_tests/function_test.go:
##########
@@ -0,0 +1,149 @@
+//go:build integration
+// +build integration
+
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package main
+
+import (
+	"encoding/json"
+	"log"
+	"os"
+	"path/filepath"
+	"testing"
+
+	"github.com/stretchr/testify/assert"
+)
+
+const (
+	PORT_SDK_LIST         = "PORT_SDK_LIST"
+	PORT_GET_CONTENT_TREE = "PORT_GET_CONTENT_TREE"
+	PORT_GET_UNIT_CONTENT = "PORT_GET_UNIT_CONTENT"
+)
+
+// scenarios:
+// + Get SDK list
+// + Get content tree for existing SDK
+// - Get content tree for non-existing SDK: 404 Not Found
+// - Get unit content for existing SDK, existing unitId
+// - Get unit content for non-existing SDK/unitId: 404 Not Found
+// TODO:
+// - Get content tree for a registered user
+// - Get unit content for a registered user
+// - Save user code/progress for a registered user
+// - (negative) Save user code/progress w/o user token/bad token
+// - (negative) Save user code/progress for non-existing SDK/unitId: 404 Not Found
+
+func loadJson(path string, dst interface{}) error {
+	fh, err := os.Open(path)
+	if err != nil {
+		return err
+	}
+	return json.NewDecoder(fh).Decode(dst)
+}
+
+func TestSdkList(t *testing.T) {
+	port := os.Getenv(PORT_SDK_LIST)
+	if port == "" {
+		log.Fatal(PORT_SDK_LIST, "env not set")

Review Comment:
   ```suggestion
   		t.Fatal(PORT_SDK_LIST, "env not set")
   ```



##########
learning/tour-of-beam/backend/integration_tests/function_test.go:
##########
@@ -0,0 +1,149 @@
+//go:build integration
+// +build integration
+
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package main
+
+import (
+	"encoding/json"
+	"log"
+	"os"
+	"path/filepath"
+	"testing"
+
+	"github.com/stretchr/testify/assert"
+)
+
+const (
+	PORT_SDK_LIST         = "PORT_SDK_LIST"
+	PORT_GET_CONTENT_TREE = "PORT_GET_CONTENT_TREE"
+	PORT_GET_UNIT_CONTENT = "PORT_GET_UNIT_CONTENT"
+)
+
+// scenarios:
+// + Get SDK list
+// + Get content tree for existing SDK
+// - Get content tree for non-existing SDK: 404 Not Found
+// - Get unit content for existing SDK, existing unitId
+// - Get unit content for non-existing SDK/unitId: 404 Not Found
+// TODO:
+// - Get content tree for a registered user
+// - Get unit content for a registered user
+// - Save user code/progress for a registered user
+// - (negative) Save user code/progress w/o user token/bad token
+// - (negative) Save user code/progress for non-existing SDK/unitId: 404 Not Found
+
+func loadJson(path string, dst interface{}) error {
+	fh, err := os.Open(path)
+	if err != nil {
+		return err
+	}
+	return json.NewDecoder(fh).Decode(dst)
+}
+
+func TestSdkList(t *testing.T) {
+	port := os.Getenv(PORT_SDK_LIST)
+	if port == "" {
+		log.Fatal(PORT_SDK_LIST, "env not set")

Review Comment:
   Same suggestion for rest of the tests as well



##########
.github/workflows/tour_of_beam_backend_integration.yml:
##########
@@ -0,0 +1,95 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# To learn more about GitHub Actions in Apache Beam check the CI.md
+
+name: Tour of Beam Go integration tests
+
+on:
+  push:
+    branches: ['master', 'release-*']
+    tags: 'v*'
+  pull_request:
+    branches: ['master', 'release-*']
+    tags: 'v*'
+    paths: ['learning/tour-of-beam/backend/**']
+
+# This allows a subsequently queued workflow run to interrupt previous runs
+concurrency:
+  group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
+  cancel-in-progress: true
+
+env:
+  TOB_LEARNING_ROOT: ./samples/learning-content
+  DATASTORE_PROJECT_ID: test-proj
+  DATASTORE_EMULATOR_HOST: localhost:8081
+  DATASTORE_EMULATOR_DATADIR: ./datadir
+  PORT_SDK_LIST: 8801
+  PORT_GET_CONTENT_TREE: 8802
+  PORT_GET_UNIT_CONTENT: 8803
+
+
+jobs:
+  integration:
+    runs-on: ubuntu-latest
+    defaults:
+      run:
+        working-directory: ./learning/tour-of-beam/backend
+    steps:
+      - uses: actions/checkout@v3
+      - uses: actions/setup-go@v3
+        with:
+          go-version: '1.16'

Review Comment:
   Minor: Could we add a comment explaining we're pinning to 1.16 because Google Cloud Functions don't support higher versions (ideally here and in tour_of_beam_backend.yml)? That way we avoid a well meaning contributor (or dependabot) bumping the version.



##########
.github/workflows/tour_of_beam_backend.yml:
##########
@@ -28,6 +28,11 @@ on:
     tags: 'v*'
     paths: ['learning/tour-of-beam/backend/**']
 
+# This allows a subsequently queued workflow run to interrupt previous runs
+concurrency:
+  group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
+  cancel-in-progress: true

Review Comment:
   I wasn't familiar with this feature - neat!



##########
learning/tour-of-beam/backend/internal/storage/image/Dockerfile:
##########
@@ -24,7 +24,7 @@ FROM google/cloud-sdk:$GCLOUD_SDK_VERSION
 VOLUME /opt/data
 
 # RUN mkdir -p /opt/data/WEB-INF
-COPY index.yaml /opt/data/WEB-INF/index.yaml
+# COPY index.yaml /opt/data/WEB-INF/index.yaml

Review Comment:
   Should we just remove this entirely? Why did we end up moving this?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] eantyshev commented on a diff in pull request #23032: [Tour Of Beam][backend] integration tests and GA workflow

Posted by GitBox <gi...@apache.org>.
eantyshev commented on code in PR #23032:
URL: https://github.com/apache/beam/pull/23032#discussion_r966023514


##########
learning/tour-of-beam/backend/internal/storage/image/Dockerfile:
##########
@@ -24,7 +24,7 @@ FROM google/cloud-sdk:$GCLOUD_SDK_VERSION
 VOLUME /opt/data
 
 # RUN mkdir -p /opt/data/WEB-INF
-COPY index.yaml /opt/data/WEB-INF/index.yaml
+# COPY index.yaml /opt/data/WEB-INF/index.yaml

Review Comment:
   This was my initial idea of how to validate Datastore indexes: by copying it to the Datastore emulator container
   But that actually doesn't work: emulator updates WEB-INF/index.yaml when it executes the query which requires a composite index. 
   So, in this PR we switch to comparing the generated index.yaml with our VCS version *after* the tests
   Assuming integration tests covered every possible Datastore query, it produces an index that must work when deployed to Cloud
   
   The line has to be removed, I overlooked that I only commented it



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] eantyshev commented on a diff in pull request #23032: [Tour Of Beam][backend] integration tests and GA workflow

Posted by GitBox <gi...@apache.org>.
eantyshev commented on code in PR #23032:
URL: https://github.com/apache/beam/pull/23032#discussion_r966023514


##########
learning/tour-of-beam/backend/internal/storage/image/Dockerfile:
##########
@@ -24,7 +24,7 @@ FROM google/cloud-sdk:$GCLOUD_SDK_VERSION
 VOLUME /opt/data
 
 # RUN mkdir -p /opt/data/WEB-INF
-COPY index.yaml /opt/data/WEB-INF/index.yaml
+# COPY index.yaml /opt/data/WEB-INF/index.yaml

Review Comment:
   This was my initial idea of how to validate Datastore indexes: by copying it to the Datastore emulator container
   But that actually doesn't work: emulator updates WEB-INF/index.yaml when it executes the query which requires a composite index. 
   So, in this PR we switch to comparing the generated index.yaml with our VCS version.
   Assuming integration tests covered every possible Datastore query, it produces an index that must work when deployed to Cloud
   
   This line is removed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] github-actions[bot] commented on pull request #23032: [Tour Of Beam][backend] integration tests and GA workflow

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #23032:
URL: https://github.com/apache/beam/pull/23032#issuecomment-1237870945

   Assigning reviewers. If you would like to opt out of this review, comment `assign to next reviewer`:
   
   R: @Abacn for label build.
   
   Available commands:
   - `stop reviewer notifications` - opt out of the automated review tooling
   - `remind me after tests pass` - tag the comment author after tests pass
   - `waiting on author` - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)
   
   The PR bot will only process comments in the main thread (not review comments).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org