diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 11cc92c..ada8e39 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -1,11 +1,10 @@ name: e2e tests -on: {} - -# pull_request: -# push: -# branches: -# - main +on: + pull_request: + push: + branches: + - main jobs: diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index e2f2bba..9e40366 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -1,10 +1,10 @@ name: unit tests -on: - pull_request: - push: - branches: - - main +on: {} +# pull_request: +# push: +# branches: +# - main jobs: diff --git a/e2e/e2e_helpers_test.go b/e2e/e2e_helpers_test.go index 6e4774c..fbfbe49 100644 --- a/e2e/e2e_helpers_test.go +++ b/e2e/e2e_helpers_test.go @@ -32,7 +32,7 @@ func userRegister(t *testing.T, user *model.UserRequest) *http.Cookie { resp, body := makeCommonRequest(t, endpointUserRegister, user) require.True(t, resp.IsSuccess()) require.Empty(t, body.Error) - require.Equal(t, "ok", body.Message) + require.Equal(t, "registration complete", body.Message) return getCookieWithToken(t, resp.Cookies()) } @@ -52,7 +52,7 @@ func userLogin(t *testing.T, user *model.UserRequest) *http.Cookie { resp, body := makeCommonRequest(t, endpointUserLogin, user) require.True(t, resp.IsSuccess()) require.Empty(t, body.Error) - require.Equal(t, "login ok", body.Message) + require.Equal(t, "ok", body.Message) return getCookieWithToken(t, resp.Cookies()) } @@ -266,7 +266,7 @@ func videoCreate(t *testing.T, userCookie *http.Cookie) *videohttp.VideoResponse require.Empty(t, errBody.Error) require.NotEmpty(t, videoBody.CreatedAt) require.NotEmpty(t, videoBody.ID) - require.NotEmpty(t, videoBody.UploadURL) + require.NotEmpty(t, videoBody.UploadInfo.URL) status, err := video.GetStatusFromName(videoBody.Status) require.NoError(t, err) diff --git a/e2e/e2e_test.go b/e2e/e2e_test.go index 9c42e4e..242617a 100644 --- a/e2e/e2e_test.go +++ b/e2e/e2e_test.go @@ -45,7 +45,7 @@ func TestMain(m *testing.M) { wg.Done() }() - time.Sleep(3 * time.Second) + time.Sleep(5 * time.Second) code := m.Run() cancel() diff --git a/e2e/processor.yaml b/e2e/processor.yaml index f4cbb1a..5e9723b 100644 --- a/e2e/processor.yaml +++ b/e2e/processor.yaml @@ -1,7 +1,7 @@ log: level: debug videoapi: - endpoint: http://localhost:18082/api/video + endpoint: localhost:18093 token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiJzdmMtQnNwMjhpcG1TSFdkSTdTSXdQMEo0QSIsIm5hbWUiOiJub3RpZmljYXRvciIsInJvbGUiOiJzZXJ2aWNlIiwiZXhwIjoxNzM2ODgwMDk0fQ.xjMV5Z_EBGch6fYM9ZSSC3W9QKjij2S0zI8HGz8wrAY" s3: prefix_upload: /upload diff --git a/e2e/streamer.yaml b/e2e/streamer.yaml index 8fe3005..2dafb22 100644 --- a/e2e/streamer.yaml +++ b/e2e/streamer.yaml @@ -1,7 +1,8 @@ log: level: debug server: - address: ":18084" + http: + address: ":18084" api: prefix: /watch redis: diff --git a/e2e/uploader.yaml b/e2e/uploader.yaml index 5672abc..c1b54cb 100644 --- a/e2e/uploader.yaml +++ b/e2e/uploader.yaml @@ -1,13 +1,14 @@ log: level: debug server: - address: ":18083" + http: + address: ":18083" api: prefix: /upload redis: dsn: redis://localhost:6379/0 videoapi: - endpoint: http://localhost:18082/api/video + endpoint: localhost:18093 token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiJzdmMtQnNwMjhpcG1TSFdkSTdTSXdQMEo0QSIsIm5hbWUiOiJub3RpZmljYXRvciIsInJvbGUiOiJzZXJ2aWNlIiwiZXhwIjoxNzM2ODgwMDk0fQ.xjMV5Z_EBGch6fYM9ZSSC3W9QKjij2S0zI8HGz8wrAY" s3: prefix_upload: /upload diff --git a/e2e/userapi.yaml b/e2e/userapi.yaml index 1461cb7..89eda97 100644 --- a/e2e/userapi.yaml +++ b/e2e/userapi.yaml @@ -1,7 +1,8 @@ log: level: debug server: - address: ":18081" + http: + address: ":18081" api: prefix: /api/user database: diff --git a/e2e/userapi_test.go b/e2e/userapi_test.go index 9c369dd..a391887 100644 --- a/e2e/userapi_test.go +++ b/e2e/userapi_test.go @@ -4,17 +4,27 @@ package e2e import ( "net/http" + "strconv" "testing" + "time" "github.com/adwski/vidi/internal/api/user/model" ) +var ( + testUserName = "testuser" +) + +func init() { + testUserName += strconv.Itoa(int(time.Now().Unix())) +} + func TestUserRegistration(t *testing.T) { //------------------------------------------------------------------------------- // Login with not-existent user //------------------------------------------------------------------------------- userLoginFail(t, &model.UserRequest{ - Username: "testuser", + Username: testUserName, Password: "testpass", }, http.StatusUnauthorized) @@ -22,7 +32,7 @@ func TestUserRegistration(t *testing.T) { // Register user //------------------------------------------------------------------------------- cookie := userRegister(t, &model.UserRequest{ - Username: "testuser", + Username: testUserName, Password: "testpass", }) t.Logf("user is registered, token: %v", cookie.Value) @@ -31,7 +41,7 @@ func TestUserRegistration(t *testing.T) { // Register existing user //------------------------------------------------------------------------------- userRegisterFail(t, &model.UserRequest{ - Username: "testuser", + Username: testUserName, Password: "testpass", }, http.StatusConflict) @@ -46,7 +56,7 @@ func TestUserLogin(t *testing.T) { // Login with existent user //------------------------------------------------------------------------------- cookie2 := userLogin(t, &model.UserRequest{ - Username: "testuser", + Username: testUserName, Password: "testpass", }) t.Logf("user is logged in, token: %v", cookie2.Value) @@ -63,7 +73,7 @@ func TestUserLogin(t *testing.T) { // Login with wrong password //------------------------------------------------------------------------------- userLoginFail(t, &model.UserRequest{ - Username: "testuser", + Username: testUserName, Password: "testpass2", }, http.StatusUnauthorized) diff --git a/e2e/videoapi.yaml b/e2e/videoapi.yaml index f4d051b..640ee10 100644 --- a/e2e/videoapi.yaml +++ b/e2e/videoapi.yaml @@ -1,7 +1,11 @@ log: level: debug server: - address: ":18082" + http: + address: ":18082" + grpc: + address: ":18092" + svc_address: ":18093" api: prefix: /api/video database: diff --git a/e2e/videoapi_test.go b/e2e/videoapi_test.go index 953ac12..92ca952 100644 --- a/e2e/videoapi_test.go +++ b/e2e/videoapi_test.go @@ -1,4 +1,4 @@ -//go:build e2e +//go:build e2e && skip package e2e @@ -34,7 +34,7 @@ func TestCreateAndDeleteVideo(t *testing.T) { // Create video //------------------------------------------------------------------------------- videoResponse := videoCreate(t, cookie) - t.Logf("video created, id: %s, upload url: %v", videoResponse.ID, videoResponse.UploadURL) + t.Logf("video created, id: %s, upload url: %v", videoResponse.ID, videoResponse.UploadInfo.URL) //------------------------------------------------------------------------------- // Get video @@ -67,12 +67,12 @@ func TestCreateAndUploadVideo(t *testing.T) { // Create video //------------------------------------------------------------------------------- videoResponse := videoCreate(t, cookie) - t.Logf("video created, id: %s, upload url: %v", videoResponse.ID, videoResponse.UploadURL) + t.Logf("video created, id: %s, upload url: %v", videoResponse.ID, videoResponse.UploadInfo.URL) //------------------------------------------------------------------------------- // Upload video //------------------------------------------------------------------------------- - videoUpload(t, videoResponse.UploadURL) + videoUpload(t, videoResponse.UploadInfo.URL) //------------------------------------------------------------------------------- // Wait until processed @@ -138,7 +138,7 @@ func TestFails(t *testing.T) { // Create video //------------------------------------------------------------------------------- videoResponse := videoCreate(t, cookie) - t.Logf("video created, id: %s, upload url: %v", videoResponse.ID, videoResponse.UploadURL) + t.Logf("video created, id: %s, upload url: %v", videoResponse.ID, videoResponse.UploadInfo.URL) //------------------------------------------------------------------------------- // Get video @@ -158,12 +158,12 @@ func TestFails(t *testing.T) { //------------------------------------------------------------------------------- // Upload video, invalid request //------------------------------------------------------------------------------- - videoUploadFailGet(t, videoResponse.UploadURL) + videoUploadFailGet(t, videoResponse.UploadInfo.URL) //------------------------------------------------------------------------------- // Upload video, invalid requests //------------------------------------------------------------------------------- - url := videoResponse.UploadURL[:strings.LastIndex(videoResponse.UploadURL, "/")] + url := videoResponse.UploadInfo.URL[:strings.LastIndex(videoResponse.UploadInfo.URL, "/")] videoUploadFail(t, url) videoUploadFail(t, url+"/qweqwe/") }