复制项目

This commit is contained in:
kim.dev.6789
2026-01-14 22:16:44 +08:00
parent e2577b8cee
commit e50142a3b9
691 changed files with 97009 additions and 1 deletions

136
test/e2e/README.md Normal file
View File

@@ -0,0 +1,136 @@
# OpenIM End-to-End (E2E) Testing Module
## Overview
This repository contains the End-to-End (E2E) testing suite for OpenIM, a comprehensive instant messaging platform. The E2E tests are designed to simulate real-world usage scenarios to ensure that all components of the OpenIM system are functioning correctly in an integrated environment.
The tests cover various aspects of the system, including API endpoints, chat services, web interfaces, and RPC components, as well as performance and scalability under different load conditions.
## Directory Structure
```bash
tree e2e
test/e2e/
├── conformance/ # Contains tests for verifying OpenIM API conformance
├── framework/ # Provides auxiliary code and libraries for building and running E2E tests
│ ├── config/ # Test configuration files and management
│ ├── ginkgowrapper/ # Functions wrapping the testing library for handling test failures and skips
│ └── helpers/ # Helper functions such as user creation, message sending, etc.
├── api/ # End-to-end tests for OpenIM API
├── chat/ # Tests for the business server (including login, registration, and other logic)
├── web/ # Tests for the web frontend (login, registration, message sending and receiving)
├── rpc/ # End-to-end tests for various RPC components
│ ├── auth/ # Tests for the authentication service
│ ├── conversation/ # Tests for conversation management
│ ├── friend/ # Tests for friend relationship management
│ ├── group/ # Tests for group management
│ └── message/ # Tests for message handling
├── scalability/ # Tests for the scalability of the OpenIM system
├── performance/ # Performance tests such as load testing and stress testing
└── upgrade/ # Tests for compatibility and stability during OpenIM upgrades
```
The E2E tests are organized into the following directory structure:
- `conformance/`: Contains tests to verify the conformance of OpenIM API implementations.
- `framework/`: Provides helper code for constructing and running E2E tests using the Ginkgo framework.
- `config/`: Manages test configurations and options.
- `ginkgowrapper/`: Wrappers for Ginkgo's `Fail` and `Skip` functions to handle structured data panics.
- `helpers/`: Utility functions for common test actions like user creation, message dispatching, etc.
- `api/`: E2E tests for the OpenIM API endpoints.
- `chat/`: Tests for the chat service, including authentication, session management, and messaging logic.
- `web/`: Tests for the web interface, including user interactions and information exchange.
- `rpc/`: E2E tests for each of the RPC components.
- `auth/`: Tests for the authentication service.
- `conversation/`: Tests for conversation management.
- `friend/`: Tests for friend relationship management.
- `group/`: Tests for group management.
- `message/`: Tests for message handling.
- `scalability/`: Tests for the scalability of the OpenIM system.
- `performance/`: Performance tests, including load and stress tests.
- `upgrade/`: Tests for the upgrade process of OpenIM, ensuring compatibility and stability.
## Prerequisites
Since the deployment of OpenIM requires some components such as Mongo and Kafka, you should think a bit before using E2E tests
```bash
docker compose up -d
```
OR User [kubernetes deployment](https://github.com/openimsdk/helm-charts)
Before running the E2E tests, ensure that you have the following prerequisites installed:
- Docker
- Kubernetes
- Ginkgo test framework
- Go (version 1.19 or higher)
## Configuration
Test configurations can be customized via the `config/` directory. The configuration files are in YAML format and allow you to set parameters such as API endpoints, user credentials, and test data.
## Running the Tests
To run a single test or set of tests, you'll need the [Ginkgo](https://github.com/onsi/ginkgo) tool installed on your machine:
```
ginkgo --help
--focus value
If set, ginkgo will only run specs that match this regular expression. Can be specified multiple times, values are ORed.
```
To run the entire suite of E2E tests, use the following command:
```sh
ginkgo -v --randomizeAllSpecs --randomizeSuites --failOnPending --cover --trace --race --progress
```
You can also run a specific test or group of tests by specifying the path to the test directory:
```bash
ginkgo -v ./test/e2e/chat
```
Or you can use Makefile to run the tests:
```bash
make test-e2e
```
## Test Development
To contribute to the E2E tests:
1. Clone the repository and navigate to the `test/e2e/` directory.
2. Create a new test file or modify an existing test to cover a new scenario.
3. Write test cases using the Ginkgo BDD style, ensuring that they are clear and descriptive.
4. Run the tests locally to ensure they pass.
5. Submit a pull request with your changes.
Please refer to the `CONTRIBUTING.md` file for more detailed instructions on contributing to the test suite.
## Reporting Issues
If you encounter any issues while running the E2E tests, please open an issue on the GitHub repository with the following information:
Open issue: https://github.com/openimsdk/open-im-server-deploy/issues/new/choose, choose "Failing Test" template.
+ A clear and concise description of the issue.
+ Steps to reproduce the behavior.
+ Relevant logs and test output.
+ Any other context that could be helpful in troubleshooting.
## Continuous Integration (CI)
The E2E test suite is integrated with CI, which runs the tests automatically on each code commit. The results are reported back to the pull request or commit to provide immediate feedback on the impact of the changes.
[![OpenIM Linux System E2E Test](https://github.com/openimsdk/open-im-server-deploy/actions/workflows/e2e-test.yml/badge.svg)](https://github.com/openimsdk/open-im-server-deploy/actions/workflows/e2e-test.yml)
## Contact
For any queries or assistance, please reach out to the OpenIM development team at [support@openim.com](mailto:support@openim.com).

149
test/e2e/api/token/token.go Normal file
View File

@@ -0,0 +1,149 @@
// Copyright © 2023 OpenIM. All rights reserved.
//
// 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 token
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
// API endpoints and other constants.
const (
APIHost = "http://127.0.0.1:10002"
UserTokenURL = APIHost + "/auth/user_token"
UserRegisterURL = APIHost + "/user/user_register"
SecretKey = "openIM123"
OperationID = "1646445464564"
)
// UserTokenRequest represents a request to get a user token.
type UserTokenRequest struct {
Secret string `json:"secret"`
PlatformID int `json:"platformID"`
UserID string `json:"userID"`
}
// UserTokenResponse represents a response containing a user token.
type UserTokenResponse struct {
Token string `json:"token"`
ErrCode int `json:"errCode"`
}
// User represents user data for registration.
type User struct {
UserID string `json:"userID"`
Nickname string `json:"nickname"`
FaceURL string `json:"faceURL"`
}
// UserRegisterRequest represents a request to register a user.
type UserRegisterRequest struct {
Users []User `json:"users"`
}
/* func main() {
// Example usage of functions
token, err := GetUserToken("openIM123456")
if err != nil {
log.Fatalf("Error getting user token: %v", err)
}
fmt.Println("Token:", token)
err = RegisterUser(token, "testUserID", "TestNickname", "https://example.com/image.jpg")
if err != nil {
log.Fatalf("Error registering user: %v", err)
}
} */
// GetUserToken requests a user token from the API.
func GetUserToken(userID string) (string, error) {
reqBody := UserTokenRequest{
Secret: SecretKey,
PlatformID: 1,
UserID: userID,
}
reqBytes, err := json.Marshal(reqBody)
if err != nil {
return "", err
}
resp, err := http.Post(UserTokenURL, "application/json", bytes.NewBuffer(reqBytes))
if err != nil {
return "", err
}
defer resp.Body.Close()
var tokenResp UserTokenResponse
if err := json.NewDecoder(resp.Body).Decode(&tokenResp); err != nil {
return "", err
}
if tokenResp.ErrCode != 0 {
return "", fmt.Errorf("error in token response: %v", tokenResp.ErrCode)
}
return tokenResp.Token, nil
}
// RegisterUser registers a new user using the API.
func RegisterUser(token, userID, nickname, faceURL string) error {
user := User{
UserID: userID,
Nickname: nickname,
FaceURL: faceURL,
}
reqBody := UserRegisterRequest{
Users: []User{user},
}
reqBytes, err := json.Marshal(reqBody)
if err != nil {
return err
}
client := &http.Client{}
req, err := http.NewRequest("POST", UserRegisterURL, bytes.NewBuffer(reqBytes))
if err != nil {
return err
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("operationID", OperationID)
req.Header.Add("token", token)
resp, err := client.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
respBody, err := io.ReadAll(resp.Body)
if err != nil {
return err
}
var respData map[string]any
if err := json.Unmarshal(respBody, &respData); err != nil {
return err
}
if errCode, ok := respData["errCode"].(float64); ok && errCode != 0 {
return fmt.Errorf("error in user registration response: %v", respData)
}
return nil
}

71
test/e2e/api/user/curd.go Normal file
View File

@@ -0,0 +1,71 @@
// Copyright © 2023 OpenIM. All rights reserved.
//
// 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 user
import (
"fmt"
gettoken "git.imall.cloud/openim/open-im-server-deploy/test/e2e/api/token"
"git.imall.cloud/openim/open-im-server-deploy/test/e2e/framework/config"
)
// UserInfoRequest represents a request to get or update user information.
type UserInfoRequest struct {
UserIDs []string `json:"userIDs,omitempty"`
UserInfo *gettoken.User `json:"userInfo,omitempty"`
}
// GetUsersOnlineStatusRequest represents a request to get users' online status.
type GetUsersOnlineStatusRequest struct {
UserIDs []string `json:"userIDs"`
}
// GetUsersInfo retrieves detailed information for a list of user IDs.
func GetUsersInfo(token string, userIDs []string) error {
url := fmt.Sprintf("http://%s:%s/user/get_users_info", config.LoadConfig().APIHost, config.LoadConfig().APIPort)
requestBody := UserInfoRequest{
UserIDs: userIDs,
}
return sendPostRequestWithToken(url, token, requestBody)
}
// UpdateUserInfo updates the information for a user.
func UpdateUserInfo(token, userID, nickname, faceURL string) error {
url := fmt.Sprintf("http://%s:%s/user/update_user_info", config.LoadConfig().APIHost, config.LoadConfig().APIPort)
requestBody := UserInfoRequest{
UserInfo: &gettoken.User{
UserID: userID,
Nickname: nickname,
FaceURL: faceURL,
},
}
return sendPostRequestWithToken(url, token, requestBody)
}
// GetUsersOnlineStatus retrieves the online status for a list of user IDs.
func GetUsersOnlineStatus(token string, userIDs []string) error {
url := fmt.Sprintf("http://%s:%s/user/get_users_online_status", config.LoadConfig().APIHost, config.LoadConfig().APIPort)
requestBody := GetUsersOnlineStatusRequest{
UserIDs: userIDs,
}
return sendPostRequestWithToken(url, token, requestBody)
}

125
test/e2e/api/user/user.go Normal file
View File

@@ -0,0 +1,125 @@
// Copyright © 2023 OpenIM. All rights reserved.
//
// 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 user
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
gettoken "git.imall.cloud/openim/open-im-server-deploy/test/e2e/api/token"
"git.imall.cloud/openim/open-im-server-deploy/test/e2e/framework/config"
)
// ForceLogoutRequest represents a request to force a user logout.
type ForceLogoutRequest struct {
PlatformID int `json:"platformID"`
UserID string `json:"userID"`
}
// CheckUserAccountRequest represents a request to check a user account.
type CheckUserAccountRequest struct {
CheckUserIDs []string `json:"checkUserIDs"`
}
// GetUsersRequest represents a request to get a list of users.
type GetUsersRequest struct {
Pagination Pagination `json:"pagination"`
}
// Pagination specifies the page number and number of items per page.
type Pagination struct {
PageNumber int `json:"pageNumber"`
ShowNumber int `json:"showNumber"`
}
// ForceLogout forces a user to log out.
func ForceLogout(token, userID string, platformID int) error {
url := fmt.Sprintf("http://%s:%s/auth/force_logout", config.LoadConfig().APIHost, config.LoadConfig().APIPort)
requestBody := ForceLogoutRequest{
PlatformID: platformID,
UserID: userID,
}
return sendPostRequestWithToken(url, token, requestBody)
}
// CheckUserAccount checks if the user accounts exist.
func CheckUserAccount(token string, userIDs []string) error {
url := fmt.Sprintf("http://%s:%s/user/account_check", config.LoadConfig().APIHost, config.LoadConfig().APIPort)
requestBody := CheckUserAccountRequest{
CheckUserIDs: userIDs,
}
return sendPostRequestWithToken(url, token, requestBody)
}
// GetUsers retrieves a list of users with pagination.
func GetUsers(token string, pageNumber, showNumber int) error {
url := fmt.Sprintf("http://%s:%s/user/account_check", config.LoadConfig().APIHost, config.LoadConfig().APIPort)
requestBody := GetUsersRequest{
Pagination: Pagination{
PageNumber: pageNumber,
ShowNumber: showNumber,
},
}
return sendPostRequestWithToken(url, token, requestBody)
}
// sendPostRequestWithToken sends a POST request with a token in the header.
func sendPostRequestWithToken(url, token string, body any) error {
reqBytes, err := json.Marshal(body)
if err != nil {
return err
}
client := &http.Client{}
req, err := http.NewRequest("POST", url, bytes.NewBuffer(reqBytes))
if err != nil {
return err
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("operationID", gettoken.OperationID)
req.Header.Add("token", token)
resp, err := client.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
respBody, err := io.ReadAll(resp.Body)
if err != nil {
return err
}
var respData map[string]any
if err := json.Unmarshal(respBody, &respData); err != nil {
return err
}
if errCode, ok := respData["errCode"].(float64); ok && errCode != 0 {
return fmt.Errorf("error in response: %v", respData)
}
return nil
}

View File

@@ -0,0 +1 @@
.keep

51
test/e2e/e2e.go Normal file
View File

@@ -0,0 +1,51 @@
// Copyright © 2023 OpenIM. All rights reserved.
//
// 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 e2e
import (
"testing"
gettoken "git.imall.cloud/openim/open-im-server-deploy/test/e2e/api/token"
"git.imall.cloud/openim/open-im-server-deploy/test/e2e/api/user"
)
// RunE2ETests checks configuration parameters (specified through flags) and then runs
// E2E tests using the Ginkgo runner.
// If a "report directory" is specified, one or more JUnit test reports will be
// generated in this directory, and cluster logs will also be saved.
// This function is called on each Ginkgo node in parallel mode.
func RunE2ETests(t *testing.T) {
// Example usage of new functions
token, _ := gettoken.GetUserToken("openIM123456")
// Example of getting user info
_ = user.GetUsersInfo(token, []string{"user1", "user2"})
// Example of updating user info
_ = user.UpdateUserInfo(token, "user1", "NewNickname", "https://github.com/openimsdk/open-im-server-deploy/blob/main/assets/logo/openim-logo.png")
// Example of getting users' online status
_ = user.GetUsersOnlineStatus(token, []string{"user1", "user2"})
// Example of forcing a logout
_ = user.ForceLogout(token, "4950983283", 2)
// Example of checking user account
_ = user.CheckUserAccount(token, []string{"openIM123456", "anotherUserID"})
// Example of getting users
_ = user.GetUsers(token, 1, 100)
}

37
test/e2e/e2e_test.go Normal file
View File

@@ -0,0 +1,37 @@
// Copyright © 2023 OpenIM. All rights reserved.
//
// 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 e2e
import (
"flag"
"testing"
"git.imall.cloud/openim/open-im-server-deploy/test/e2e/framework/config"
)
// handleFlags sets up all flags and parses the command line.
func handleFlags() {
config.CopyFlags(config.Flags, flag.CommandLine)
flag.Parse()
}
func TestMain(m *testing.M) {
handleFlags()
m.Run()
}
func TestE2E(t *testing.T) {
RunE2ETests(t)
}

View File

@@ -0,0 +1,84 @@
// Copyright © 2023 OpenIM. All rights reserved.
//
// 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 config
import (
"flag"
"os"
)
// Flags is the flag set that AddOptions adds to. Test authors should
// also use it instead of directly adding to the global command line.
var Flags = flag.NewFlagSet("", flag.ContinueOnError)
// CopyFlags ensures that all flags that are defined in the source flag
// set appear in the target flag set as if they had been defined there
// directly. From the flag package it inherits the behavior that there
// is a panic if the target already contains a flag from the source.
func CopyFlags(source *flag.FlagSet, target *flag.FlagSet) {
source.VisitAll(func(flag *flag.Flag) {
// We don't need to copy flag.DefValue. The original
// default (from, say, flag.String) was stored in
// the value and gets extracted by Var for the help
// message.
target.Var(flag.Value, flag.Name, flag.Usage)
})
}
// Config defines the configuration structure for the OpenIM components.
type Config struct {
APIHost string
APIPort string
MsgGatewayHost string
MsgTransferHost string
PushHost string
RPCAuthHost string
RPCConversationHost string
RPCFriendHost string
RPCGroupHost string
RPCMsgHost string
RPCThirdHost string
RPCUserHost string
// Add other configuration fields as needed
}
// LoadConfig loads the configurations from environment variables or default values.
func LoadConfig() *Config {
return &Config{
APIHost: getEnv("OPENIM_API_HOST", "127.0.0.1"),
APIPort: getEnv("API_OPENIM_PORT", "10002"),
// TODO: Set default variable
MsgGatewayHost: getEnv("OPENIM_MSGGATEWAY_HOST", "default-msggateway-host"),
MsgTransferHost: getEnv("OPENIM_MSGTRANSFER_HOST", "default-msgtransfer-host"),
PushHost: getEnv("OPENIM_PUSH_HOST", "default-push-host"),
RPCAuthHost: getEnv("OPENIM_RPC_AUTH_HOST", "default-rpc-auth-host"),
RPCConversationHost: getEnv("OPENIM_RPC_CONVERSATION_HOST", "default-rpc-conversation-host"),
RPCFriendHost: getEnv("OPENIM_RPC_FRIEND_HOST", "default-rpc-friend-host"),
RPCGroupHost: getEnv("OPENIM_RPC_GROUP_HOST", "default-rpc-group-host"),
RPCMsgHost: getEnv("OPENIM_RPC_MSG_HOST", "default-rpc-msg-host"),
RPCThirdHost: getEnv("OPENIM_RPC_THIRD_HOST", "default-rpc-third-host"),
RPCUserHost: getEnv("OPENIM_RPC_USER_HOST", "default-rpc-user-host"),
}
}
// getEnv is a helper function to read an environment variable or return a default value.
func getEnv(key, defaultValue string) string {
value, exists := os.LookupEnv(key)
if !exists {
return defaultValue
}
return value
}

View File

@@ -0,0 +1,89 @@
// Copyright © 2023 OpenIM. All rights reserved.
//
// 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 config
import (
"flag"
"reflect"
"testing"
)
func TestCopyFlags(t *testing.T) {
type args struct {
source *flag.FlagSet
target *flag.FlagSet
}
tests := []struct {
name string
args args
wantErr bool
}{
{
name: "Copy empty source to empty target",
args: args{
source: flag.NewFlagSet("source", flag.ContinueOnError),
target: flag.NewFlagSet("target", flag.ContinueOnError),
},
wantErr: false,
},
{
name: "Copy non-empty source to empty target",
args: args{
source: func() *flag.FlagSet {
fs := flag.NewFlagSet("source", flag.ContinueOnError)
fs.String("test-flag", "default", "test usage")
return fs
}(),
target: flag.NewFlagSet("target", flag.ContinueOnError),
},
wantErr: false,
},
{
name: "Copy source to target with existing flag",
args: args{
source: func() *flag.FlagSet {
fs := flag.NewFlagSet("source", flag.ContinueOnError)
fs.String("test-flag", "default", "test usage")
return fs
}(),
target: func() *flag.FlagSet {
fs := flag.NewFlagSet("target", flag.ContinueOnError)
fs.String("test-flag", "default", "test usage")
return fs
}(),
},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
defer func() {
if r := recover(); (r != nil) != tt.wantErr {
t.Errorf("CopyFlags() panic = %v, wantErr %v", r, tt.wantErr)
}
}()
CopyFlags(tt.args.source, tt.args.target)
// Verify the replicated tag
if !tt.wantErr {
tt.args.source.VisitAll(func(f *flag.Flag) {
if gotFlag := tt.args.target.Lookup(f.Name); gotFlag == nil || !reflect.DeepEqual(gotFlag, f) {
t.Errorf("CopyFlags() failed to copy flag %s", f.Name)
}
})
}
})
}
}

View File

@@ -0,0 +1 @@
.keep

View File

@@ -0,0 +1,15 @@
// Copyright © 2023 OpenIM. All rights reserved.
//
// 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 ginkgowrapper

View File

@@ -0,0 +1,15 @@
// Copyright © 2023 OpenIM. All rights reserved.
//
// 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 ginkgowrapper

View File

@@ -0,0 +1 @@
.keep

View File

@@ -0,0 +1,167 @@
// Copyright © 2023 OpenIM. All rights reserved.
//
// 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 (
"fmt"
"io"
"net/http"
"os"
"os/exec"
"path/filepath"
)
var (
// The default template version.
defaultTemplateVersion = "v1.3.0"
)
func main() {
// Define the URL to get the latest version
// latestVersionURL := "https://github.com/openimsdk/chat/releases/latest"
// latestVersion, err := getLatestVersion(latestVersionURL)
// if err != nil {
// fmt.Printf("Failed to get the latest version: %v\n", err)
// return
// }
latestVersion := defaultTemplateVersion
// getLatestVersion
// Construct the download URL
downloadURL := fmt.Sprintf("https://github.com/openimsdk/chat/releases/download/%s/chat_Linux_x86_64.tar.gz", latestVersion)
// Set the installation directory
installDir := "/tmp/chat"
// Clear the installation directory before proceeding
err := os.RemoveAll(installDir)
if err != nil {
fmt.Printf("Failed to clear installation directory: %v\n", err)
return
}
// Create the installation directory
err = os.MkdirAll(installDir, 0755)
if err != nil {
fmt.Printf("Failed to create installation directory: %v\n", err)
return
}
// Download and extract OpenIM Chat to the installation directory
err = downloadAndExtract(downloadURL, installDir)
if err != nil {
fmt.Printf("Failed to download and extract OpenIM Chat: %v\n", err)
return
}
// Create configuration file directory
configDir := filepath.Join(installDir, "config")
err = os.MkdirAll(configDir, 0755)
if err != nil {
fmt.Printf("Failed to create configuration directory: %v\n", err)
return
}
// Download configuration files
configURL := "https://raw.githubusercontent.com/openimsdk/chat/main/config/config.yaml"
err = downloadAndExtract(configURL, configDir)
if err != nil {
fmt.Printf("Failed to download and extract configuration files: %v\n", err)
return
}
// Define the processes to be started
cmds := []string{
"admin-api",
"admin-rpc",
"chat-api",
"chat-rpc",
}
// Start each process in a new goroutine
for _, cmd := range cmds {
go startProcess(filepath.Join(installDir, cmd))
}
// Block the main thread indefinitely
select {}
}
/* func getLatestVersion(url string) (string, error) {
resp, err := webhook.Get(url)
if err != nil {
return "", err
}
defer resp.Body.Close()
// location := resp.Header.Get("Location")
// if location == "" {
// return defaultTemplateVersion, nil
// }
// Extract the version number from the URL
latestVersion := filepath.Base(location)
return latestVersion, nil
} */
// downloadAndExtract downloads a file from a URL and extracts it to a destination directory.
func downloadAndExtract(url, destDir string) error {
resp, err := http.Get(url)
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("error downloading file, HTTP status code: %d", resp.StatusCode)
}
// Create the destination directory
err = os.MkdirAll(destDir, 0755)
if err != nil {
return err
}
// Define the path for the downloaded file
filePath := filepath.Join(destDir, "downloaded_file.tar.gz")
file, err := os.Create(filePath)
if err != nil {
return err
}
defer file.Close()
// Copy the downloaded file
_, err = io.Copy(file, resp.Body)
if err != nil {
return err
}
// Extract the file
cmd := exec.Command("tar", "xzvf", filePath, "-C", destDir)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd.Run()
}
// startProcess starts a process and prints any errors encountered.
func startProcess(cmdPath string) {
cmd := exec.Command(cmdPath)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
fmt.Printf("Failed to start process %s: %v\n", cmdPath, err)
}
}

View File

@@ -0,0 +1,15 @@
// Copyright © 2024 OpenIM. All rights reserved.
//
// 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 page

View File

@@ -0,0 +1,15 @@
// Copyright © 2024 OpenIM. All rights reserved.
//
// 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 page

View File

@@ -0,0 +1 @@
.keep

1
test/e2e/rpc/auth/.keep Normal file
View File

@@ -0,0 +1 @@
.keep

View File

@@ -0,0 +1 @@
.keep

View File

@@ -0,0 +1 @@
.keep

1
test/e2e/rpc/group/.keep Normal file
View File

@@ -0,0 +1 @@
.keep

View File

@@ -0,0 +1 @@
.keep

View File

@@ -0,0 +1 @@
.keep

1
test/e2e/upgrade/.keep Normal file
View File

@@ -0,0 +1 @@
.keep

2
test/e2e/web/Readme.md Normal file
View File

@@ -0,0 +1,2 @@
# OpenIM Web E2E